Browse Source

Merge topic 'try_compile-clean-up-tests'

299cd3e6ab try_compile: Clean up tests

Acked-by: Kitware Robot <[email protected]>
Merge-request: !7591
Brad King 3 years ago
parent
commit
d69d0316da
1 changed files with 10 additions and 36 deletions
  1. 10 36
      Tests/TryCompile/CMakeLists.txt

+ 10 - 36
Tests/TryCompile/CMakeLists.txt

@@ -29,6 +29,15 @@ macro(TEST_EXPECT_CONTAINS command expected)
 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
@@ -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