diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 2bdff7889..22d080c6a 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -564,10 +564,26 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode const char* loc = 0; const char* imp = 0; std::string suffix; - return context->CurrentTarget->GetMappedConfig(context->Config, + if (context->CurrentTarget->GetMappedConfig(context->Config, &loc, &imp, - suffix) ? "1" : "0"; + suffix)) + { + // This imported target has an appropriate location + // for this (possibly mapped) config. + // Check if there is a proper config mapping for the tested config. + std::vector mappedConfigs; + std::string mapProp = "MAP_IMPORTED_CONFIG_"; + mapProp += context->Config; + if(const char* mapValue = + context->CurrentTarget->GetProperty(mapProp.c_str())) + { + cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue), + mappedConfigs); + return std::find(mappedConfigs.begin(), mappedConfigs.end(), + context->Config) != mappedConfigs.end() ? "1" : "0"; + } + } } return "0"; } diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index ab936ca31..7ac6ede3f 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -138,6 +138,31 @@ add_custom_target(check-part2 ALL VERBATIM ) +add_library(imported1 SHARED IMPORTED) +set_property(TARGET imported1 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) +set_property(TARGET imported1 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) +set_property(TARGET imported1 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) +set_property(TARGET imported1 PROPERTY INTERFACE_INCLUDE_DIRECTORIES /imported1/include) + +add_library(imported2 SHARED IMPORTED) +set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) +set_property(TARGET imported2 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) +set_property(TARGET imported2 PROPERTY IMPORTED_CONFIGURATIONS RELEASE DEBUG) +set_property(TARGET imported2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES /imported2/include) + +add_library(imported3 SHARED IMPORTED) +set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_RELEASE release_loc) +set_property(TARGET imported3 PROPERTY IMPORTED_LOCATION_DEBUG debug_loc) +# Both Debug and Release should not be true when this is evaluated. +set_property(TARGET imported3 APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES $<$:$>) +set_property(TARGET imported3 APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES $<$:$>) + +add_library(imported4 SHARED IMPORTED) +set_property(TARGET imported4 APPEND PROPERTY + INCLUDE_DIRECTORIES $) + add_custom_target(check-part3 ALL COMMAND ${CMAKE_COMMAND} -Dtest_version_greater_1=$ @@ -146,6 +171,11 @@ add_custom_target(check-part3 ALL -Dtest_version_less_2=$ -Dtest_version_equal_1=$ -Dtest_version_equal_2=$ + -Dconfig=$ + -Dtest_imported_debug=$ + -Dtest_imported_release=$ + -Dtest_imported_relwithdebinfo=$ + -Dtest_imported_minsizerel=$ -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)" VERBATIM diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake index 70d6571a7..af290a539 100644 --- a/Tests/GeneratorExpression/check-part3.cmake +++ b/Tests/GeneratorExpression/check-part3.cmake @@ -7,3 +7,16 @@ check(test_version_less_1 "0") check(test_version_less_2 "1") check(test_version_equal_1 "0") check(test_version_equal_2 "1") + +foreach(c debug release relwithdebinfo minsizerel) + if(config AND NOT config STREQUAL NoConfig) + if(NOT "${test_imported_${c}}" MATCHES "^;/imported2/include$" + AND NOT "${test_imported_${c}}" MATCHES "^/imported1/include;$") + message(SEND_ERROR "test_imported_${c} is not correct: ${test_imported_${c}}") + endif() + else() + if(NOT "${test_imported_${c}}" MATCHES "^;$") + message(SEND_ERROR "test_imported_${c} is not an empty list: ${test_imported_${c}}") + endif() + endif() +endforeach()