diff options
Diffstat (limited to 'Tests')
39 files changed, 227 insertions, 10 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index b742dad..b660442 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -245,7 +245,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(CompileOptions CompileOptions) ADD_TEST_MACRO(CompatibleInterface CompatibleInterface) set_tests_properties(EmptyLibrary PROPERTIES - PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target:test") + PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test") ADD_TEST_MACRO(CrossCompile CrossCompile) set_tests_properties(CrossCompile PROPERTIES PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode") @@ -1640,7 +1640,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ FAIL_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:5 \\(set\\):") list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset") - if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile") + if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile" AND NOT WIN32) # Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails # this test. (See #13371) # Apparently Visual Studio does not support it either. As the MakeClean diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake new file mode 100644 index 0000000..1655eb4 --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake @@ -0,0 +1 @@ +cmake_host_system_information(HOSTNAME) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake new file mode 100644 index 0000000..1f056d5 --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT FQDN HOSTNAME) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake new file mode 100644 index 0000000..9c5a558 --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT RESULT QUERY FOOBAR) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake new file mode 100644 index 0000000..1c3156d --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake @@ -0,0 +1,5 @@ +cmake_host_system_information(RESULT RESULT + QUERY NUMBER_OF_LOGICAL_CORES NUMBER_OF_PHYSICAL_CORES +) + +message("[${RESULT}]") diff --git a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in new file mode 100644 index 0000000..3294a2f --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in @@ -0,0 +1,33 @@ +set(BadArg1-RESULT 1) +set(BadArg1-STDERR "missing RESULT specification") +set(BadArg2-RESULT 1) +set(BadArg2-STDERR "missing QUERY specification") +set(BadArg3-RESULT 1) +set(BadArg3-STDERR "does not recognize <key> FOOBAR") +set(QueryList-RESULT 0) +set(QueryList-STDERR "\\[[0-9]+;[0-9]+\\]") + +function(try_and_print key) + cmake_host_system_information(RESULT RESULT QUERY ${key}) + message(STATUS "[${key}] [${RESULT}]") +endfunction() + +message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +try_and_print(NUMBER_OF_LOGICAL_CORES) +try_and_print(NUMBER_OF_PHYSICAL_CORES) +try_and_print(HOSTNAME) +try_and_print(FQDN) +try_and_print(TOTAL_VIRTUAL_MEMORY) +try_and_print(AVAILABLE_VIRTUAL_MEMORY) +try_and_print(TOTAL_PHYSICAL_MEMORY) +try_and_print(AVAILABLE_PHYSICAL_MEMORY) + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") + +check_cmake_test(CMakeHostSystemInformation + BadArg1 + BadArg2 + BadArg3 + QueryList +) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index b049995..344b772 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -32,6 +32,7 @@ AddCMakeTest(CompilerIdVendor "") AddCMakeTest(ProcessorCount "-DKWSYS_TEST_EXE=$<TARGET_FILE:cmsysTestsCxx>") AddCMakeTest(PushCheckState "") AddCMakeTest(While "") +AddCMakeTest(CMakeHostSystemInformation "") AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt index 6d8a96a..9b6c9c2 100644 --- a/Tests/CompileOptions/CMakeLists.txt +++ b/Tests/CompileOptions/CMakeLists.txt @@ -5,7 +5,23 @@ project(CompileOptions) add_library(testlib other.cpp) add_executable(CompileOptions main.cpp) -set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE>") + +macro(get_compiler_test_genex lst lang) + list(APPEND ${lst} -DTEST_${lang}_COMPILER_VERSION="$<${lang}_COMPILER_VERSION>") + list(APPEND ${lst} -DTEST_${lang}_COMPILER_VERSION_EQUALITY=$<${lang}_COMPILER_VERSION:${CMAKE_${lang}_COMPILER_VERSION}>) +endmacro() + +get_compiler_test_genex(c_tests C) +get_compiler_test_genex(cxx_tests CXX) + +set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS + "-DTEST_DEFINE" + "-DNEEDS_ESCAPE=\"E$CAPE\"" + "$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE_GNU>" + ${c_tests} + ${cxx_tests} + ) + target_link_libraries(CompileOptions testlib) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -14,3 +30,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") "DO_GNU_TESTS" ) endif() + +target_compile_definitions(CompileOptions + PRIVATE + "EXPECTED_C_COMPILER_VERSION=\"${CMAKE_C_COMPILER_VERSION}\"" + "EXPECTED_CXX_COMPILER_VERSION=\"${CMAKE_CXX_COMPILER_VERSION}\"" +) diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp index 0d39050..42f4cca 100644 --- a/Tests/CompileOptions/main.cpp +++ b/Tests/CompileOptions/main.cpp @@ -1,11 +1,24 @@ +#ifndef TEST_DEFINE +# error Expected definition TEST_DEFINE +#endif + +#ifndef NEEDS_ESCAPE +# error Expected definition NEEDS_ESCAPE +#endif #ifdef DO_GNU_TESTS -# ifndef TEST_DEFINE -# error Expected TEST_DEFINE -# endif +# ifndef TEST_DEFINE_GNU +# error Expected definition TEST_DEFINE_GNU +# endif #endif -int main(int argc, char **argv) +#include <string.h> + +int main() { - return 0; + return (strcmp(NEEDS_ESCAPE, "E$CAPE") == 0 + && strcmp(EXPECTED_C_COMPILER_VERSION, TEST_C_COMPILER_VERSION) == 0 + && strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) == 0 + && TEST_C_COMPILER_VERSION_EQUALITY == 1 + && TEST_CXX_COMPILER_VERSION_EQUALITY == 1) ? 0 : 1; } diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index d3ced3f..30daa7d 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -123,6 +123,19 @@ add_custom_command( COMMENT "Running TDocument post-build commands" ) +# Setup a custom target that will fail if the POST_BUILD custom command +# isn't run before it. +add_custom_command( + OUTPUT doc3post.txt + DEPENDS ${PROJECT_BINARY_DIR}/doc2post.txt + COMMAND ${CMAKE_COMMAND} -E echo " Copying doc2pre.txt to doc3post.txt." + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc2post.txt + ${PROJECT_BINARY_DIR}/doc3post.txt + COMMENT "Running TDocument post-build dependent custom command" + ) +add_custom_target(doc3Post ALL DEPENDS doc3post.txt) +add_dependencies(doc3Post TDocument) + ################################################################ # # Test using a multistep generated file diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index e3f23b8..efecd03 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -162,7 +162,6 @@ set_property(TARGET testLibRequired APPEND PROPERTY $<BUILD_INTERFACE:BuildOnly_DEFINE> $<INSTALL_INTERFACE:InstallOnly_DEFINE> ) - include(GenerateExportHeader) add_subdirectory(renamed) @@ -201,6 +200,11 @@ set_property(TARGET testSharedLibRequired PROPERTY INTERFACE_CUSTOM_STRING testcontent ) +set_property(TARGET testSharedLibRequired APPEND PROPERTY + INTERFACE_COMPILE_OPTIONS + $<$<CXX_COMPILER_ID:GNU>:-DCUSTOM_COMPILE_OPTION> +) + add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp) set_property(TARGET testSharedLibDepends APPEND PROPERTY diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 65b1a36..3bfbc46 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -169,6 +169,13 @@ target_compile_definitions(deps_shared_iface $<$<STREQUAL:$<TARGET_PROPERTY:CUSTOM_STRING>,testcontent>:CUSTOM_STRING_IS_MATCH> ) +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_compile_definitions(deps_shared_iface + PRIVATE + "DO_GNU_TESTS" + ) +endif() + if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-fPIE run_pic_test) @@ -199,6 +206,12 @@ endif() add_executable(deps_shared_iface2 deps_shared_iface.cpp) target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends bld_subdirlib) +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_compile_definitions(deps_shared_iface2 + PRIVATE + "DO_GNU_TESTS" + ) +endif() target_compile_definitions(deps_shared_iface2 PRIVATE TEST_SUBDIR_LIB $<$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>:PIC_PROPERTY_IS_ON> diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index 32e04db..d5e4de3 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -25,6 +25,12 @@ #include "renamed.h" #endif +#ifdef DO_GNU_TESTS +#ifndef CUSTOM_COMPILE_OPTION +#error Expected CUSTOM_COMPILE_OPTION +#endif +#endif + int main(int,char **) { TestSharedLibDepends dep; diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-result.txt b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt new file mode 100644 index 0000000..8e0591d --- /dev/null +++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex-stderr.txt @@ -0,0 +1,6 @@ +CMake Error: + Error evaluating generator expression: + + \$<LINK_LANGUAGE> + + \$<LINK_LANGUAGE> expression can not be used while evaluating link libraries diff --git a/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake new file mode 100644 index 0000000..e0f8c57 --- /dev/null +++ b/Tests/RunCMake/Languages/LINK_LANGUAGE-genex.cmake @@ -0,0 +1,4 @@ + +add_library(foo SHARED empty.cpp) +add_library(bar SHARED empty.cpp) +target_link_libraries(foo $<$<STREQUAL:$<LINK_LANGUAGE>,anything>:bar>) diff --git a/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt b/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt index 3f93cf8..983129a 100644 --- a/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt +++ b/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt @@ -1 +1 @@ -CMake Error: CMake can not determine linker language for target:NoLang +CMake Error: CMake can not determine linker language for target: NoLang diff --git a/Tests/RunCMake/Languages/RunCMakeTest.cmake b/Tests/RunCMake/Languages/RunCMakeTest.cmake index a99548f..6517a81 100644 --- a/Tests/RunCMake/Languages/RunCMakeTest.cmake +++ b/Tests/RunCMake/Languages/RunCMakeTest.cmake @@ -1,3 +1,6 @@ include(RunCMake) run_cmake(NoLangSHARED) +run_cmake(LINK_LANGUAGE-genex) +run_cmake(link-libraries-TARGET_FILE-genex) +run_cmake(link-libraries-TARGET_FILE-genex-ok) diff --git a/Tests/RunCMake/Languages/empty.cpp b/Tests/RunCMake/Languages/empty.cpp new file mode 100644 index 0000000..7279c5e --- /dev/null +++ b/Tests/RunCMake/Languages/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty(void) +{ + return 0; +} diff --git a/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-ok-result.txt b/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-ok-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-ok-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-ok.cmake b/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-ok.cmake new file mode 100644 index 0000000..f0fd6e5 --- /dev/null +++ b/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-ok.cmake @@ -0,0 +1,6 @@ + +enable_language(CXX) + +add_library(foo SHARED empty.cpp) +add_library(bar SHARED empty.cpp) +target_link_libraries(foo $<$<STREQUAL:$<TARGET_FILE:bar>,anything>:bar>) diff --git a/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-result.txt b/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-stderr.txt b/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-stderr.txt new file mode 100644 index 0000000..2d7a3c9 --- /dev/null +++ b/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex-stderr.txt @@ -0,0 +1,7 @@ +CMake Error: + Error evaluating generator expression: + + \$<TARGET_FILE:foo> + + Expressions which require the linker language may not be used while + evaluating link libraries diff --git a/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex.cmake b/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex.cmake new file mode 100644 index 0000000..eca73e9 --- /dev/null +++ b/Tests/RunCMake/Languages/link-libraries-TARGET_FILE-genex.cmake @@ -0,0 +1,4 @@ + +add_library(foo SHARED empty.cpp) +add_library(bar SHARED empty.cpp) +target_link_libraries(foo $<$<STREQUAL:$<TARGET_FILE:foo>,anything>:bar>) diff --git a/Tests/RunCMake/try_compile/BadSources1-result.txt b/Tests/RunCMake/try_compile/BadSources1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/BadSources1-stderr.txt b/Tests/RunCMake/try_compile/BadSources1-stderr.txt new file mode 100644 index 0000000..864a294 --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources1-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at BadSources1.cmake:1 \(try_compile\): + Unknown extension ".c" for file + + .*/Tests/RunCMake/try_compile/src.c + + try_compile\(\) works only for enabled languages. Currently these are: + + NONE + + See project\(\) command to enable other languages. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/BadSources1.cmake b/Tests/RunCMake/try_compile/BadSources1.cmake new file mode 100644 index 0000000..aa4dc5e --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources1.cmake @@ -0,0 +1 @@ +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c) diff --git a/Tests/RunCMake/try_compile/BadSources2-result.txt b/Tests/RunCMake/try_compile/BadSources2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/BadSources2-stderr.txt b/Tests/RunCMake/try_compile/BadSources2-stderr.txt new file mode 100644 index 0000000..3313f99 --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources2-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at BadSources2.cmake:2 \(try_compile\): + Unknown extension ".cxx" for file + + .*/Tests/RunCMake/try_compile/src.cxx + + try_compile\(\) works only for enabled languages. Currently these are: + + C NONE( RC)? + + See project\(\) command to enable other languages. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/BadSources2.cmake b/Tests/RunCMake/try_compile/BadSources2.cmake new file mode 100644 index 0000000..ed2b036 --- /dev/null +++ b/Tests/RunCMake/try_compile/BadSources2.cmake @@ -0,0 +1,5 @@ +enable_language(C) +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src.c + ${CMAKE_CURRENT_SOURCE_DIR}/src.cxx + ) diff --git a/Tests/RunCMake/try_compile/NoSources-result.txt b/Tests/RunCMake/try_compile/NoSources-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/NoSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/NoSources-stderr.txt b/Tests/RunCMake/try_compile/NoSources-stderr.txt new file mode 100644 index 0000000..023032b --- /dev/null +++ b/Tests/RunCMake/try_compile/NoSources-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at NoSources.cmake:1 \(try_compile\): + SOURCES must be followed by at least one source file +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/NoSources.cmake b/Tests/RunCMake/try_compile/NoSources.cmake new file mode 100644 index 0000000..8a73af4 --- /dev/null +++ b/Tests/RunCMake/try_compile/NoSources.cmake @@ -0,0 +1 @@ +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} SOURCES) diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 31643cf..3494695 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -7,6 +7,9 @@ run_cmake(NoCopyFile) run_cmake(NoCopyFile2) run_cmake(NoOutputVariable) run_cmake(NoOutputVariable2) +run_cmake(NoSources) run_cmake(BadLinkLibraries) +run_cmake(BadSources1) +run_cmake(BadSources2) run_cmake(NonSourceCopyFile) run_cmake(NonSourceCompileDefinitions) diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index b6b66d8..4540fd0 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -71,6 +71,24 @@ 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}${CMAKE_FILES_DIRECTORY}/CMakeTmp + SOURCES ${TryCompile_SOURCE_DIR}/pass2a.c ${TryCompile_SOURCE_DIR}/pass2b.cxx + OUTPUT_VARIABLE TRY_OUT) +if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") +endif() + +# try to compile two files that should not compile +try_compile(SHOULD_FAIL + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + SOURCES ${TryCompile_SOURCE_DIR}/fail2a.c ${TryCompile_SOURCE_DIR}/fail2b.c + OUTPUT_VARIABLE TRY_OUT) +if(SHOULD_FAIL) + message(SEND_ERROR "Should fail passed ${TRY_OUT}") +endif() + if(NOT SHOULD_FAIL) if(SHOULD_PASS) message("All Tests passed, ignore all previous output.") diff --git a/Tests/TryCompile/fail2a.c b/Tests/TryCompile/fail2a.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/TryCompile/fail2a.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/Tests/TryCompile/fail2b.c b/Tests/TryCompile/fail2b.c new file mode 100644 index 0000000..5ee809c --- /dev/null +++ b/Tests/TryCompile/fail2b.c @@ -0,0 +1 @@ +does_not_compile diff --git a/Tests/TryCompile/pass2a.c b/Tests/TryCompile/pass2a.c new file mode 100644 index 0000000..bbfe6d5 --- /dev/null +++ b/Tests/TryCompile/pass2a.c @@ -0,0 +1,2 @@ +extern int pass2b(void); +int main() { return pass2b(); } diff --git a/Tests/TryCompile/pass2b.cxx b/Tests/TryCompile/pass2b.cxx new file mode 100644 index 0000000..4c539e2 --- /dev/null +++ b/Tests/TryCompile/pass2b.cxx @@ -0,0 +1 @@ +extern "C" int pass2b(void) { return 0; } |