diff options
author | Brad King <brad.king@kitware.com> | 2020-06-17 10:56:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-06-18 13:29:41 (GMT) |
commit | ab6e1e49c0ad2395cb1f5befb9e8908256b3910c (patch) | |
tree | 1b38840f1234e407b596288d2c2610b1bbfecd27 /Tests/CMakeLists.txt | |
parent | 882483192d64866a1da0c5f44f8ac9b8a327f31f (diff) | |
download | CMake-ab6e1e49c0ad2395cb1f5befb9e8908256b3910c.zip CMake-ab6e1e49c0ad2395cb1f5befb9e8908256b3910c.tar.gz CMake-ab6e1e49c0ad2395cb1f5befb9e8908256b3910c.tar.bz2 |
Tests: Simplify addition of extra generator tests
Do not try to run the `cmake` binary that has not been built yet.
Always add the extra generator tests in combination with the
corresponding Makefile and Ninja generators.
Diffstat (limited to 'Tests/CMakeLists.txt')
-rw-r--r-- | Tests/CMakeLists.txt | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index b771ff5..4fb905e 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -698,38 +698,28 @@ if(BUILD_TESTING) # build the "Simple" test with the ExtraGenerators, if available # This doesn't test whether the generated project files work (unfortunately), # mainly it tests that cmake doesn't crash when generating these project files. - if(${CMAKE_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_GENERATOR} MATCHES "Ninja") - - # check which generators we have - execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help - OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput) - - set(extraGenerators - "CodeBlocks" - "CodeLite" - "Eclipse CDT4" - "Kate" - "Sublime Text 2") - - foreach(extraGenerator ${extraGenerators}) - if ("${cmakeOutput}" MATCHES "${extraGenerator} - ${CMAKE_GENERATOR}") - set(extraGeneratorTestName "Simple_${extraGenerator}Generator") - string(REPLACE " " "" extraGeneratorTestName ${extraGeneratorTestName}) - - add_test(${extraGeneratorTestName} ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/Simple" - "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}" - --build-two-config - --build-generator "${extraGenerator} - ${CMAKE_GENERATOR}" - --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}" - --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" - --build-project Simple - --test-command Simple) - list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}") - endif () - endforeach(extraGenerator) - + if(CMAKE_GENERATOR MATCHES "^(Unix Makefiles|Ninja)$" + AND NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + foreach(extraGenerator + "CodeBlocks" + "CodeLite" + "Eclipse CDT4" + "Kate" + "Sublime Text 2" + ) + string(REPLACE " " "" extraGeneratorTestName "Simple_${extraGenerator}Generator") + add_test(${extraGeneratorTestName} ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Simple" + "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}" + --build-two-config + --build-generator "${extraGenerator} - ${CMAKE_GENERATOR}" + --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}" + --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" + --build-project Simple + --test-command Simple) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${extraGeneratorTestName}") + endforeach() endif() # test for correct sub-project generation |