From 299cd3e6ab2fd1dded4953a286e665a9c51c1e0a Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Thu, 18 Aug 2022 11:27:27 -0400 Subject: try_compile: Clean up tests Switch order of one try_compile test so that the total set of tests is in a more sensible order. Remove two duplicate tests. Remove some gratuitous (and not entirely accurate) messages. --- Tests/TryCompile/CMakeLists.txt | 46 +++++++++-------------------------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 7c6f970..dccc227 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -30,6 +30,15 @@ endmacro() # try to compile a file that should compile +try_compile(SHOULD_PASS + ${TryCompile_BINARY_DIR} + ${TryCompile_SOURCE_DIR}/pass.c + OUTPUT_VARIABLE TRY_OUT) +if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") +endif() + +# try to compile a file that should compile # also check that COPY_FILE works try_compile(SHOULD_PASS ${TryCompile_BINARY_DIR} @@ -73,24 +82,6 @@ if(SHOULD_FAIL) message(SEND_ERROR "Should fail passed ${TRY_OUT}") endif() -# try to compile a file that should compile -try_compile(SHOULD_PASS - ${TryCompile_BINARY_DIR} - ${TryCompile_SOURCE_DIR}/pass.c - OUTPUT_VARIABLE TRY_OUT) -if(NOT SHOULD_PASS) - message(SEND_ERROR "should pass failed ${TRY_OUT}") -endif() - -# try to compile a file that should not compile -try_compile(SHOULD_FAIL - ${TryCompile_BINARY_DIR} - ${TryCompile_SOURCE_DIR}/fail.c - OUTPUT_VARIABLE TRY_OUT) -if(SHOULD_FAIL) - message(SEND_ERROR "Should fail passed ${TRY_OUT}") -endif() - # try to compile two files that should compile try_compile(SHOULD_PASS ${TryCompile_BINARY_DIR} @@ -125,24 +116,6 @@ if(NOT SHOULD_PASS) endif() set(CMAKE_C_FLAGS "${_c_flags}") -if(NOT SHOULD_FAIL) - if(SHOULD_PASS) - message("All Tests passed, ignore all previous output.") - else() - message("Test failed") - endif() -else() - message("Test failed") -endif() -try_compile(CMAKE_ANSI_FOR_SCOPE - ${TryCompile_BINARY_DIR} - ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT) -if (CMAKE_ANSI_FOR_SCOPE) - message("Compiler supports ansi for") -else() - message("Compiler does not support ansi for scope") -endif() - try_compile(CMAKE_ANSI_FOR_SCOPE ${TryCompile_BINARY_DIR} ${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT) @@ -160,6 +133,7 @@ else() message("Compiler does not support ansi for scope") endif() +# try to compile a project message("Testing try_compile project mode") try_compile(TEST_INNER ${TryCompile_BINARY_DIR}/CMakeFiles/Inner -- cgit v0.12