diff options
author | Bastien Schatt <bastien.schatt@magestik.fr> | 2018-04-15 20:14:52 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-04-19 13:39:34 (GMT) |
commit | 6ec3e880e75761edcbb1e84fa4a596e69ac5a94f (patch) | |
tree | 38b04d28522ec3da6c22546b7b6d805892f80a16 | |
parent | 4984d8433edb05eac446542b561a31edf7a25783 (diff) | |
download | CMake-6ec3e880e75761edcbb1e84fa4a596e69ac5a94f.zip CMake-6ec3e880e75761edcbb1e84fa4a596e69ac5a94f.tar.gz CMake-6ec3e880e75761edcbb1e84fa4a596e69ac5a94f.tar.bz2 |
VS: Add variables to set SDK directories in vcxproj files
Create `CMAKE_VS_SDK_*_DIRECTORIES` variables to tell the VS generator
how to populate fields in `.vcxproj` files that specify SDK directories.
Fixes: #17908
-rw-r--r-- | Help/manual/cmake-variables.7.rst | 7 | ||||
-rw-r--r-- | Help/release/dev/vs-sdk-dirs.rst | 15 | ||||
-rw-r--r-- | Help/variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES.rst | 4 | ||||
-rw-r--r-- | Help/variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES.rst | 4 | ||||
-rw-r--r-- | Help/variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES.rst | 4 | ||||
-rw-r--r-- | Help/variable/CMAKE_VS_SDK_LIBRARY_DIRECTORIES.rst | 4 | ||||
-rw-r--r-- | Help/variable/CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES.rst | 5 | ||||
-rw-r--r-- | Help/variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES.rst | 4 | ||||
-rw-r--r-- | Help/variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES.rst | 4 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 49 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/VsSdkDirectories-check.cmake | 88 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/VsSdkDirectories.cmake | 11 |
13 files changed, 200 insertions, 0 deletions
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index c1b0316..44271c1 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -369,6 +369,13 @@ Variables that Control the Build /variable/CMAKE_VISIBILITY_INLINES_HIDDEN /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD /variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD + /variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES + /variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES + /variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES + /variable/CMAKE_VS_SDK_LIBRARY_DIRECTORIES + /variable/CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES + /variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES + /variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES /variable/CMAKE_WIN32_EXECUTABLE /variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS /variable/CMAKE_XCODE_ATTRIBUTE_an-attribute diff --git a/Help/release/dev/vs-sdk-dirs.rst b/Help/release/dev/vs-sdk-dirs.rst new file mode 100644 index 0000000..3377775 --- /dev/null +++ b/Help/release/dev/vs-sdk-dirs.rst @@ -0,0 +1,15 @@ +vs-sdk-dirs +----------- + +* ``CMAKE_VS_SDK_*_DIRECTORIES`` variables were defined to tell + :ref:`Visual Studio Generators` for VS 2010 and above how to populate + fields in ``.vcxproj`` files that specify SDK directories. The + variables are: + + - :variable:`CMAKE_VS_SDK_EXCLUDE_DIRECTORIES` + - :variable:`CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES` + - :variable:`CMAKE_VS_SDK_INCLUDE_DIRECTORIES` + - :variable:`CMAKE_VS_SDK_LIBRARY_DIRECTORIES` + - :variable:`CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES` + - :variable:`CMAKE_VS_SDK_REFERENCE_DIRECTORIES` + - :variable:`CMAKE_VS_SDK_SOURCE_DIRECTORIES` diff --git a/Help/variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES.rst new file mode 100644 index 0000000..36c4dcc --- /dev/null +++ b/Help/variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES.rst @@ -0,0 +1,4 @@ +CMAKE_VS_SDK_EXCLUDE_DIRECTORIES +-------------------------------- + +This variable allows to override Visual Studio default Exclude Directories. diff --git a/Help/variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES.rst new file mode 100644 index 0000000..3ec755b --- /dev/null +++ b/Help/variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES.rst @@ -0,0 +1,4 @@ +CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES +----------------------------------- + +This variable allows to override Visual Studio default Executable Directories. diff --git a/Help/variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES.rst new file mode 100644 index 0000000..da10bde --- /dev/null +++ b/Help/variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES.rst @@ -0,0 +1,4 @@ +CMAKE_VS_SDK_INCLUDE_DIRECTORIES +-------------------------------- + +This variable allows to override Visual Studio default Include Directories. diff --git a/Help/variable/CMAKE_VS_SDK_LIBRARY_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_LIBRARY_DIRECTORIES.rst new file mode 100644 index 0000000..b33754a --- /dev/null +++ b/Help/variable/CMAKE_VS_SDK_LIBRARY_DIRECTORIES.rst @@ -0,0 +1,4 @@ +CMAKE_VS_SDK_LIBRARY_DIRECTORIES +-------------------------------- + +This variable allows to override Visual Studio default Library Directories. diff --git a/Help/variable/CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES.rst new file mode 100644 index 0000000..b022215 --- /dev/null +++ b/Help/variable/CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES.rst @@ -0,0 +1,5 @@ +CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES +-------------------------------------- + +This variable allows to override Visual Studio default Library WinRT +Directories. diff --git a/Help/variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES.rst new file mode 100644 index 0000000..c03f0ae --- /dev/null +++ b/Help/variable/CMAKE_VS_SDK_REFERENCE_DIRECTORIES.rst @@ -0,0 +1,4 @@ +CMAKE_VS_SDK_REFERENCE_DIRECTORIES +---------------------------------- + +This variable allows to override Visual Studio default Reference Directories. diff --git a/Help/variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES.rst b/Help/variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES.rst new file mode 100644 index 0000000..0c73f06 --- /dev/null +++ b/Help/variable/CMAKE_VS_SDK_SOURCE_DIRECTORIES.rst @@ -0,0 +1,4 @@ +CMAKE_VS_SDK_SOURCE_DIRECTORIES +------------------------------- + +This variable allows to override Visual Studio default Source Directories. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 13af167..0d32b3a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2235,6 +2235,55 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() *this->BuildFileStream << cmVS10EscapeXML(intermediateDir) << "</IntDir>\n"; + if (const char* sdkExecutableDirectories = this->Makefile->GetDefinition( + "CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES")) { + this->WritePlatformConfigTag("ExecutablePath", config, 2); + *this->BuildFileStream << cmVS10EscapeXML(sdkExecutableDirectories) + << "</ExecutablePath>\n"; + } + + if (const char* sdkIncludeDirectories = this->Makefile->GetDefinition( + "CMAKE_VS_SDK_INCLUDE_DIRECTORIES")) { + this->WritePlatformConfigTag("IncludePath", config, 2); + *this->BuildFileStream << cmVS10EscapeXML(sdkIncludeDirectories) + << "</IncludePath>\n"; + } + + if (const char* sdkReferenceDirectories = this->Makefile->GetDefinition( + "CMAKE_VS_SDK_REFERENCE_DIRECTORIES")) { + this->WritePlatformConfigTag("ReferencePath", config, 2); + *this->BuildFileStream << cmVS10EscapeXML(sdkReferenceDirectories) + << "</ReferencePath>\n"; + } + + if (const char* sdkLibraryDirectories = this->Makefile->GetDefinition( + "CMAKE_VS_SDK_LIBRARY_DIRECTORIES")) { + this->WritePlatformConfigTag("LibraryPath", config, 2); + *this->BuildFileStream << cmVS10EscapeXML(sdkLibraryDirectories) + << "</LibraryPath>\n"; + } + + if (const char* sdkLibraryWDirectories = this->Makefile->GetDefinition( + "CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES")) { + this->WritePlatformConfigTag("LibraryWPath", config, 2); + *this->BuildFileStream << cmVS10EscapeXML(sdkLibraryWDirectories) + << "</LibraryWPath>\n"; + } + + if (const char* sdkSourceDirectories = + this->Makefile->GetDefinition("CMAKE_VS_SDK_SOURCE_DIRECTORIES")) { + this->WritePlatformConfigTag("SourcePath", config, 2); + *this->BuildFileStream << cmVS10EscapeXML(sdkSourceDirectories) + << "</SourcePath>\n"; + } + + if (const char* sdkExcludeDirectories = this->Makefile->GetDefinition( + "CMAKE_VS_SDK_EXCLUDE_DIRECTORIES")) { + this->WritePlatformConfigTag("ExcludePath", config, 2); + *this->BuildFileStream << cmVS10EscapeXML(sdkExcludeDirectories) + << "</ExcludePath>\n"; + } + if (const char* workingDir = this->GeneratorTarget->GetProperty( "VS_DEBUGGER_WORKING_DIRECTORY")) { this->WritePlatformConfigTag("LocalDebuggerWorkingDirectory", config, diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index afe9d6d..359cdfb 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -7,3 +7,4 @@ run_cmake(VsDebuggerCommand) run_cmake(VsCSharpCustomTags) run_cmake(VsCSharpReferenceProps) run_cmake(VsCSharpWithoutSources) +run_cmake(VsSdkDirectories) diff --git a/Tests/RunCMake/VS10Project/VsSdkDirectories-check.cmake b/Tests/RunCMake/VS10Project/VsSdkDirectories-check.cmake new file mode 100644 index 0000000..c21afb6 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsSdkDirectories-check.cmake @@ -0,0 +1,88 @@ +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(ExecutablePathSet FALSE) +set(IncludePathSet FALSE) +set(ReferencePathSet FALSE) +set(LibraryPathSet FALSE) +set(LibraryWPathSet FALSE) +set(SourcePathSet FALSE) +set(ExcludePathSet FALSE) + +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<ExecutablePath[^>]*>([^<>]+)</ExecutablePath>$") + if("${CMAKE_MATCH_1}" STREQUAL "$(VC_ExecutablePath_x86);C:\\Program Files\\Custom-SDK\\;") + message(STATUS "foo.vcxproj has executable path set") + set(ExecutablePathSet TRUE) + endif() + elseif(line MATCHES "^ *<IncludePath[^>]*>([^<>]+)</IncludePath>$") + if("${CMAKE_MATCH_1}" STREQUAL "$(VC_IncludePath);C:\\Program Files\\Custom-SDK\\;") + message(STATUS "foo.vcxproj has include path set") + set(IncludePathSet TRUE) + endif() + elseif(line MATCHES "^ *<ReferencePath[^>]*>([^<>]+)</ReferencePath>$") + if("${CMAKE_MATCH_1}" STREQUAL "$(VC_ReferencesPath_x86);C:\\Program Files\\Custom-SDK\\;") + message(STATUS "foo.vcxproj has reference path set") + set(ReferencePathSet TRUE) + endif() + elseif(line MATCHES "^ *<LibraryPath[^>]*>([^<>]+)</LibraryPath>$") + if("${CMAKE_MATCH_1}" STREQUAL "$(VC_LibraryPath_x86);C:\\Program Files\\Custom-SDK\\;") + message(STATUS "foo.vcxproj has library path set") + set(LibraryPathSet TRUE) + endif() + elseif(line MATCHES "^ *<LibraryWPath[^>]*>([^<>]+)</LibraryWPath>$") + if("${CMAKE_MATCH_1}" STREQUAL "$(WindowsSDK_MetadataPath);C:\\Program Files\\Custom-SDK\\;") + message(STATUS "foo.vcxproj has library WinRT path set") + set(LibraryWPathSet TRUE) + endif() + elseif(line MATCHES "^ *<SourcePath[^>]*>([^<>]+)</SourcePath>$") + if("${CMAKE_MATCH_1}" STREQUAL "$(VC_SourcePath);C:\\Program Files\\Custom-SDK\\;") + message(STATUS "foo.vcxproj has source path set") + set(SourcePathSet TRUE) + endif() + elseif(line MATCHES "^ *<ExcludePath[^>]*>([^<>]+)</ExcludePath>$") + if("${CMAKE_MATCH_1}" STREQUAL "$(VC_IncludePath);C:\\Program Files\\Custom-SDK\\;") + message(STATUS "foo.vcxproj has exclude path set") + set(ExcludePathSet TRUE) + endif() + endif() +endforeach() + +if(NOT ExecutablePathSet) + set(RunCMake_TEST_FAILED "ExecutablePath not found or not set correctly.") + return() +endif() + +if(NOT IncludePathSet) + set(RunCMake_TEST_FAILED "IncludePath not found or not set correctly.") + return() +endif() + +if(NOT ReferencePathSet) + set(RunCMake_TEST_FAILED "ReferencePath not found or not set correctly.") + return() +endif() + +if(NOT LibraryPathSet) + set(RunCMake_TEST_FAILED "LibraryPath not found or not set correctly.") + return() +endif() + +if(NOT LibraryWPathSet) + set(RunCMake_TEST_FAILED "LibraryWPath not found or not set correctly.") + return() +endif() + +if(NOT SourcePathSet) + set(RunCMake_TEST_FAILED "SourcePath not found or not set correctly.") + return() +endif() + +if(NOT ExcludePathSet) + set(RunCMake_TEST_FAILED "ExcludePath not found or not set correctly.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsSdkDirectories.cmake b/Tests/RunCMake/VS10Project/VsSdkDirectories.cmake new file mode 100644 index 0000000..c8f2a5a --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsSdkDirectories.cmake @@ -0,0 +1,11 @@ +enable_language(CXX) + +set(CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES "$(VC_ExecutablePath_x86);C:\\Program Files\\Custom-SDK\\;") +set(CMAKE_VS_SDK_INCLUDE_DIRECTORIES "$(VC_IncludePath);C:\\Program Files\\Custom-SDK\\;") +set(CMAKE_VS_SDK_REFERENCE_DIRECTORIES "$(VC_ReferencesPath_x86);C:\\Program Files\\Custom-SDK\\;") +set(CMAKE_VS_SDK_LIBRARY_DIRECTORIES "$(VC_LibraryPath_x86);C:\\Program Files\\Custom-SDK\\;") +set(CMAKE_VS_SDK_LIBRARY_WINRT_DIRECTORIES "$(WindowsSDK_MetadataPath);C:\\Program Files\\Custom-SDK\\;") +set(CMAKE_VS_SDK_SOURCE_DIRECTORIES "$(VC_SourcePath);C:\\Program Files\\Custom-SDK\\;") +set(CMAKE_VS_SDK_EXCLUDE_DIRECTORIES "$(VC_IncludePath);C:\\Program Files\\Custom-SDK\\;") + +add_library(foo foo.cpp) |