mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-03 14:20:27 +00:00
Genex: $<CONFIG:> now supports multiple configurations
Instead of having to do $<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>> you can do $<CONFIG:Release,MinSizeRel>
This commit is contained in:
committed by
Brad King
parent
c4cc21d20b
commit
eae15dce6a
@@ -105,10 +105,11 @@ Variable Queries
|
|||||||
|
|
||||||
``$<TARGET_EXISTS:target>``
|
``$<TARGET_EXISTS:target>``
|
||||||
``1`` if ``target`` exists, else ``0``.
|
``1`` if ``target`` exists, else ``0``.
|
||||||
``$<CONFIG:cfg>``
|
``$<CONFIG:cfgs>``
|
||||||
``1`` if config is ``cfg``, else ``0``. This is a case-insensitive comparison.
|
``1`` if config is any one of the entires in ``cfgs``, else ``0``. This is a
|
||||||
The mapping in :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` is also considered by
|
case-insensitive comparison. The mapping in
|
||||||
this expression when it is evaluated on a property on an :prop_tgt:`IMPORTED`
|
:prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` is also considered by this
|
||||||
|
expression when it is evaluated on a property on an :prop_tgt:`IMPORTED`
|
||||||
target.
|
target.
|
||||||
``$<PLATFORM_ID:platform_ids>``
|
``$<PLATFORM_ID:platform_ids>``
|
||||||
where ``platform_ids`` is a comma-separated list.
|
where ``platform_ids`` is a comma-separated list.
|
||||||
|
|||||||
@@ -881,7 +881,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
|
|||||||
{
|
{
|
||||||
ConfigurationTestNode() {} // NOLINT(modernize-use-equals-default)
|
ConfigurationTestNode() {} // NOLINT(modernize-use-equals-default)
|
||||||
|
|
||||||
int NumExpectedParameters() const override { return OneOrZeroParameters; }
|
int NumExpectedParameters() const override { return ZeroOrMoreParameters; }
|
||||||
|
|
||||||
std::string Evaluate(
|
std::string Evaluate(
|
||||||
const std::vector<std::string>& parameters,
|
const std::vector<std::string>& parameters,
|
||||||
@@ -899,13 +899,15 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
|
|||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
context->HadContextSensitiveCondition = true;
|
context->HadContextSensitiveCondition = true;
|
||||||
if (context->Config.empty()) {
|
for (auto& param : parameters) {
|
||||||
return parameters.front().empty() ? "1" : "0";
|
if (context->Config.empty()) {
|
||||||
}
|
if (param.empty()) {
|
||||||
|
return "1";
|
||||||
if (cmsysString_strcasecmp(parameters.front().c_str(),
|
}
|
||||||
context->Config.c_str()) == 0) {
|
} else if (cmsysString_strcasecmp(param.c_str(),
|
||||||
return "1";
|
context->Config.c_str()) == 0) {
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->CurrentTarget && context->CurrentTarget->IsImported()) {
|
if (context->CurrentTarget && context->CurrentTarget->IsImported()) {
|
||||||
@@ -922,10 +924,12 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
|
|||||||
"MAP_IMPORTED_CONFIG_", cmSystemTools::UpperCase(context->Config));
|
"MAP_IMPORTED_CONFIG_", cmSystemTools::UpperCase(context->Config));
|
||||||
if (cmProp mapValue = context->CurrentTarget->GetProperty(mapProp)) {
|
if (cmProp mapValue = context->CurrentTarget->GetProperty(mapProp)) {
|
||||||
cmExpandList(cmSystemTools::UpperCase(*mapValue), mappedConfigs);
|
cmExpandList(cmSystemTools::UpperCase(*mapValue), mappedConfigs);
|
||||||
return cm::contains(mappedConfigs,
|
|
||||||
cmSystemTools::UpperCase(parameters.front()))
|
for (auto& param : parameters) {
|
||||||
? "1"
|
if (cm::contains(mappedConfigs, cmSystemTools::UpperCase(param))) {
|
||||||
: "0";
|
return "1";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ add_custom_target(check-part1 ALL
|
|||||||
-Dtest_and_0_invalidcontent=$<AND:0,invalidcontent>
|
-Dtest_and_0_invalidcontent=$<AND:0,invalidcontent>
|
||||||
-Dtest_config_0=$<CONFIG:$<CONFIGURATION>x>
|
-Dtest_config_0=$<CONFIG:$<CONFIGURATION>x>
|
||||||
-Dtest_config_1=$<CONFIG:$<CONFIGURATION>>
|
-Dtest_config_1=$<CONFIG:$<CONFIGURATION>>
|
||||||
-Dtest_config_debug=$<CONFIG:Debug>$<CONFIG:DEBUG>$<CONFIG:DeBuG>
|
-Dtest_config_debug=$<CONFIG:Debug,DEBUG,DeBuG>
|
||||||
-Dtest_config_release=$<CONFIG:Release>$<CONFIG:RELEASE>$<CONFIG:ReLeAsE>
|
-Dtest_config_release=$<CONFIG:Release>$<CONFIG:RELEASE,ReLeAsE>
|
||||||
-Dtest_config_relwithdebinfo=$<CONFIG:RelWithDebInfo>$<CONFIG:RELWITHDEBINFO>$<CONFIG:relwithdebinfo>
|
-Dtest_config_relwithdebinfo=$<CONFIG:RelWithDebInfo,RELWITHDEBINFO>$<CONFIG:relwithdebinfo>
|
||||||
-Dtest_config_minsizerel=$<CONFIG:MinSizeRel>$<CONFIG:MINSIZEREL>$<CONFIG:minsizerel>
|
-Dtest_config_minsizerel=$<CONFIG:MinSizeRel>$<CONFIG:MINSIZEREL>$<CONFIG:minsizerel>
|
||||||
-Dtest_not_0=$<NOT:0>
|
-Dtest_not_0=$<NOT:0>
|
||||||
-Dtest_not_1=$<NOT:1>
|
-Dtest_not_1=$<NOT:1>
|
||||||
@@ -180,9 +180,7 @@ set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc)
|
|||||||
set_property(TARGET imported3 APPEND PROPERTY
|
set_property(TARGET imported3 APPEND PROPERTY
|
||||||
INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:DEBUG>:$<TARGET_PROPERTY:imported1,INTERFACE_INCLUDE_DIRECTORIES>>)
|
INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:DEBUG>:$<TARGET_PROPERTY:imported1,INTERFACE_INCLUDE_DIRECTORIES>>)
|
||||||
set_property(TARGET imported3 APPEND PROPERTY
|
set_property(TARGET imported3 APPEND PROPERTY
|
||||||
INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:RELEASE>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>)
|
INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:RELEASE,RELWITHDEBINFO>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>)
|
||||||
set_property(TARGET imported3 APPEND PROPERTY
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:RELWITHDEBINFO>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>)
|
|
||||||
set_property(TARGET imported3 APPEND PROPERTY
|
set_property(TARGET imported3 APPEND PROPERTY
|
||||||
INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:MINSIZEREL>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>)
|
INTERFACE_INCLUDE_DIRECTORIES $<$<CONFIG:MINSIZEREL>:$<TARGET_PROPERTY:imported2,INTERFACE_INCLUDE_DIRECTORIES>>)
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ if(config AND NOT config STREQUAL NoConfig)
|
|||||||
message(SEND_ERROR "test_imported_includes is not correct: ${test_imported_includes}")
|
message(SEND_ERROR "test_imported_includes is not correct: ${test_imported_includes}")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if(NOT "${test_imported_includes}" MATCHES "^;;;$")
|
if(NOT "${test_imported_includes}" MATCHES "^;;$")
|
||||||
message(SEND_ERROR "test_imported_includes is not an empty list: ${test_imported_includes}")
|
message(SEND_ERROR "test_imported_includes is not an empty list: ${test_imported_includes}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -7,15 +7,6 @@ CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
|
|||||||
Call Stack \(most recent call first\):
|
Call Stack \(most recent call first\):
|
||||||
CMakeLists.txt:3 \(include\)
|
CMakeLists.txt:3 \(include\)
|
||||||
+
|
+
|
||||||
CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
|
|
||||||
Error evaluating generator expression:
|
|
||||||
|
|
||||||
\$<CONFIG:Foo,Bar>
|
|
||||||
|
|
||||||
\$<CONFIG> expression requires one or zero parameters.
|
|
||||||
Call Stack \(most recent call first\):
|
|
||||||
CMakeLists.txt:3 \(include\)
|
|
||||||
+
|
|
||||||
CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
|
CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
|
||||||
Error evaluating generator expression:
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
add_custom_target(check ALL COMMAND check
|
add_custom_target(check ALL COMMAND check
|
||||||
$<CONFIG:.>
|
$<CONFIG:.>
|
||||||
$<CONFIG:Foo,Bar>
|
|
||||||
$<CONFIG:Foo-Bar>
|
$<CONFIG:Foo-Bar>
|
||||||
$<$<CONFIG:Foo-Nested>:foo>
|
$<$<CONFIG:Foo-Nested>:foo>
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
file(READ "${RunCMake_TEST_BINARY_DIR}/CONFIG-empty-entries-generated.txt" content)
|
||||||
|
|
||||||
|
set(expected "1234")
|
||||||
|
if(NOT content STREQUAL expected)
|
||||||
|
set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
cmake_policy(SET CMP0070 NEW)
|
||||||
|
|
||||||
|
set(text)
|
||||||
|
string(APPEND text "$<$<CONFIG:>:1>")
|
||||||
|
string(APPEND text "$<$<CONFIG:Release,>:2>")
|
||||||
|
string(APPEND text "$<$<CONFIG:,Release>:3>")
|
||||||
|
string(APPEND text "$<$<CONFIG:Release,,Debug>:4>")
|
||||||
|
string(APPEND text "$<$<CONFIG:Release,Debug>:5>")
|
||||||
|
file(GENERATE OUTPUT CONFIG-empty-entries-generated.txt CONTENT ${text})
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
file(READ "${RunCMake_TEST_BINARY_DIR}/CONFIG-multiple-entries-generated.txt" content)
|
||||||
|
|
||||||
|
set(expected "14")
|
||||||
|
if(NOT content STREQUAL expected)
|
||||||
|
set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]")
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
cmake_policy(SET CMP0070 NEW)
|
||||||
|
|
||||||
|
set(text)
|
||||||
|
string(APPEND text "$<$<CONFIG:CustomConfig>:1>")
|
||||||
|
string(APPEND text "$<$<CONFIG:Release>:2>")
|
||||||
|
string(APPEND text "$<$<CONFIG:Debug,Release>:3>")
|
||||||
|
string(APPEND text "$<$<CONFIG:Release,CustomConfig,Debug>:4>")
|
||||||
|
file(GENERATE OUTPUT CONFIG-multiple-entries-generated.txt CONTENT "${text}")
|
||||||
@@ -12,6 +12,7 @@ run_cmake(BadTargetTypeInterface)
|
|||||||
run_cmake(BadTargetTypeObject)
|
run_cmake(BadTargetTypeObject)
|
||||||
run_cmake(BadInstallPrefix)
|
run_cmake(BadInstallPrefix)
|
||||||
run_cmake(BadSHELL_PATH)
|
run_cmake(BadSHELL_PATH)
|
||||||
|
run_cmake(BadCONFIG)
|
||||||
run_cmake(CMP0044-WARN)
|
run_cmake(CMP0044-WARN)
|
||||||
run_cmake(NonValidTarget-C_COMPILER_ID)
|
run_cmake(NonValidTarget-C_COMPILER_ID)
|
||||||
run_cmake(NonValidTarget-CXX_COMPILER_ID)
|
run_cmake(NonValidTarget-CXX_COMPILER_ID)
|
||||||
@@ -44,6 +45,19 @@ run_cmake(FILTER-InvalidOperator)
|
|||||||
run_cmake(FILTER-Exclude)
|
run_cmake(FILTER-Exclude)
|
||||||
run_cmake(FILTER-Include)
|
run_cmake(FILTER-Include)
|
||||||
|
|
||||||
|
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||||
|
set(RunCMake_TEST_OPTIONS [==[-DCMAKE_CONFIGURATION_TYPES=CustomConfig]==])
|
||||||
|
else()
|
||||||
|
set(RunCMake_TEST_OPTIONS [==[-DCMAKE_BUILD_TYPE=CustomConfig]==])
|
||||||
|
endif()
|
||||||
|
run_cmake(CONFIG-multiple-entries)
|
||||||
|
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
|
||||||
|
set(RunCMake_TEST_OPTIONS [==[-DCMAKE_CONFIGURATION_TYPES=]==])
|
||||||
|
else()
|
||||||
|
set(RunCMake_TEST_OPTIONS [==[-DCMAKE_BUILD_TYPE=]==])
|
||||||
|
endif()
|
||||||
|
run_cmake(CONFIG-empty-entries)
|
||||||
|
|
||||||
set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0085:STRING=OLD)
|
set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0085:STRING=OLD)
|
||||||
run_cmake(CMP0085-OLD)
|
run_cmake(CMP0085-OLD)
|
||||||
unset(RunCMake_TEST_OPTIONS)
|
unset(RunCMake_TEST_OPTIONS)
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "Assets")
|
|||||||
set_property(SOURCE ${STRING_FILES} PROPERTY VS_TOOL_OVERRIDE "PRIResource")
|
set_property(SOURCE ${STRING_FILES} PROPERTY VS_TOOL_OVERRIDE "PRIResource")
|
||||||
set_property(SOURCE ${DEBUG_CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT $<CONFIG:Debug>)
|
set_property(SOURCE ${DEBUG_CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT $<CONFIG:Debug>)
|
||||||
set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY
|
set_property(SOURCE ${RELEASE_CONTENT_FILES} PROPERTY
|
||||||
VS_DEPLOYMENT_CONTENT $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>)
|
VS_DEPLOYMENT_CONTENT $<CONFIG:Release,RelWithDebInfo,MinSizeRel>)
|
||||||
|
|
||||||
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel)
|
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_TYPE Pixel)
|
||||||
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS)
|
set_property(SOURCE ${PIXELSHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT mainPS)
|
||||||
|
|||||||
Reference in New Issue
Block a user