summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-02-23 23:41:34 (GMT)
committerBrad King <brad.king@kitware.com>2022-02-24 18:47:43 (GMT)
commit802b76140d782d1482ddbff676fee6108b1224b5 (patch)
treeaf4e6fc21b68a1bb2b9aafcfe7e68ecc684f06fc
parentb0ac0fbe0eac590233cb94b3124239a491ee2a9b (diff)
downloadCMake-802b76140d782d1482ddbff676fee6108b1224b5.zip
CMake-802b76140d782d1482ddbff676fee6108b1224b5.tar.gz
CMake-802b76140d782d1482ddbff676fee6108b1224b5.tar.bz2
Tests: Extend RunCMake.SymlinkTrees to verify paths passed to compiler
Verify that the paths to source files and include directories are passed to the compiler with the symlinks preserved.
-rw-r--r--Tests/RunCMake/SymlinkTrees/CMakeLists.txt43
-rw-r--r--Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake10
-rw-r--r--Tests/RunCMake/SymlinkTrees/common-separate-exe-build-stdout.txt4
-rw-r--r--Tests/RunCMake/SymlinkTrees/generic-exe-build-stdout.txt4
4 files changed, 61 insertions, 0 deletions
diff --git a/Tests/RunCMake/SymlinkTrees/CMakeLists.txt b/Tests/RunCMake/SymlinkTrees/CMakeLists.txt
index d090fea..e16faea 100644
--- a/Tests/RunCMake/SymlinkTrees/CMakeLists.txt
+++ b/Tests/RunCMake/SymlinkTrees/CMakeLists.txt
@@ -7,3 +7,46 @@ get_filename_component(real_source "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component(real_binary "${CMAKE_BINARY_DIR}" REALPATH)
message(STATUS "real source: '${real_source}'")
message(STATUS "real binary: '${real_binary}'")
+
+if(RunCMake_TEST MATCHES "-exe")
+ enable_language(C)
+ file(WRITE "${CMAKE_SOURCE_DIR}/source.c" [[
+ #include <stdio.h>
+ #include "source.h"
+ #include "binary.h"
+ extern void print_binary_c(void);
+ extern void print_binary_c(void);
+ void print_source_c(void) {
+ printf("source.c: '%s'\n", __FILE__);
+ }
+ int main(void) {
+ print_source_c();
+ print_source_h();
+ print_binary_c();
+ print_binary_h();
+ return 0;
+ }
+ ]])
+ file(WRITE "${CMAKE_BINARY_DIR}/binary.c" [[
+ #include <stdio.h>
+ void print_binary_c(void) {
+ printf("binary.c: '%s'\n", __FILE__);
+ }
+ ]])
+ file(WRITE "${CMAKE_SOURCE_DIR}/include/source.h" [[
+ void print_source_h(void) {
+ printf("source.h: '%s'\n", __FILE__);
+ }
+ ]])
+ file(WRITE "${CMAKE_BINARY_DIR}/include/binary.h" [[
+ void print_binary_h(void) {
+ printf("binary.h: '%s'\n", __FILE__);
+ }
+ ]])
+ add_executable(exe source.c ${CMAKE_BINARY_DIR}/binary.c)
+ target_include_directories(exe PRIVATE
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_BINARY_DIR}/include
+ )
+ add_custom_target(print ALL COMMAND exe)
+endif()
diff --git a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
index 02989ab..72676d2 100644
--- a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
+++ b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
@@ -74,6 +74,16 @@ function (run_symlink_test case src bin src_from_bin bin_from_src)
# Pass relative paths to the source and binary trees.
set(RunCMake_TEST_VARIANT_DESCRIPTION " -S ../${name}/${src} -B ../${name}/${bin}")
run_symlink_test_case("${case}" -S "../${name}/${src}" -B "../${name}/${bin}")
+
+ # Verify paths passed to compiler.
+ unset(RunCMake_TEST_VARIANT_DESCRIPTION)
+ run_symlink_test_case("${case}-exe" -S "${src}" -B "${bin}")
+ if (RunCMake_GENERATOR MATCHES "Xcode")
+ # The native build system may pass the real paths.
+ set(RunCMake-stdout-file "generic-exe-build-stdout.txt")
+ endif()
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command("${case}-exe-build" ${CMAKE_COMMAND} --build "${bin}")
endfunction ()
# Create the following structure:
diff --git a/Tests/RunCMake/SymlinkTrees/common-separate-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-separate-exe-build-stdout.txt
new file mode 100644
index 0000000..7f73af2
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/common-separate-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/generic-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/generic-exe-build-stdout.txt
new file mode 100644
index 0000000..db2173c
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/generic-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/include/binary.h'