diff options
author | Matthew Woehlke <matthew.woehlke@kitware.com> | 2022-09-02 14:21:12 (GMT) |
---|---|---|
committer | Matthew Woehlke <matthew.woehlke@kitware.com> | 2022-09-05 17:19:59 (GMT) |
commit | aa9220d3a0c4a5b15a9a590ed75afedff38764fe (patch) | |
tree | b7f2decb489123643acbef1e85850b803c7a2722 /Tests/RunCMake/try_run | |
parent | d1befe5515968d7fe4f7fd3f2ca243e98d6012d0 (diff) | |
download | CMake-aa9220d3a0c4a5b15a9a590ed75afedff38764fe.zip CMake-aa9220d3a0c4a5b15a9a590ed75afedff38764fe.tar.gz CMake-aa9220d3a0c4a5b15a9a590ed75afedff38764fe.tar.bz2 |
try_compile: Add keyword-dispatched signature
Introduce a new signature for try_compile (and try_run) which removes
the `bindir` argument and requires the SOURCES tag. This will eventually
allow us to add other ways of providing sources, but also allows us to
change the behavior without breaking compatibility.
The old signature uses a special, but non-unique temporary location
inside the specified `bindir`, which conventionally is just the
project's build directory. The new signature unconditionally uses the a
unique temporary directory which is unconditionally within the project's
build directory (which is no longer separately specified). This ensures
that successive runs do not overwrite previous runs, will simplify
debugging, and should also, eventually, allow us to execute multiple
trials in parallel.
Diffstat (limited to 'Tests/RunCMake/try_run')
-rw-r--r-- | Tests/RunCMake/try_run/BadLinkLibraries-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/BadLinkLibraries.cmake | 7 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/NoCompileOutputVariable.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/NoRunOutputVariable.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/NoRunStdErrVariable-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/NoRunStdErrVariable.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/NoRunStdOutVariable-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/NoRunStdOutVariable.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/NoWorkingDirectory.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/RunCMakeTest.cmake | 19 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/WorkingDirArg.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/new_signature.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/old_and_new_signature_tests.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/try_run/old_signature.cmake | 2 |
14 files changed, 56 insertions, 27 deletions
diff --git a/Tests/RunCMake/try_run/BadLinkLibraries-stderr.txt b/Tests/RunCMake/try_run/BadLinkLibraries-stderr.txt index dcd1bfc..f9cc50e 100644 --- a/Tests/RunCMake/try_run/BadLinkLibraries-stderr.txt +++ b/Tests/RunCMake/try_run/BadLinkLibraries-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at BadLinkLibraries.cmake:2 \(try_run\): +CMake Error at BadLinkLibraries.cmake:[0-9+] \(try_run\): Only libraries may be used as try_compile or try_run IMPORTED LINK_LIBRARIES. Got not_a_library of type UTILITY. Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/try_run/BadLinkLibraries.cmake b/Tests/RunCMake/try_run/BadLinkLibraries.cmake index a124bf6..950a942 100644 --- a/Tests/RunCMake/try_run/BadLinkLibraries.cmake +++ b/Tests/RunCMake/try_run/BadLinkLibraries.cmake @@ -1,4 +1,7 @@ +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) + add_custom_target(not_a_library) -try_run(RUN_RESULT COMPILE_RESULT - ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp ${CMAKE_CURRENT_SOURCE_DIR}/src.c + +try_run(RUN_RESULT COMPILE_RESULT ${try_compile_bindir_or_SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c LINK_LIBRARIES not_a_library) diff --git a/Tests/RunCMake/try_run/NoCompileOutputVariable.cmake b/Tests/RunCMake/try_run/NoCompileOutputVariable.cmake index 85b91f4..9eb7c5e 100644 --- a/Tests/RunCMake/try_run/NoCompileOutputVariable.cmake +++ b/Tests/RunCMake/try_run/NoCompileOutputVariable.cmake @@ -1,4 +1,6 @@ -try_run(RUN_RESULT COMPILE_RESULT - ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp ${CMAKE_CURRENT_SOURCE_DIR}/src.c +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) + +try_run(RUN_RESULT COMPILE_RESULT ${try_compile_bindir_or_SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c COMPILE_OUTPUT_VARIABLE ) diff --git a/Tests/RunCMake/try_run/NoRunOutputVariable.cmake b/Tests/RunCMake/try_run/NoRunOutputVariable.cmake index 25310d8..f9e5e0b 100644 --- a/Tests/RunCMake/try_run/NoRunOutputVariable.cmake +++ b/Tests/RunCMake/try_run/NoRunOutputVariable.cmake @@ -1,4 +1,6 @@ -try_run(RUN_RESULT COMPILE_RESULT - ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp ${CMAKE_CURRENT_SOURCE_DIR}/src.c +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) + +try_run(RUN_RESULT COMPILE_RESULT ${try_compile_bindir_or_SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c RUN_OUTPUT_VARIABLE ) diff --git a/Tests/RunCMake/try_run/NoRunStdErrVariable-stderr.txt b/Tests/RunCMake/try_run/NoRunStdErrVariable-stderr.txt index 04ffc5d..1443ab2 100644 --- a/Tests/RunCMake/try_run/NoRunStdErrVariable-stderr.txt +++ b/Tests/RunCMake/try_run/NoRunStdErrVariable-stderr.txt @@ -1,4 +1,4 @@ -^CMake Error at NoRunStdErrVariable.cmake:1 \(try_run\): +^CMake Error at NoRunStdErrVariable.cmake:[0-9]+ \(try_run\): Error after keyword "RUN_OUTPUT_STDERR_VARIABLE": missing required value diff --git a/Tests/RunCMake/try_run/NoRunStdErrVariable.cmake b/Tests/RunCMake/try_run/NoRunStdErrVariable.cmake index 88c2a72..888bc25 100644 --- a/Tests/RunCMake/try_run/NoRunStdErrVariable.cmake +++ b/Tests/RunCMake/try_run/NoRunStdErrVariable.cmake @@ -1,5 +1,7 @@ -try_run(RUN_RESULT COMPILE_RESULT - ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp ${CMAKE_CURRENT_SOURCE_DIR}/src.c +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) + +try_run(RUN_RESULT COMPILE_RESULT ${try_compile_bindir_or_SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp/workdir RUN_OUTPUT_STDERR_VARIABLE ) diff --git a/Tests/RunCMake/try_run/NoRunStdOutVariable-stderr.txt b/Tests/RunCMake/try_run/NoRunStdOutVariable-stderr.txt index 40e0e27..8b90e94 100644 --- a/Tests/RunCMake/try_run/NoRunStdOutVariable-stderr.txt +++ b/Tests/RunCMake/try_run/NoRunStdOutVariable-stderr.txt @@ -1,4 +1,4 @@ -^CMake Error at NoRunStdOutVariable.cmake:1 \(try_run\): +^CMake Error at NoRunStdOutVariable.cmake:[0-9]+ \(try_run\): Error after keyword "RUN_OUTPUT_STDOUT_VARIABLE": missing required value diff --git a/Tests/RunCMake/try_run/NoRunStdOutVariable.cmake b/Tests/RunCMake/try_run/NoRunStdOutVariable.cmake index 691e881..ed6ab88 100644 --- a/Tests/RunCMake/try_run/NoRunStdOutVariable.cmake +++ b/Tests/RunCMake/try_run/NoRunStdOutVariable.cmake @@ -1,5 +1,7 @@ -try_run(RUN_RESULT COMPILE_RESULT - ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp ${CMAKE_CURRENT_SOURCE_DIR}/src.c +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) + +try_run(RUN_RESULT COMPILE_RESULT ${try_compile_bindir_or_SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp/workdir RUN_OUTPUT_STDOUT_VARIABLE ) diff --git a/Tests/RunCMake/try_run/NoWorkingDirectory.cmake b/Tests/RunCMake/try_run/NoWorkingDirectory.cmake index a115e36..0d68182 100644 --- a/Tests/RunCMake/try_run/NoWorkingDirectory.cmake +++ b/Tests/RunCMake/try_run/NoWorkingDirectory.cmake @@ -1,4 +1,6 @@ -try_run(RUN_RESULT COMPILE_RESULT - ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp ${CMAKE_CURRENT_SOURCE_DIR}/src.c +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) + +try_run(RUN_RESULT COMPILE_RESULT ${try_compile_bindir_or_SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c WORKING_DIRECTORY ) diff --git a/Tests/RunCMake/try_run/RunCMakeTest.cmake b/Tests/RunCMake/try_run/RunCMakeTest.cmake index 698357b..dbea089 100644 --- a/Tests/RunCMake/try_run/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_run/RunCMakeTest.cmake @@ -1,8 +1,16 @@ include(RunCMake) -run_cmake(BadLinkLibraries) run_cmake(BinDirEmpty) run_cmake(BinDirRelative) +run_cmake(NoOutputVariable) + +set(RunCMake_TEST_OPTIONS -Dtry_compile_DEFS=old_signature.cmake) +include(${RunCMake_SOURCE_DIR}/old_and_new_signature_tests.cmake) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS -Dtry_compile_DEFS=new_signature.cmake) +include(${RunCMake_SOURCE_DIR}/old_and_new_signature_tests.cmake) +unset(RunCMake_TEST_OPTIONS) if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$" AND CMAKE_C_COMPILER_ID MATCHES "^(MSVC|GNU|LCC|Clang|AppleClang)$") @@ -10,12 +18,3 @@ if (CMAKE_SYSTEM_NAME MATCHES "^(Linux|Darwin|Windows)$" AND run_cmake(LinkOptions) unset (RunCMake_TEST_OPTIONS) endif() - -run_cmake(WorkingDirArg) - -run_cmake(NoOutputVariable) -run_cmake(NoCompileOutputVariable) -run_cmake(NoRunOutputVariable) -run_cmake(NoRunStdOutVariable) -run_cmake(NoRunStdErrVariable) -run_cmake(NoWorkingDirectory) diff --git a/Tests/RunCMake/try_run/WorkingDirArg.cmake b/Tests/RunCMake/try_run/WorkingDirArg.cmake index 62f78e8..375a703 100644 --- a/Tests/RunCMake/try_run/WorkingDirArg.cmake +++ b/Tests/RunCMake/try_run/WorkingDirArg.cmake @@ -1,5 +1,7 @@ -try_run(RUN_RESULT COMPILE_RESULT - ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp ${CMAKE_CURRENT_SOURCE_DIR}/src.c +include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS}) + +try_run(RUN_RESULT COMPILE_RESULT ${try_compile_bindir_or_SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/src.c RUN_OUTPUT_VARIABLE RUN_OUTPUT WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp/workdir ) diff --git a/Tests/RunCMake/try_run/new_signature.cmake b/Tests/RunCMake/try_run/new_signature.cmake new file mode 100644 index 0000000..cbcb261 --- /dev/null +++ b/Tests/RunCMake/try_run/new_signature.cmake @@ -0,0 +1,2 @@ +set(try_compile_bindir_or_SOURCES SOURCES) +set(try_compile_redundant_SOURCES "") diff --git a/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake b/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake new file mode 100644 index 0000000..2332127 --- /dev/null +++ b/Tests/RunCMake/try_run/old_and_new_signature_tests.cmake @@ -0,0 +1,11 @@ +run_cmake(BadLinkLibraries) +run_cmake(BinDirEmpty) +run_cmake(BinDirRelative) + +run_cmake(WorkingDirArg) + +run_cmake(NoCompileOutputVariable) +run_cmake(NoRunOutputVariable) +run_cmake(NoRunStdOutVariable) +run_cmake(NoRunStdErrVariable) +run_cmake(NoWorkingDirectory) diff --git a/Tests/RunCMake/try_run/old_signature.cmake b/Tests/RunCMake/try_run/old_signature.cmake new file mode 100644 index 0000000..94b12de --- /dev/null +++ b/Tests/RunCMake/try_run/old_signature.cmake @@ -0,0 +1,2 @@ +set(try_compile_bindir_or_SOURCES ${CMAKE_CURRENT_BINARY_DIR}) +set(try_compile_redundant_SOURCES SOURCES) |