mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-01 20:00:51 -05:00
Merge topic 'include_external_msproject-map-config'
227de0b9include_external_msproject: Honor MAP_IMPORTED_CONFIG_<CONFIG>4cd815f0VS: Pass whole target to WriteProjectConfigurations Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !669
This commit is contained in:
@@ -20,3 +20,7 @@ command to make things depend on the external project.
|
||||
specify the type of project, id (GUID) of the project and the name of
|
||||
the target platform. This is useful for projects requiring values
|
||||
other than the default (e.g. WIX projects).
|
||||
|
||||
If the imported project has different configuration names than the
|
||||
current project, set the :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>`
|
||||
target property to specify the mapping.
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
include_external_msproject-map-config
|
||||
-------------------------------------
|
||||
|
||||
* The :command:`include_external_msproject` command learned to use
|
||||
the :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` target property
|
||||
to map current configurations to the external configurations.
|
||||
@@ -249,7 +249,7 @@ void cmGlobalVisualStudio71Generator::WriteExternalProject(
|
||||
// Write a dsp file into the SLN file, Note, that dependencies from
|
||||
// executables to the libraries it uses are also done here
|
||||
void cmGlobalVisualStudio71Generator::WriteProjectConfigurations(
|
||||
std::ostream& fout, const std::string& name, cmStateEnums::TargetType,
|
||||
std::ostream& fout, const std::string& name, cmGeneratorTarget const& target,
|
||||
std::vector<std::string> const& configs,
|
||||
const std::set<std::string>& configsPartOfDefaultBuild,
|
||||
std::string const& platformMapping)
|
||||
@@ -259,13 +259,18 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations(
|
||||
std::string guid = this->GetGUID(name);
|
||||
for (std::vector<std::string>::const_iterator i = configs.begin();
|
||||
i != configs.end(); ++i) {
|
||||
fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|"
|
||||
<< platformName << std::endl;
|
||||
const char* dstConfig = target.GetProperty("MAP_IMPORTED_CONFIG_" +
|
||||
cmSystemTools::UpperCase(*i));
|
||||
if (dstConfig == CM_NULLPTR) {
|
||||
dstConfig = i->c_str();
|
||||
}
|
||||
fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << dstConfig
|
||||
<< "|" << platformName << std::endl;
|
||||
std::set<std::string>::const_iterator ci =
|
||||
configsPartOfDefaultBuild.find(*i);
|
||||
if (!(ci == configsPartOfDefaultBuild.end())) {
|
||||
fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << *i << "|"
|
||||
<< platformName << std::endl;
|
||||
fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << dstConfig
|
||||
<< "|" << platformName << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ protected:
|
||||
const char* path,
|
||||
cmGeneratorTarget const* t);
|
||||
virtual void WriteProjectConfigurations(
|
||||
std::ostream& fout, const std::string& name, cmStateEnums::TargetType type,
|
||||
std::vector<std::string> const& configs,
|
||||
std::ostream& fout, const std::string& name,
|
||||
cmGeneratorTarget const& target, std::vector<std::string> const& configs,
|
||||
const std::set<std::string>& configsPartOfDefaultBuild,
|
||||
const std::string& platformMapping = "");
|
||||
virtual void WriteExternalProject(std::ostream& fout,
|
||||
|
||||
@@ -356,16 +356,16 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
|
||||
if (expath) {
|
||||
std::set<std::string> allConfigurations(configs.begin(), configs.end());
|
||||
const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING");
|
||||
this->WriteProjectConfigurations(
|
||||
fout, target->GetName().c_str(), target->GetType(), configs,
|
||||
allConfigurations, mapping ? mapping : "");
|
||||
this->WriteProjectConfigurations(fout, target->GetName().c_str(),
|
||||
*target, configs, allConfigurations,
|
||||
mapping ? mapping : "");
|
||||
} else {
|
||||
const std::set<std::string>& configsPartOfDefaultBuild =
|
||||
this->IsPartOfDefaultBuild(configs, projectTargets, target);
|
||||
const char* vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
|
||||
if (vcprojName) {
|
||||
this->WriteProjectConfigurations(fout, vcprojName, target->GetType(),
|
||||
configs, configsPartOfDefaultBuild);
|
||||
this->WriteProjectConfigurations(fout, vcprojName, *target, configs,
|
||||
configsPartOfDefaultBuild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ protected:
|
||||
const char* path,
|
||||
cmGeneratorTarget const* t) = 0;
|
||||
virtual void WriteProjectConfigurations(
|
||||
std::ostream& fout, const std::string& name, cmStateEnums::TargetType type,
|
||||
std::vector<std::string> const& configs,
|
||||
std::ostream& fout, const std::string& name,
|
||||
cmGeneratorTarget const& target, std::vector<std::string> const& configs,
|
||||
const std::set<std::string>& configsPartOfDefaultBuild,
|
||||
const std::string& platformMapping = "") = 0;
|
||||
virtual void WriteSLNGlobalSections(std::ostream& fout,
|
||||
|
||||
@@ -353,7 +353,7 @@ void cmGlobalVisualStudio8Generator::WriteSolutionConfigurations(
|
||||
}
|
||||
|
||||
void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
|
||||
std::ostream& fout, const std::string& name, cmStateEnums::TargetType type,
|
||||
std::ostream& fout, const std::string& name, cmGeneratorTarget const& target,
|
||||
std::vector<std::string> const& configs,
|
||||
const std::set<std::string>& configsPartOfDefaultBuild,
|
||||
std::string const& platformMapping)
|
||||
@@ -361,8 +361,13 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
|
||||
std::string guid = this->GetGUID(name);
|
||||
for (std::vector<std::string>::const_iterator i = configs.begin();
|
||||
i != configs.end(); ++i) {
|
||||
const char* dstConfig = target.GetProperty("MAP_IMPORTED_CONFIG_" +
|
||||
cmSystemTools::UpperCase(*i));
|
||||
if (dstConfig == CM_NULLPTR) {
|
||||
dstConfig = i->c_str();
|
||||
}
|
||||
fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
|
||||
<< ".ActiveCfg = " << *i << "|"
|
||||
<< ".ActiveCfg = " << dstConfig << "|"
|
||||
<< (!platformMapping.empty() ? platformMapping
|
||||
: this->GetPlatformName())
|
||||
<< "\n";
|
||||
@@ -370,14 +375,14 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
|
||||
configsPartOfDefaultBuild.find(*i);
|
||||
if (!(ci == configsPartOfDefaultBuild.end())) {
|
||||
fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
|
||||
<< ".Build.0 = " << *i << "|"
|
||||
<< ".Build.0 = " << dstConfig << "|"
|
||||
<< (!platformMapping.empty() ? platformMapping
|
||||
: this->GetPlatformName())
|
||||
<< "\n";
|
||||
}
|
||||
if (this->NeedsDeploy(type)) {
|
||||
if (this->NeedsDeploy(target.GetType())) {
|
||||
fout << "\t\t{" << guid << "}." << *i << "|" << this->GetPlatformName()
|
||||
<< ".Deploy.0 = " << *i << "|"
|
||||
<< ".Deploy.0 = " << dstConfig << "|"
|
||||
<< (!platformMapping.empty() ? platformMapping
|
||||
: this->GetPlatformName())
|
||||
<< "\n";
|
||||
|
||||
@@ -82,8 +82,8 @@ protected:
|
||||
virtual void WriteSolutionConfigurations(
|
||||
std::ostream& fout, std::vector<std::string> const& configs);
|
||||
virtual void WriteProjectConfigurations(
|
||||
std::ostream& fout, const std::string& name, cmStateEnums::TargetType type,
|
||||
std::vector<std::string> const& configs,
|
||||
std::ostream& fout, const std::string& name,
|
||||
cmGeneratorTarget const& target, std::vector<std::string> const& configs,
|
||||
const std::set<std::string>& configsPartOfDefaultBuild,
|
||||
const std::string& platformMapping = "");
|
||||
virtual bool ComputeTargetDepends();
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user