Tests: Add dedicated RunCMake.ExtraGenerators test

The `Simple_${extraGenerator}` tests do not actually need to compile
because they only smoke test CMake's generation of the extra project
files.
This commit is contained in:
Brad King
2023-02-13 18:15:29 -05:00
parent 93edb4d0c0
commit 6cf281b108
5 changed files with 30 additions and 30 deletions
-30
View File
@@ -746,36 +746,6 @@ if(BUILD_TESTING)
ADD_LINK_FLAGS_TEST(mod_flags_config dll_flags_config)
ADD_LINK_FLAGS_TEST(exe_flags_config mod_flags_config)
# If we are running right now with a Unix Makefiles or Ninja based generator,
# 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|Ninja)$"
AND NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
foreach(
extraGenerator
IN ITEMS
"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
# not implemented in Xcode or Ninja
if(NOT CMAKE_GENERATOR MATCHES "Xcode|Ninja")
+4
View File
@@ -323,6 +323,10 @@ endif()
add_RunCMake_test(ExcludeFromAll)
add_RunCMake_test(ExportImport)
add_RunCMake_test(ExternalData)
if(CMAKE_GENERATOR MATCHES "^(Unix Makefiles|Ninja)$"
AND NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
add_RunCMake_test(ExtraGenerators)
endif()
add_RunCMake_test(FeatureSummary)
add_RunCMake_test(FPHSA)
if(CMAKE_USE_SYSTEM_JSONCPP)
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.5)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)
@@ -0,0 +1,19 @@
include(RunCMake)
foreach(
extraGenerator
IN ITEMS
"CodeBlocks"
"CodeLite"
"Eclipse CDT4"
"Kate"
"Sublime Text 2"
)
block()
set(RunCMake_GENERATOR "${extraGenerator} - ${RunCMake_GENERATOR}")
set(RunCMake_TEST_VARIANT_DESCRIPTION ": ${RunCMake_GENERATOR}")
string(REPLACE " " "" extraGeneratorNoSpaces "${extraGenerator}")
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Simple-${extraGeneratorNoSpaces})
run_cmake(Simple)
endblock()
endforeach()
@@ -0,0 +1,4 @@
enable_language(C)
enable_language(CXX)
add_subdirectory(../../Simple Simple)