From 56ae40cc59b74d7d4cf4c00cf35badec6aea2274 Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Wed, 14 Sep 2022 16:35:50 -0400 Subject: try_compile: Add PROJECT keyword-dispatched signature Introduce a new signature for the project flavor of try_compile (and try_run) which removes the `bindir` argument and adds a required PROJECT tag. This is similar to the SOURCES flavor added by commit aa9220d3 (try_compile: Add keyword-dispatched signature, 2022-09-02). --- Tests/RunCMake/try_compile/OldProjectBinDirEmpty-result.txt | 1 + Tests/RunCMake/try_compile/OldProjectBinDirEmpty-stderr.txt | 4 ++++ Tests/RunCMake/try_compile/OldProjectBinDirEmpty.cmake | 1 + Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-result.txt | 1 + Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-stderr.txt | 4 ++++ Tests/RunCMake/try_compile/OldProjectSrcDirEmpty.cmake | 1 + Tests/RunCMake/try_compile/ProjectBinDirEmpty-result.txt | 1 + Tests/RunCMake/try_compile/ProjectBinDirEmpty-stderr.txt | 4 ++++ Tests/RunCMake/try_compile/ProjectBinDirEmpty.cmake | 4 ++++ Tests/RunCMake/try_compile/ProjectCopyFile-result.txt | 1 + Tests/RunCMake/try_compile/ProjectCopyFile-stderr.txt | 7 +++++++ Tests/RunCMake/try_compile/ProjectCopyFile.cmake | 4 ++++ Tests/RunCMake/try_compile/ProjectSrcDirEmpty-result.txt | 1 + Tests/RunCMake/try_compile/ProjectSrcDirEmpty-stderr.txt | 4 ++++ Tests/RunCMake/try_compile/ProjectSrcDirEmpty.cmake | 1 + Tests/RunCMake/try_compile/ProjectSrcDirMissing-result.txt | 1 + Tests/RunCMake/try_compile/ProjectSrcDirMissing-stderr.txt | 4 ++++ Tests/RunCMake/try_compile/ProjectSrcDirMissing.cmake | 1 + Tests/RunCMake/try_compile/RunCMakeTest.cmake | 6 ++++++ Tests/TryCompile/CMakeLists.txt | 11 ++++++++++- 20 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/try_compile/OldProjectBinDirEmpty-result.txt create mode 100644 Tests/RunCMake/try_compile/OldProjectBinDirEmpty-stderr.txt create mode 100644 Tests/RunCMake/try_compile/OldProjectBinDirEmpty.cmake create mode 100644 Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-result.txt create mode 100644 Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-stderr.txt create mode 100644 Tests/RunCMake/try_compile/OldProjectSrcDirEmpty.cmake create mode 100644 Tests/RunCMake/try_compile/ProjectBinDirEmpty-result.txt create mode 100644 Tests/RunCMake/try_compile/ProjectBinDirEmpty-stderr.txt create mode 100644 Tests/RunCMake/try_compile/ProjectBinDirEmpty.cmake create mode 100644 Tests/RunCMake/try_compile/ProjectCopyFile-result.txt create mode 100644 Tests/RunCMake/try_compile/ProjectCopyFile-stderr.txt create mode 100644 Tests/RunCMake/try_compile/ProjectCopyFile.cmake create mode 100644 Tests/RunCMake/try_compile/ProjectSrcDirEmpty-result.txt create mode 100644 Tests/RunCMake/try_compile/ProjectSrcDirEmpty-stderr.txt create mode 100644 Tests/RunCMake/try_compile/ProjectSrcDirEmpty.cmake create mode 100644 Tests/RunCMake/try_compile/ProjectSrcDirMissing-result.txt create mode 100644 Tests/RunCMake/try_compile/ProjectSrcDirMissing-stderr.txt create mode 100644 Tests/RunCMake/try_compile/ProjectSrcDirMissing.cmake (limited to 'Tests') diff --git a/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-result.txt b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-stderr.txt b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-stderr.txt new file mode 100644 index 0000000000..e9ec4509ea --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at OldProjectBinDirEmpty.cmake:[0-9]+ \(try_compile\): + No specified. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/OldProjectBinDirEmpty.cmake b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty.cmake new file mode 100644 index 0000000000..fa922d9228 --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectBinDirEmpty.cmake @@ -0,0 +1 @@ +try_compile(RESULT "" ${CMAKE_CURRENT_SOURCE_DIR}/proj Foo) diff --git a/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-result.txt b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-stderr.txt b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-stderr.txt new file mode 100644 index 0000000000..47dd60f8df --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at OldProjectSrcDirEmpty.cmake:[0-9]+ \(try_compile\): + No specified. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty.cmake b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty.cmake new file mode 100644 index 0000000000..dfbfba6af3 --- /dev/null +++ b/Tests/RunCMake/try_compile/OldProjectSrcDirEmpty.cmake @@ -0,0 +1 @@ +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} "" Foo) diff --git a/Tests/RunCMake/try_compile/ProjectBinDirEmpty-result.txt b/Tests/RunCMake/try_compile/ProjectBinDirEmpty-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectBinDirEmpty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/ProjectBinDirEmpty-stderr.txt b/Tests/RunCMake/try_compile/ProjectBinDirEmpty-stderr.txt new file mode 100644 index 0000000000..57a2bd0d23 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectBinDirEmpty-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at ProjectBinDirEmpty.cmake:[0-9]+ \(try_compile\): + No specified. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/try_compile/ProjectBinDirEmpty.cmake b/Tests/RunCMake/try_compile/ProjectBinDirEmpty.cmake new file mode 100644 index 0000000000..e867cc693a --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectBinDirEmpty.cmake @@ -0,0 +1,4 @@ +try_compile(RESULT PROJECT Foo + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/proj + BINARY_DIR "" + ) diff --git a/Tests/RunCMake/try_compile/ProjectCopyFile-result.txt b/Tests/RunCMake/try_compile/ProjectCopyFile-result.txt new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectCopyFile-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/try_compile/ProjectCopyFile-stderr.txt b/Tests/RunCMake/try_compile/ProjectCopyFile-stderr.txt new file mode 100644 index 0000000000..45241c930e --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectCopyFile-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at ProjectCopyFile.cmake:[0-9]+ \(try_compile\): + Unknown arguments: + + "COPY_FILE" + "result" +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/ProjectCopyFile.cmake b/Tests/RunCMake/try_compile/ProjectCopyFile.cmake new file mode 100644 index 0000000000..6bfec994fa --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectCopyFile.cmake @@ -0,0 +1,4 @@ +try_compile(RESULT + PROJECT TestProject + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/proj + COPY_FILE result) diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-result.txt b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-stderr.txt b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-stderr.txt new file mode 100644 index 0000000000..dc6f3543d4 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at ProjectSrcDirEmpty.cmake:[0-9]+ \(try_compile\): + No specified. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirEmpty.cmake b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty.cmake new file mode 100644 index 0000000000..ac33ed0df1 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirEmpty.cmake @@ -0,0 +1 @@ +try_compile(RESULT PROJECT Foo SOURCE_DIR "") diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirMissing-result.txt b/Tests/RunCMake/try_compile/ProjectSrcDirMissing-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirMissing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirMissing-stderr.txt b/Tests/RunCMake/try_compile/ProjectSrcDirMissing-stderr.txt new file mode 100644 index 0000000000..af6edd5287 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirMissing-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at ProjectSrcDirMissing.cmake:[0-9]+ \(try_compile\): + No specified. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/ProjectSrcDirMissing.cmake b/Tests/RunCMake/try_compile/ProjectSrcDirMissing.cmake new file mode 100644 index 0000000000..e32cdf4a37 --- /dev/null +++ b/Tests/RunCMake/try_compile/ProjectSrcDirMissing.cmake @@ -0,0 +1 @@ +try_compile(RESULT PROJECT Foo) diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index c0fdd9fd19..bb11a5798c 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -6,6 +6,11 @@ run_cmake(TwoArgs) run_cmake(NoSources) run_cmake(BinDirEmpty) run_cmake(BinDirRelative) +run_cmake(ProjectSrcDirMissing) +run_cmake(ProjectSrcDirEmpty) +run_cmake(ProjectBinDirEmpty) +run_cmake(OldProjectSrcDirEmpty) +run_cmake(OldProjectBinDirEmpty) set(RunCMake_TEST_OPTIONS -Dtry_compile_DEFS=old_signature.cmake) include(${RunCMake_SOURCE_DIR}/old_and_new_signature_tests.cmake) @@ -15,6 +20,7 @@ set(RunCMake_TEST_OPTIONS -Dtry_compile_DEFS=new_signature.cmake) include(${RunCMake_SOURCE_DIR}/old_and_new_signature_tests.cmake) unset(RunCMake_TEST_OPTIONS) +run_cmake(ProjectCopyFile) run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index a53dd939e1..8ebb00a3cf 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -65,7 +65,7 @@ set(try_compile_run_output_var RUN_OUTPUT) include(old_and_new_signature_tests.cmake) # try to compile a project (old signature) -message("Testing try_compile project mode") +message("Testing try_compile project mode (old signature)") try_compile(TEST_INNER ${TryCompile_BINARY_DIR}/CMakeFiles/Inner ${TryCompile_SOURCE_DIR}/Inner @@ -73,6 +73,15 @@ try_compile(TEST_INNER OUTPUT_VARIABLE output) TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}") +# try to compile a project (new signature) +message("Testing try_compile project mode (new signature)") +try_compile(TEST_INNER + PROJECT TryCompileInner + SOURCE_DIR ${TryCompile_SOURCE_DIR}/Inner + TARGET innerexe + OUTPUT_VARIABLE output) +TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}") + add_executable(TryCompile pass.c) ####################################################################### -- cgit v1.2.1