Commit 3c413e2a authored by Craig Scott's avatar Craig Scott

GENERATOR_IS_MULTI_CONFIG: Use for multi-config checks in Modules

parent c267ea1c
......@@ -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()
......
......@@ -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()
......
......@@ -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")
......
......@@ -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})
......
......@@ -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
......
......@@ -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})
......
......@@ -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})
......
......@@ -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}" )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment