diff options
author | Craig Scott <craig.scott@crascit.com> | 2017-12-29 22:17:32 +1100 |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2017-12-30 09:35:56 +1100 |
commit | c267ea1c3e54626e4ab2283dc7529ed8aa8beac8 (patch) | |
tree | e361a5bcdec7006768e3a4a79109c19efa34c9ee | |
parent | 497f4bb941a84bacfca2392759de6cb8e23b0684 (diff) | |
download | cmake-c267ea1c3e54626e4ab2283dc7529ed8aa8beac8.tar.gz |
GENERATOR_IS_MULTI_CONFIG: Use for multi-config checks in Tests
39 files changed, 134 insertions, 76 deletions
diff --git a/Tests/CMakeBuildTest.cmake.in b/Tests/CMakeBuildTest.cmake.in index 71bcb183e4..b4b12863d4 100644 --- a/Tests/CMakeBuildTest.cmake.in +++ b/Tests/CMakeBuildTest.cmake.in @@ -29,11 +29,10 @@ if(RESULT) message(FATAL_ERROR "Error running cmake --build") endif() -# check for configuration types -set(CMAKE_CONFIGURATION_TYPES @CMAKE_CONFIGURATION_TYPES@) -# run the executable out of the Debug directory if there -# are configuration types -if(CMAKE_CONFIGURATION_TYPES) +# run the executable out of the Debug directory if using a +# multi-config generator +set(_isMultiConfig @_isMultiConfig@) +if(_isMultiConfig) set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/@CMAKE_BUILD_TEST_EXE@") else() set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/@CMAKE_BUILD_TEST_EXE@") diff --git a/Tests/CMakeInstall.cmake b/Tests/CMakeInstall.cmake index fda8c54b33..d9d85f71b8 100644 --- a/Tests/CMakeInstall.cmake +++ b/Tests/CMakeInstall.cmake @@ -14,7 +14,18 @@ if(CMake_TEST_INSTALL) set(CMake_TEST_INSTALL_PREFIX ${CMake_BINARY_DIR}/Tests/CMakeInstall) set(CMAKE_INSTALL_PREFIX "${CMake_TEST_INSTALL_PREFIX}") - if(CMAKE_CONFIGURATION_TYPES) + # 3.9 or later provides a definitive answer to whether we are multi-config + # through a global property. Prior to 3.9, CMAKE_CONFIGURATION_TYPES being set + # is assumed to mean multi-config, but developers might modify it so it is + # technically not as reliable. + if(NOT CMAKE_VERSION VERSION_LESS 3.9) + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + elseif(CMAKE_CONFIGURATION_TYPES) + set(_isMultiConfig True) + else() + set(_isMultiConfig False) + endif() + if(_isMultiConfig) # There are multiple configurations. Make sure the tested # configuration is the one that is installed. set(CMake_TEST_INSTALL_CONFIG --config $<CONFIGURATION>) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5d8c2fe3a1..fb7313f936 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -38,9 +38,21 @@ set(ENV{HOME} \"${TEST_HOME}\") ") endif() +# 3.9 or later provides a definitive answer to whether we are multi-config +# through a global property. Prior to 3.9, CMAKE_CONFIGURATION_TYPES being set +# is assumed to mean multi-config, but developers might modify it so it is +# technically not as reliable. +if(NOT CMAKE_VERSION VERSION_LESS 3.9) + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +elseif(CMAKE_CONFIGURATION_TYPES) + set(_isMultiConfig True) +else() + set(_isMultiConfig False) +endif() + # Choose a default configuration for CTest tests. set(CTestTest_CONFIG Debug) -if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE) +if(NOT _isMultiConfig AND CMAKE_BUILD_TYPE) set(CTestTest_CONFIG ${CMAKE_BUILD_TYPE}) endif() @@ -3190,7 +3202,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result ) if(_result EQUAL 0) - if(CMAKE_CONFIGURATION_TYPES) + if(_isMultiConfig) set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>) else() set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) diff --git a/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt b/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt index 6d1628ae51..3676b17922 100644 --- a/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt +++ b/Tests/CMakeOnly/SelectLibraryConfigurations/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(SelectLibraryConfigurations NONE) @@ -15,7 +15,8 @@ macro(check_slc basename expect) endif () endmacro(check_slc) -if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if (NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE) set(NOTYPE_RELONLY_LIBRARY_RELEASE "opt") check_slc(NOTYPE_RELONLY "opt") diff --git a/Tests/CTestConfig/CMakeLists.txt b/Tests/CTestConfig/CMakeLists.txt index f46d89a55d..8c19adbe29 100644 --- a/Tests/CTestConfig/CMakeLists.txt +++ b/Tests/CTestConfig/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(CTestConfig) include(CTest) @@ -8,32 +8,41 @@ include(CTest) # 'ctest -S script.cmake' call. # # In either case, we expect CMAKE_BUILD_TYPE to be defined for single-configuration -# build trees and not defined for multi-configuration build trees. +# build trees and not defined for multi-configuration build trees. The value of +# CMAKE_CONFIGURATION_TYPES should not be relied upon to determine whether we +# are using a multi-config generator or not, the GENERATOR_IS_MULTI_CONFIG +# global property is the canonical way to do that as of CMake 3.9. # -if(CMAKE_CONFIGURATION_TYPES) - # multi-configuration: expect not defined, error if defined +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) + if(NOT DEFINED CMAKE_CONFIGURATION_TYPES OR CMAKE_CONFIGURATION_TYPES STREQUAL "") + message(FATAL_ERROR "CMAKE_CONFIGURATION_TYPES is not defined or is empty " + "(but must be defined and non-empty for a multi-configuration generator)") + endif() if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") - message(FATAL_ERROR "CMAKE_CONFIGURATION_TYPES='${CMAKE_CONFIGURATION_TYPES}' CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' is defined and non-empty (but should not be for a multi-configuration generator)") + message(FATAL_ERROR "CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' is defined and non-empty " + "(but should not be for a multi-configuration generator)") endif() + set(_configs ${CMAKE_CONFIGURATION_TYPES}) else() - # single-configuration: expect defined, error if not defined + # Populating CMAKE_CONFIGURATION_TYPES even for single config generators is + # common enough for user projects that we don't want to consider it an error. + # We just need CMAKE_BUILD_TYPE to be set and ignore CMAKE_CONFIGURATION_TYPES. if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") - message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined or is empty (but should be defined and non-empty for a single-configuration generator)") + message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined or is empty " + "(but should be defined and non-empty for a single-configuration generator)") endif() -endif() - - -if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "") add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}") + set(_configs ${CMAKE_BUILD_TYPE}) endif() add_executable(ctc CTestConfig.cxx) -foreach(cfg ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE}) +foreach(cfg ${_configs}) add_test(NAME ctc-${cfg} CONFIGURATIONS ${cfg} COMMAND ctc --config $<CONFIGURATION>) - if(CMAKE_CONFIGURATION_TYPES) + if(_isMultiConfig) set_property(TEST ctc-${cfg} PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_INTDIR is ${cfg}") set_property(TEST ctc-${cfg} diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in index 143fe717ab..4bb1262c0e 100644 --- a/Tests/CTestConfig/dashboard.cmake.in +++ b/Tests/CTestConfig/dashboard.cmake.in @@ -1,4 +1,4 @@ -set(CMAKE_CONFIGURATION_TYPES "@CMAKE_CONFIGURATION_TYPES@") +set(_isMultiConfig "@_isMultiConfig@") set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig") set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-dashboard") @@ -11,7 +11,7 @@ message("CMAKE_COMMAND='${CMAKE_COMMAND}'") message("CMAKE_CTEST_COMMAND='${CMAKE_CTEST_COMMAND}'") set(arg "") -if(NOT CMAKE_CONFIGURATION_TYPES) +if(NOT _isMultiConfig) set(arg "-DCMAKE_BUILD_TYPE:STRING=@cfg@") endif() diff --git a/Tests/CustomCommandByproducts/CMakeLists.txt b/Tests/CustomCommandByproducts/CMakeLists.txt index 3289e8f9f7..d0bf6487ea 100644 --- a/Tests/CustomCommandByproducts/CMakeLists.txt +++ b/Tests/CustomCommandByproducts/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.9) +cmake_policy(SET CMP0058 OLD) project(CustomCommandByproducts C) # Generate a byproduct in a rule that runs in the target consuming it. @@ -81,7 +82,8 @@ add_custom_command(OUTPUT timestamp8.txt # Generate the library file of an imported target as a byproduct # of an external project. -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(cfg /${CMAKE_CFG_INTDIR}) else() set(cfg) @@ -105,7 +107,7 @@ add_dependencies(ExternalLibrary ExternalTarget) # Generate the library file of an imported target as a byproduct # of an external project. The byproduct uses <BINARY_DIR> that is substituted # by the real binary path -if(CMAKE_CONFIGURATION_TYPES) +if(_isMultiConfig) set(cfg /${CMAKE_CFG_INTDIR}) else() set(cfg) diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index eaad3d46c1..dc621eb274 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.7.20090711) +cmake_minimum_required (VERSION 3.9) project(ExportImport C CXX) if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") @@ -15,7 +15,8 @@ set_property( PROPERTY SYMBOLIC 1 ) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") else() if(CMAKE_BUILD_TYPE) diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt index 3996600023..d056b43798 100644 --- a/Tests/FortranModules/CMakeLists.txt +++ b/Tests/FortranModules/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.1) +cmake_minimum_required (VERSION 3.9) project(FortranModules Fortran) if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") @@ -56,7 +56,8 @@ add_executable(test_non_pp_include test_non_pp_include_main.f90) # Build the external project separately using a custom target. # Make sure it uses the same build configuration as this test. -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(External_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") set(External_BUILD_TYPE) else() diff --git a/Tests/JavaExportImport/CMakeLists.txt b/Tests/JavaExportImport/CMakeLists.txt index a075301f96..c70704a045 100644 --- a/Tests/JavaExportImport/CMakeLists.txt +++ b/Tests/JavaExportImport/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.9) project(JavaExportImport) if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") @@ -17,7 +17,8 @@ set_property( PROPERTY SYMBOLIC 1 ) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") else() if(CMAKE_BUILD_TYPE) diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt index 3e9ab8a558..a3c6fd9a9c 100644 --- a/Tests/MacRuntimePath/CMakeLists.txt +++ b/Tests/MacRuntimePath/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 3.9) project(MacRuntimePath) if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") @@ -18,7 +18,8 @@ set_property( configure_file(${MacRuntimePath_SOURCE_DIR}/InitialCache.cmake.in ${MacRuntimePath_BINARY_DIR}/InitialCache.cmake @ONLY) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") else() if(CMAKE_BUILD_TYPE) diff --git a/Tests/MissingInstall/CMakeLists.txt b/Tests/MissingInstall/CMakeLists.txt index 91624f710b..365b31f62a 100644 --- a/Tests/MissingInstall/CMakeLists.txt +++ b/Tests/MissingInstall/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.12) +cmake_minimum_required (VERSION 3.9) project(TestMissingInstall) set(CMAKE_SKIP_INSTALL_RULES ON) @@ -8,11 +8,7 @@ set(CMAKE_SKIP_INSTALL_RULES ON) set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1) set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1) -if(CMAKE_CONFIGURATION_TYPES) - set(MULTI_CONFIG ON) -else() - set(MULTI_CONFIG OFF) -endif() +get_property(MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) add_executable(mybin mybin.cpp) install(TARGETS mybin RUNTIME DESTINATION bin) diff --git a/Tests/OutDir/CMakeLists.txt b/Tests/OutDir/CMakeLists.txt index 88468c3c0b..823ab0864b 100644 --- a/Tests/OutDir/CMakeLists.txt +++ b/Tests/OutDir/CMakeLists.txt @@ -1,7 +1,8 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(OutDir C) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) foreach(config ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER "${config}" CONFIG) list(APPEND configs "${CONFIG}") diff --git a/Tests/PrecompiledHeader/CMakeLists.txt b/Tests/PrecompiledHeader/CMakeLists.txt index a804538929..58f4863b40 100644 --- a/Tests/PrecompiledHeader/CMakeLists.txt +++ b/Tests/PrecompiledHeader/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.9) project(PrecompiledHeader C) # Make sure the proper compiler is in use. @@ -7,7 +7,8 @@ if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel") endif() # Compute a custom name for the precompiled header. -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(PCH_DIR "${CMAKE_CURRENT_BINARY_DIR}/PCH/${CMAKE_CFG_INTDIR}") foreach(cfg ${CMAKE_CONFIGURATION_TYPES}) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PCH/${cfg}) diff --git a/Tests/Qt4Deploy/CMakeLists.txt b/Tests/Qt4Deploy/CMakeLists.txt index 646ea9f3b6..c73a38c0fc 100644 --- a/Tests/Qt4Deploy/CMakeLists.txt +++ b/Tests/Qt4Deploy/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(Qt4Deploy) set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/install) @@ -10,7 +10,8 @@ add_executable(testdeploy MACOSX_BUNDLE testdeploy.cpp) target_link_libraries(testdeploy ${QT_LIBRARIES}) set_target_properties(testdeploy PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") -if(CMAKE_CONFIGURATION_TYPES AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig AND QT_QTCORE_LIBRARY_RELEASE AND QT_QTCORE_LIBRARY_DEBUG) # note: installing debug Qt libraries from a Qt installation configured with # -debug-and-release not yet supported (very low priority). install(CODE " @@ -58,7 +59,7 @@ if(QT_QSQLITE_PLUGIN_DEBUG OR QT_QSQLITE_PLUGIN_RELEASE) endif() # custom target to install and test the installation at build time - if(CMAKE_CONFIGURATION_TYPES) + if(_isMultiConfig) set(install_config "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}") endif() diff --git a/Tests/QtAutogen/Complex/CMakeLists.txt b/Tests/QtAutogen/Complex/CMakeLists.txt index e9feea0063..a18cc042f7 100644 --- a/Tests/QtAutogen/Complex/CMakeLists.txt +++ b/Tests/QtAutogen/Complex/CMakeLists.txt @@ -36,7 +36,8 @@ add_custom_command( DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in" ) -if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_GENERATOR STREQUAL Ninja) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig AND NOT CMAKE_GENERATOR STREQUAL Ninja) set(debug_srcs "$<$<CONFIG:Debug>:debug_class.cpp>" $<$<CONFIG:Debug>:debug_resource.qrc>) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:TEST_DEBUG_CLASS>) endif() diff --git a/Tests/QtAutogen/TestMacros.cmake b/Tests/QtAutogen/TestMacros.cmake index 966f3b8f2d..bc7c7e294c 100644 --- a/Tests/QtAutogen/TestMacros.cmake +++ b/Tests/QtAutogen/TestMacros.cmake @@ -1,6 +1,6 @@ # Autogen build options set(Autogen_BUILD_OPTIONS "-DQT_TEST_VERSION=${QT_TEST_VERSION}") -if(NOT CMAKE_CONFIGURATION_TYPES) +if(NOT _isMultiConfig) # Set in Tests/CMakeLists.txt list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_BUILD_TYPE=$<CONFIGURATION>") endif() list(APPEND Autogen_BUILD_OPTIONS diff --git a/Tests/QtAutogen/UicInterface/CMakeLists.txt b/Tests/QtAutogen/UicInterface/CMakeLists.txt index a216aff64f..e0421a23c9 100644 --- a/Tests/QtAutogen/UicInterface/CMakeLists.txt +++ b/Tests/QtAutogen/UicInterface/CMakeLists.txt @@ -35,8 +35,8 @@ set_property(TARGET KI18n APPEND PROPERTY # END upstream -get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(_GENERATOR_IS_MULTI_CONFIG) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(INC_DIR "include_$<CONFIG>" ) else() set(INC_DIR "include" ) diff --git a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake index f268de7219..27a609dcb2 100644 --- a/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake +++ b/Tests/RunCMake/AutoExportDll/RunCMakeTest.cmake @@ -12,7 +12,7 @@ if("${RunCMake_GENERATOR}" MATCHES "Watcom WMake|Borland Makefiles") endif() # we build debug so the say.exe will be found in Debug/say.exe for # Visual Studio generators -if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode") +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) set(INTDIR "Debug/") endif() # build AutoExport diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 1bf8fbc49e..3445beb7bb 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -11,7 +11,7 @@ function(run_BuildDepends CASE) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${CASE}-build) set(RunCMake_TEST_NO_CLEAN 1) - if(RunCMake_GENERATOR MATCHES "Make|Ninja") + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") diff --git a/Tests/RunCMake/CMP0060/CMP0060-Common.cmake b/Tests/RunCMake/CMP0060/CMP0060-Common.cmake index e0a56e68ce..06955eebab 100644 --- a/Tests/RunCMake/CMP0060/CMP0060-Common.cmake +++ b/Tests/RunCMake/CMP0060/CMP0060-Common.cmake @@ -1,6 +1,7 @@ # Always build in a predictable configuration. For multi-config # generators we depend on RunCMakeTest.cmake to do this for us. -if(NOT CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig) set(CMAKE_BUILD_TYPE Debug) endif() diff --git a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt index f6cc97854a..e2c280ee73 100644 --- a/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt +++ b/Tests/RunCMake/CMP0060/CMP0060-WARN-ON-stderr.txt @@ -12,5 +12,5 @@ will ask the linker to search for these by library name. Call Stack \(most recent call first\): CMP0060-WARN-ON.cmake:[0-9]+ \(include\) - CMakeLists.txt:3 \(include\) + CMakeLists.txt:4 \(include\) This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/CMP0060/CMakeLists.txt b/Tests/RunCMake/CMP0060/CMakeLists.txt index db6b701c04..291d34d43d 100644 --- a/Tests/RunCMake/CMP0060/CMakeLists.txt +++ b/Tests/RunCMake/CMP0060/CMakeLists.txt @@ -1,3 +1,4 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.9) +cmake_policy(VERSION 3.2) project(${RunCMake_TEST} C) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index aa075b0277..8eb856811e 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -1,5 +1,8 @@ # See adjacent README.rst for documentation of this test infrastructure. +# Note that the _isMultiConfig variable is set in the parent directory's +# CMakeLists.txt (slightly complex logic to support CMake versions before 3.9) + macro(add_RunCMake_test test) set(TEST_ARGS ${ARGN}) if ("${ARGV1}" STREQUAL "TEST_DIR") @@ -14,6 +17,7 @@ macro(add_RunCMake_test test) endif() add_test(NAME RunCMake.${test} COMMAND ${CMAKE_CMAKE_COMMAND} -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR} + -DRunCMake_GENERATOR_IS_MULTI_CONFIG=${_isMultiConfig} -DRunCMake_GENERATOR=${CMAKE_GENERATOR} -DRunCMake_GENERATOR_INSTANCE=${CMAKE_GENERATOR_INSTANCE} -DRunCMake_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} @@ -47,6 +51,7 @@ function(add_RunCMake_test_group test types) add_test(NAME RunCMake.${test}_${type} COMMAND ${CMAKE_CMAKE_COMMAND} -DTEST_TYPE=${type} -DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR} + -DRunCMake_GENERATOR_IS_MULTI_CONFIG=${_isMultiConfig} -DRunCMake_GENERATOR=${CMAKE_GENERATOR} -DRunCMake_GENERATOR_INSTANCE=${CMAKE_GENERATOR_INSTANCE} -DRunCMake_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM} diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake index 1f76fd03e6..dcb992d484 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_ARGS.cmake @@ -1,4 +1,5 @@ -if(NOT CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig) set(CMAKE_BUILD_TYPE Debug) endif() include(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake index 1b619c8c0e..4b4b40e05a 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_DEFAULT_ARGS.cmake @@ -1,4 +1,5 @@ -if(NOT CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig) set(CMAKE_BUILD_TYPE Debug) endif() include(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake index 192776ba7b..2fb0705a53 100644 --- a/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake +++ b/Tests/RunCMake/ExternalProject/CMAKE_CACHE_mix.cmake @@ -1,4 +1,5 @@ -if(NOT CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig) set(CMAKE_BUILD_TYPE Debug) endif() include(ExternalProject) diff --git a/Tests/RunCMake/ExternalProject/UsesTerminal.cmake b/Tests/RunCMake/ExternalProject/UsesTerminal.cmake index cd874039df..d3494fd4ea 100644 --- a/Tests/RunCMake/ExternalProject/UsesTerminal.cmake +++ b/Tests/RunCMake/ExternalProject/UsesTerminal.cmake @@ -1,4 +1,5 @@ -if(NOT CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig) set(CMAKE_BUILD_TYPE Debug) endif() include(ExternalProject) diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake index 616e210fc5..94aaca84a1 100644 --- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake +++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake @@ -5,7 +5,7 @@ run_cmake(CMP0070-OLD) run_cmake(CMP0070-WARN) run_cmake(CommandConflict) -if("${RunCMake_GENERATOR}" MATCHES "Visual Studio|Xcode") +if(RunCMake_GENERATOR_IS_MULTI_CONFIG) run_cmake(OutputConflict) endif() run_cmake(EmptyCondition1) diff --git a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake index 9423ef5dd2..55625a8f09 100644 --- a/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake +++ b/Tests/RunCMake/GenerateExportHeader/RunCMakeTest.cmake @@ -4,7 +4,7 @@ function(run_GEH) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GEH-build) set(RunCMake_TEST_NO_CLEAN 1) - if(RunCMake_GENERATOR MATCHES "Make|Ninja") + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") diff --git a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake index 38e47f91fc..a66394b423 100644 --- a/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake +++ b/Tests/RunCMake/GeneratorExpression/ValidTarget-TARGET_PDB_FILE.cmake @@ -3,7 +3,8 @@ enable_language(C) add_library(empty SHARED empty.c) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) list(GET CMAKE_CONFIGURATION_TYPES 0 FIRST_CONFIG) set(GENERATE_CONDITION CONDITION $<CONFIG:${FIRST_CONFIG}>) endif() diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake index 73014d1438..209e7693d6 100644 --- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake @@ -4,7 +4,7 @@ function(run_GoogleTest) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-build) set(RunCMake_TEST_NO_CLEAN 1) - if(RunCMake_GENERATOR MATCHES "Make|Ninja") + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") diff --git a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake index a9a7f05c7a..3f238f2955 100644 --- a/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake +++ b/Tests/RunCMake/RuntimePath/RunCMakeTest.cmake @@ -5,7 +5,7 @@ function(run_SymlinkImplicit) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SymlinkImplicit-build) set(RunCMake_TEST_NO_CLEAN 1) - if(RunCMake_GENERATOR MATCHES "Make|Ninja") + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") diff --git a/Tests/RunCMake/get_property/RunCMakeTest.cmake b/Tests/RunCMake/get_property/RunCMakeTest.cmake index 017990fa92..06a0c673c1 100644 --- a/Tests/RunCMake/get_property/RunCMakeTest.cmake +++ b/Tests/RunCMake/get_property/RunCMakeTest.cmake @@ -23,6 +23,10 @@ run_cmake(NoSource) run_cmake(NoProperty) run_cmake(NoCache) +# Since we are testing the GENERATOR_IS_MULTI_CONFIG property itself, +# don't rely on RunCMake_GENERATOR_IS_MULTI_CONFIG being set correctly +# and instead explicitly check for a match against those generators we +# expect to be multi-config if(RunCMake_GENERATOR MATCHES "Visual Studio|Xcode") run_cmake(IsMultiConfig) else() diff --git a/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake b/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake index d1633e4451..72056aee36 100644 --- a/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake +++ b/Tests/RunCMake/test_include_dirs/RunCMakeTest.cmake @@ -4,7 +4,7 @@ function(run_TID) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TID-build) set(RunCMake_TEST_NO_CLEAN 1) - if(RunCMake_GENERATOR MATCHES "Make|Ninja") + if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index f8068b1431..784c3fac05 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.9) project (TestSimpleInstall) set(CMAKE_VERBOSE_MAKEFILE 1) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY @@ -307,7 +307,8 @@ else() INSTALL_NAME_DIR @executable_path/../lib) endif() -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(SI_CONFIG --config $<CONFIGURATION>) else() set(SI_CONFIG) diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index 4cf73559b0..dfb61a838c 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.9) project (TestSimpleInstall) set(CMAKE_VERBOSE_MAKEFILE 1) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY @@ -307,7 +307,8 @@ else() INSTALL_NAME_DIR @executable_path/../lib) endif() -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(SI_CONFIG --config $<CONFIGURATION>) else() set(SI_CONFIG) diff --git a/Tests/StagingPrefix/CMakeLists.txt b/Tests/StagingPrefix/CMakeLists.txt index 49ff7fee76..64a3cd2291 100644 --- a/Tests/StagingPrefix/CMakeLists.txt +++ b/Tests/StagingPrefix/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.9) project(StagingPrefix) # Wipe out the install tree @@ -17,7 +17,8 @@ set_property( PROPERTY SYMBOLIC 1 ) -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}") else() if(CMAKE_BUILD_TYPE) diff --git a/Tests/VSGNUFortran/CMakeLists.txt b/Tests/VSGNUFortran/CMakeLists.txt index 229c3156c1..993d0d65f7 100644 --- a/Tests/VSGNUFortran/CMakeLists.txt +++ b/Tests/VSGNUFortran/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.9) project(VSGNUFortran) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") @@ -9,7 +9,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") # because gmake build of fortran will not be in a config # directory, and for easier testing we want the exe and .dll # to be in the same directory. -if(CMAKE_CONFIGURATION_TYPES) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(_isMultiConfig) foreach(config ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER "${config}" config) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${config} |