Merge topic 'use_generator_is_multi_config'

3c413e2a GENERATOR_IS_MULTI_CONFIG: Use for multi-config checks in Modules
c267ea1c GENERATOR_IS_MULTI_CONFIG: Use for multi-config checks in Tests

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1627
This commit is contained in:
Brad King 2018-01-08 16:14:12 +00:00 committed by Kitware Robot
commit f7f34a46e6
47 changed files with 176 additions and 102 deletions

View File

@ -50,6 +50,10 @@ function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT )
endif()
if(NOT CEIT_CONFIGURATION)
# Would be better to test GENERATOR_IS_MULTI_CONFIG global property,
# but the documented behavior specifically says we check
# CMAKE_CONFIGURATION_TYPES and fall back to CMAKE_BUILD_TYPE if no
# config types are defined.
if(CMAKE_CONFIGURATION_TYPES)
list(GET CMAKE_CONFIGURATION_TYPES 0 CEIT_CONFIGURATION)
else()

View File

@ -38,7 +38,8 @@ endif()
#
set(__conf_types "")
if(CMAKE_CONFIGURATION_TYPES)
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig)
# We need to pass the configuration type on the test command line.
set(__conf_types -C "${CMAKE_CFG_INTDIR}")
endif()

View File

@ -259,7 +259,8 @@ function(install_qt4_plugin_path plugin executable copy installed_plugin_path_va
file(MAKE_DIRECTORY "${plugins_path}")
file(COPY "${plugin}" DESTINATION "${plugins_path}")
else()
if(configurations AND (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE))
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(configurations AND (_isMultiConfig OR CMAKE_BUILD_TYPE))
set(configurations CONFIGURATIONS ${configurations})
else()
unset(configurations)
@ -295,7 +296,8 @@ function(install_qt4_plugin plugin executable copy installed_plugin_path_var)
set(plugin_debug "${plugin_release}")
endif()
if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig OR CMAKE_BUILD_TYPE)
install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}_release" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel")
install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}" "${component}" "Debug")

View File

@ -1790,7 +1790,8 @@ function(_ep_get_build_command name step cmd_var)
set(cmd "${CMAKE_COMMAND}")
endif()
set(args --build ".")
if(CMAKE_CONFIGURATION_TYPES)
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig)
if (CMAKE_CFG_INTDIR AND
NOT CMAKE_CFG_INTDIR STREQUAL "." AND
NOT CMAKE_CFG_INTDIR MATCHES "\\$")
@ -1815,7 +1816,7 @@ function(_ep_get_build_command name step cmd_var)
if("x${step}x" STREQUAL "xTESTx")
string(REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}")
set(args "")
if(CMAKE_CONFIGURATION_TYPES)
if(_isMultiConfig)
list(APPEND args -C ${config})
endif()
endif()
@ -1955,7 +1956,8 @@ endfunction()
#
function(_ep_get_configuration_subdir_suffix suffix_var)
set(suffix "")
if(CMAKE_CONFIGURATION_TYPES)
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig)
set(suffix "/${CMAKE_CFG_INTDIR}")
endif()
set(${suffix_var} "${suffix}" PARENT_SCOPE)
@ -2085,7 +2087,8 @@ function(ExternalProject_Add_Step name step)
set_property(SOURCE ${stamp_file} PROPERTY SYMBOLIC 1)
set(touch)
# Remove any existing stamp in case the option changed in an existing tree.
if(CMAKE_CONFIGURATION_TYPES)
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig)
foreach(cfg ${CMAKE_CONFIGURATION_TYPES})
string(REPLACE "/${CMAKE_CFG_INTDIR}" "/${cfg}" stamp_file_config "${stamp_file}")
file(REMOVE ${stamp_file_config})

View File

@ -275,13 +275,14 @@ endif()
macro(_Boost_ADJUST_LIB_VARS basename)
if(Boost_INCLUDE_DIR )
if(Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE)
# if the generator supports configuration types then set
# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
# if the generator is multi-config or if CMAKE_BUILD_TYPE is set for
# single-config generators, set optimized and debug libraries
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig OR CMAKE_BUILD_TYPE)
set(Boost_${basename}_LIBRARY optimized ${Boost_${basename}_LIBRARY_RELEASE} debug ${Boost_${basename}_LIBRARY_DEBUG})
else()
# if there are no configuration types and CMAKE_BUILD_TYPE has no value
# then just use the release libraries
# For single-config generators where CMAKE_BUILD_TYPE has no value,
# just use the release libraries
set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} )
endif()
# FIXME: This probably should be set for both cases

View File

@ -578,12 +578,15 @@ mark_as_advanced(
CUDA_SEPARABLE_COMPILATION
)
# Makefile and similar generators don't define CMAKE_CONFIGURATION_TYPES, so we
# need to add another entry for the CMAKE_BUILD_TYPE. We also need to add the
# standerd set of 4 build types (Debug, MinSizeRel, Release, and RelWithDebInfo)
# for completeness. We need run this loop in order to accommodate the addition
# of extra configuration types. Duplicate entries will be removed by
# REMOVE_DUPLICATES.
# Single config generators like Makefiles or Ninja don't usually have
# CMAKE_CONFIGURATION_TYPES defined (but note that it can be defined if set by
# projects or developers). Even CMAKE_BUILD_TYPE might not be defined for
# single config generators (and should not be defined for multi-config
# generators). To ensure we get a complete superset of all possible
# configurations, we combine CMAKE_CONFIGURATION_TYPES, CMAKE_BUILD_TYPE and
# all of the standard configurations, then weed out duplicates with
# list(REMOVE_DUPLICATES). Looping over the unique set then ensures we have
# each configuration-specific set of nvcc flags defined and marked as advanced.
set(CUDA_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo)
list(REMOVE_DUPLICATES CUDA_configuration_types)
foreach(config ${CUDA_configuration_types})

View File

@ -398,13 +398,14 @@ macro (_QT4_ADJUST_LIB_VARS _camelCaseBasename)
# if the release- as well as the debug-version of the library have been found:
if (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE)
# if the generator supports configuration types then set
# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
if (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
# if the generator is multi-config or if CMAKE_BUILD_TYPE is set for
# single-config generators, set optimized and debug libraries
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig OR CMAKE_BUILD_TYPE)
set(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})
else()
# if there are no configuration types and CMAKE_BUILD_TYPE has no value
# then just use the release libraries
# For single-config generators where CMAKE_BUILD_TYPE has no value,
# just use the release libraries
set(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} )
endif()
set(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG})

View File

@ -38,11 +38,12 @@ macro( select_library_configurations basename )
set(${basename}_LIBRARY_DEBUG "${basename}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library.")
endif()
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND
NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE AND
( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) )
# if the generator supports configuration types or CMAKE_BUILD_TYPE
# is set, then set optimized and debug options.
( _isMultiConfig OR CMAKE_BUILD_TYPE ) )
# if the generator is multi-config or if CMAKE_BUILD_TYPE is set for
# single-config generators, set optimized and debug libraries
set( ${basename}_LIBRARY "" )
foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE )
list( APPEND ${basename}_LIBRARY optimized "${_libname}" )

View File

@ -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@")

View File

@ -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>)

View File

@ -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)

View File

@ -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")

View File

@ -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}

View File

@ -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()

View File

@ -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)

View File

@ -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)

View File

@ -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()

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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}")

View File

@ -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})

View File

@ -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()

View File

@ -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()

View File

@ -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

View File

@ -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" )

View File

@ -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

View File

@ -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}")

View File

@ -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()

View File

@ -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.$

View File

@ -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)

View File

@ -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}

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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}")

View File

@ -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()

View File

@ -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}")

View File

@ -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}")

View File

@ -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()

View File

@ -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}")

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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}