Commit db6bf1f1 authored by Michael Stürmer's avatar Michael Stürmer
Browse files

added target properties VS_USER_PROPS_CXX and VS_CUSTOM_TARGETS

parent 1528831b
Pipeline #35906 failed with stage
......@@ -268,6 +268,7 @@ Properties on Targets
/prop_tgt/VERSION
/prop_tgt/VISIBILITY_INLINES_HIDDEN
/prop_tgt/VS_CONFIGURATION_TYPE
/prop_tgt/VS_CUSTOM_TARGETS
/prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION
/prop_tgt/VS_DOTNET_REFERENCES
/prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION
......@@ -284,6 +285,7 @@ Properties on Targets
/prop_tgt/VS_SCC_PROJECTNAME
/prop_tgt/VS_SCC_PROVIDER
/prop_tgt/VS_SDK_REFERENCES
/prop_tgt/VS_USER_PROPS_CXX
/prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
/prop_tgt/VS_WINRT_COMPONENT
/prop_tgt/VS_WINRT_EXTENSIONS
......
VS_CUSTOM_TARGETS
-----------------
Sets a custom .targets file which can be included at the end of the project. This can be necessary if the target to build relies on special configuration files.
Example for Wix custom action library:
set_target_properties(customActionLibrary PROPERTIES
VS_CUSTOM_TARGETS "$(MSBuildExtensionsPath)\\Microsoft\\WiX\\v3.x\\Wix.CA.targets"
)
VS_USER_PROPS_CXX
-----------------
Sets the user props file to be included in the visual studio
C++ project file. The standard path is
``$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props``, which is
in most cases the same as
``%LOCALAPPDATA%\\Microsoft\\MSBuild\\v4.0\\Microsoft.Cpp.Win32.user.props``
or ``%LOCALAPPDATA%\\Microsoft\\MSBuild\\v4.0\\Microsoft.Cpp.x64.user.props``.
The ``*.user.props`` files can be used for Visual Studio wide
configuration which is independent from cmake.
vs-msbuild-customization
------------------------
* The :ref:`Visual Studio Generators` for VS 2010 and above can
now be fine tuned using custom msbuild .targets files for
user props and targets. :prop_tgt:`VS_USER_PROPS_CXX` can be
used to change the default path of the user .props file from
``$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props`` to
an arbitrary filename. :prop_tgt:`VS_CUSTOM_TARGETS` may be used
to provide any custom `.targets` file which may be necessary
for special targets.
......@@ -139,7 +139,10 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line,
(*this->BuildFileStream) << line;
}
#define VS10_USER_PROPS "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props"
#define VS10_CXX_DEFAULT_PROPS "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"
#define VS10_CXX_PROPS "$(VCTargetsPath)\\Microsoft.Cpp.props"
#define VS10_CXX_USER_PROPS "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props"
#define VS10_CXX_TARGETS "$(VCTargetsPath)\\Microsoft.Cpp.targets"
void cmVisualStudio10TargetGenerator::Generate()
{
......@@ -168,7 +171,7 @@ void cmVisualStudio10TargetGenerator::Generate()
}
if (!this->ComputeLibOptions()) {
return;
}
}
}
std::string path = this->LocalGenerator->GetCurrentBinaryDirectory();
path += "/";
......@@ -348,9 +351,10 @@ void cmVisualStudio10TargetGenerator::Generate()
this->WriteString("<Import Project="
"\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n",
1);
this->WriteString("<Import Project=\"" VS10_CXX_DEFAULT_PROPS "\" />\n",
1);
this->WriteProjectConfigurationValues();
this->WriteString(
"<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n", 1);
this->WriteString("<Import Project=\"" VS10_CXX_PROPS "\" />\n", 1);
this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1);
if (this->GlobalGenerator->IsMasmEnabled()) {
this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
......@@ -359,10 +363,16 @@ void cmVisualStudio10TargetGenerator::Generate()
}
this->WriteString("</ImportGroup>\n", 1);
this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1);
this->WriteString("<Import Project=\"" VS10_USER_PROPS "\""
" Condition=\"exists('" VS10_USER_PROPS "')\""
" Label=\"LocalAppDataPlatform\" />\n",
2);
{
const char* props = this->GeneratorTarget->GetProperty("VS_USER_PROPS_CXX");
if (!props) {
props = VS10_CXX_USER_PROPS;
}
this->WriteString("", 2);
(*this->BuildFileStream) << "<Import Project=\"" << props << "\""
<< " Condition=\"exists('" << props << "')\""
<< " Label=\"LocalAppDataPlatform\" />\n";
}
this->WritePlatformExtensions();
this->WriteString("</ImportGroup>\n", 1);
this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
......@@ -377,10 +387,8 @@ void cmVisualStudio10TargetGenerator::Generate()
this->WriteWinRTReferences();
this->WriteProjectReferences();
this->WriteSDKReferences();
this->WriteString(
"<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\""
" />\n",
1);
this->WriteString("<Import Project=\"" VS10_CXX_TARGETS "\" />\n", 1);
this->WriteTargetSpecificReferences();
this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1);
this->WriteTargetsFileReferences();
......@@ -496,6 +504,12 @@ void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences()
"$(TargetPlatformVersion).targets\" />\n",
1);
}
const char* targets =
this->GeneratorTarget->GetProperty("VS_CUSTOM_TARGETS");
if (targets) {
(*this->BuildFileStream) << " "
<< "<Import Project=\"" << targets << "\" />\n";
}
}
}
......@@ -2439,7 +2453,7 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
if (cmVS10IsTargetsFile(l->Value)) {
vsTargetVec.push_back(path);
} else {
libVec.push_back(path);
libVec.push_back(path);
}
} else if (!l->Target ||
l->Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
......
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