mirror of
https://github.com/reactos/CMake.git
synced 2024-12-17 08:36:48 +00:00
VS: Add option to customize vcxproj user props file
Add a `VS_USER_PROPS_CXX` target property to set the user props file of the generated `.vcxproj` file to be something other than the default `$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props`.
This commit is contained in:
parent
1528831bb1
commit
e390991846
@ -284,6 +284,7 @@ Properties on Targets
|
|||||||
/prop_tgt/VS_SCC_PROJECTNAME
|
/prop_tgt/VS_SCC_PROJECTNAME
|
||||||
/prop_tgt/VS_SCC_PROVIDER
|
/prop_tgt/VS_SCC_PROVIDER
|
||||||
/prop_tgt/VS_SDK_REFERENCES
|
/prop_tgt/VS_SDK_REFERENCES
|
||||||
|
/prop_tgt/VS_USER_PROPS_CXX
|
||||||
/prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
|
/prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
|
||||||
/prop_tgt/VS_WINRT_COMPONENT
|
/prop_tgt/VS_WINRT_COMPONENT
|
||||||
/prop_tgt/VS_WINRT_EXTENSIONS
|
/prop_tgt/VS_WINRT_EXTENSIONS
|
||||||
|
12
Help/prop_tgt/VS_USER_PROPS_CXX.rst
Normal file
12
Help/prop_tgt/VS_USER_PROPS_CXX.rst
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
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.
|
9
Help/release/dev/vs-custom-msbuild-props.rst
Normal file
9
Help/release/dev/vs-custom-msbuild-props.rst
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
vs-custom-msbuild-props
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
* The :ref:`Visual Studio Generators` for VS 2010 and above can
|
||||||
|
now be fine tuned using custom msbuild .props files.
|
||||||
|
: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.
|
@ -139,7 +139,11 @@ void cmVisualStudio10TargetGenerator::WriteString(const char* line,
|
|||||||
(*this->BuildFileStream) << 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()
|
void cmVisualStudio10TargetGenerator::Generate()
|
||||||
{
|
{
|
||||||
@ -345,12 +349,9 @@ void cmVisualStudio10TargetGenerator::Generate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->WriteString("</PropertyGroup>\n", 1);
|
this->WriteString("</PropertyGroup>\n", 1);
|
||||||
this->WriteString("<Import Project="
|
this->WriteString("<Import Project=\"" VS10_CXX_DEFAULT_PROPS "\" />\n", 1);
|
||||||
"\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n",
|
|
||||||
1);
|
|
||||||
this->WriteProjectConfigurationValues();
|
this->WriteProjectConfigurationValues();
|
||||||
this->WriteString(
|
this->WriteString("<Import Project=\"" VS10_CXX_PROPS "\" />\n", 1);
|
||||||
"<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n", 1);
|
|
||||||
this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1);
|
this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1);
|
||||||
if (this->GlobalGenerator->IsMasmEnabled()) {
|
if (this->GlobalGenerator->IsMasmEnabled()) {
|
||||||
this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
|
this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
|
||||||
@ -359,10 +360,19 @@ void cmVisualStudio10TargetGenerator::Generate()
|
|||||||
}
|
}
|
||||||
this->WriteString("</ImportGroup>\n", 1);
|
this->WriteString("</ImportGroup>\n", 1);
|
||||||
this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1);
|
this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1);
|
||||||
this->WriteString("<Import Project=\"" VS10_USER_PROPS "\""
|
{
|
||||||
" Condition=\"exists('" VS10_USER_PROPS "')\""
|
std::string props = VS10_CXX_USER_PROPS;
|
||||||
" Label=\"LocalAppDataPlatform\" />\n",
|
if (const char* p =
|
||||||
2);
|
this->GeneratorTarget->GetProperty("VS_USER_PROPS_CXX")) {
|
||||||
|
props = p;
|
||||||
|
this->ConvertToWindowsSlash(props);
|
||||||
|
}
|
||||||
|
this->WriteString("", 2);
|
||||||
|
(*this->BuildFileStream)
|
||||||
|
<< "<Import Project=\"" << cmVS10EscapeXML(props) << "\""
|
||||||
|
<< " Condition=\"exists('" << cmVS10EscapeXML(props) << "')\""
|
||||||
|
<< " Label=\"LocalAppDataPlatform\" />\n";
|
||||||
|
}
|
||||||
this->WritePlatformExtensions();
|
this->WritePlatformExtensions();
|
||||||
this->WriteString("</ImportGroup>\n", 1);
|
this->WriteString("</ImportGroup>\n", 1);
|
||||||
this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
|
this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
|
||||||
@ -377,10 +387,8 @@ void cmVisualStudio10TargetGenerator::Generate()
|
|||||||
this->WriteWinRTReferences();
|
this->WriteWinRTReferences();
|
||||||
this->WriteProjectReferences();
|
this->WriteProjectReferences();
|
||||||
this->WriteSDKReferences();
|
this->WriteSDKReferences();
|
||||||
this->WriteString(
|
this->WriteString("<Import Project=\"" VS10_CXX_TARGETS "\" />\n", 1);
|
||||||
"<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\""
|
|
||||||
" />\n",
|
|
||||||
1);
|
|
||||||
this->WriteTargetSpecificReferences();
|
this->WriteTargetSpecificReferences();
|
||||||
this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1);
|
this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1);
|
||||||
this->WriteTargetsFileReferences();
|
this->WriteTargetsFileReferences();
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
include(RunCMake)
|
include(RunCMake)
|
||||||
run_cmake(VsConfigurationType)
|
run_cmake(VsConfigurationType)
|
||||||
run_cmake(VsTargetsFileReferences)
|
run_cmake(VsTargetsFileReferences)
|
||||||
|
run_cmake(VsCustomProps)
|
||||||
|
25
Tests/RunCMake/VS10Project/VsCustomProps-check.cmake
Normal file
25
Tests/RunCMake/VS10Project/VsCustomProps-check.cmake
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
|
||||||
|
if(NOT EXISTS "${vcProjectFile}")
|
||||||
|
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(importFound FALSE)
|
||||||
|
|
||||||
|
set(props_file "${RunCMake_SOURCE_DIR}/my.props")
|
||||||
|
file(TO_NATIVE_PATH "${props_file}" check_file)
|
||||||
|
file(STRINGS "${vcProjectFile}" lines)
|
||||||
|
foreach(line IN LISTS lines)
|
||||||
|
if(line MATCHES "^ *<Import Project=\"([^\"]+)\".*Label=\"([^\"]+)\".*$")
|
||||||
|
if("${CMAKE_MATCH_1}" STREQUAL "${check_file}" AND
|
||||||
|
"${CMAKE_MATCH_2}" STREQUAL "LocalAppDataPlatform")
|
||||||
|
message(STATUS "foo.vcxproj is importing ${check_file}")
|
||||||
|
set(importFound TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(NOT importFound)
|
||||||
|
set(RunCMake_TEST_FAILED "Import of custom .props file not found.")
|
||||||
|
return()
|
||||||
|
endif()
|
7
Tests/RunCMake/VS10Project/VsCustomProps.cmake
Normal file
7
Tests/RunCMake/VS10Project/VsCustomProps.cmake
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
enable_language(CXX)
|
||||||
|
add_library(foo foo.cpp)
|
||||||
|
|
||||||
|
set(props_file "${CMAKE_CURRENT_SOURCE_DIR}/my.props")
|
||||||
|
|
||||||
|
set_target_properties(foo PROPERTIES
|
||||||
|
VS_USER_PROPS_CXX "${props_file}")
|
5
Tests/RunCMake/VS10Project/my.props
Normal file
5
Tests/RunCMake/VS10Project/my.props
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user