include_external_msproject: Honor MAP_IMPORTED_CONFIG_<CONFIG>

This allows projects added via `include_external_msproject` to compile
the preferred configuration despite different naming conventions.
This commit is contained in:
Beeble
2017-04-04 21:13:35 +02:00
committed by Brad King
parent 4cd815f0b3
commit 227de0b95d
11 changed files with 61 additions and 11 deletions
@@ -0,0 +1 @@
check_project(CustomConfig external "aaa-bbb-ccc-000" "" "" "Custom - Release")
@@ -0,0 +1,3 @@
include_external_msproject(external external.project
GUID aaa-bbb-ccc-000)
set_target_properties(external PROPERTIES MAP_IMPORTED_CONFIG_RELEASE "Custom - Release")
@@ -1 +1 @@
check_project(CustomGuid external "aaa-bbb-ccc-000" "" "")
check_project(CustomGuid external "aaa-bbb-ccc-000" "" "" "")
@@ -1 +1 @@
check_project(CustomGuidTypePlatform external "aaa-bbb-ccc-111" "aaa-bbb-ccc-ddd-eee" "Custom Platform")
check_project(CustomGuidTypePlatform external "aaa-bbb-ccc-111" "aaa-bbb-ccc-ddd-eee" "Custom Platform" "")
@@ -1 +1 @@
check_project(CustomTypePlatform external "" "aaa-bbb-ccc-ddd-eee" "Custom Platform")
check_project(CustomTypePlatform external "" "aaa-bbb-ccc-ddd-eee" "Custom Platform" "")
@@ -4,3 +4,4 @@ include(${CMAKE_CURRENT_LIST_DIR}/check_utils.cmake)
run_cmake(CustomGuid)
run_cmake(CustomTypePlatform)
run_cmake(CustomGuidTypePlatform)
run_cmake(CustomConfig)
@@ -71,8 +71,24 @@ function(check_custom_platform TARGET_FILE PROJECT_NAME PLATFORM_NAME RESULT)
set(${RESULT} ${IS_FOUND} PARENT_SCOPE)
endfunction()
# Search project's build configuration line by project name and target configuration name.
# Returns TRUE if found and FALSE otherwise
function(check_custom_configuration TARGET_FILE PROJECT_NAME SLN_CONFIG DST_CONFIG RESULT)
set(${RESULT} "FALSE" PARENT_SCOPE)
# extract project guid
parse_project_section(${TARGET_FILE} ${PROJECT_NAME})
if(NOT IS_FOUND)
return()
endif()
set(REG_EXP "^(\t)*\\{${FOUND_GUID}\\}\\.${SLN_CONFIG}[^ ]*\\.ActiveCfg = ${DST_CONFIG}\\|.*$")
check_line_exists(${TARGET_FILE} REG_EXP)
set(${RESULT} ${IS_FOUND} PARENT_SCOPE)
endfunction()
# RunCMake test check helper
function(check_project test name guid type platform)
function(check_project test name guid type platform imported_release_config_name)
set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln")
set(sep "")
set(failed "")
@@ -88,6 +104,9 @@ function(check_project test name guid type platform)
set(platform "Win32")
endif()
endif()
if(NOT imported_release_config_name)
set(imported_release_config_name "Release")
endif()
if(guid)
check_project_guid("${sln}" "${name}" "${guid}" passed_guid)
if(NOT passed_guid)
@@ -107,5 +126,11 @@ function(check_project test name guid type platform)
string(APPEND failed "${sep}${name} solution has no project with expected PLATFORM=${platform}")
set(sep "\n")
endif()
check_custom_configuration("${sln}" "${name}" "Release" "${imported_release_config_name}" passed_configuration)
if(NOT passed_configuration)
string(APPEND failed "${sep}${name} solution has no project with expected CONFIG=${imported_release_config_name}")
set(sep "\n")
endif()
set(RunCMake_TEST_FAILED "${failed}" PARENT_SCOPE)
endfunction()