summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VS10Project
diff options
context:
space:
mode:
authorAlexander Boczar <alexboc@microsoft.com>2019-09-16 21:14:20 (GMT)
committerBrad King <brad.king@kitware.com>2019-10-15 17:28:45 (GMT)
commit548e9051a4f20657d04341107924171ea9d1bcb5 (patch)
tree4b7aba7800a6a193396aabf4ab4259029db9ec35 /Tests/RunCMake/VS10Project
parent99e83d423500e11a8e85c2032e8c536bce175ed1 (diff)
downloadCMake-548e9051a4f20657d04341107924171ea9d1bcb5.zip
CMake-548e9051a4f20657d04341107924171ea9d1bcb5.tar.gz
CMake-548e9051a4f20657d04341107924171ea9d1bcb5.tar.bz2
VS: Add support to override VCTargetsPath through toolset
Fixes: #19708
Diffstat (limited to 'Tests/RunCMake/VS10Project')
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/VS10Project/VsVCTargetsPath-check.cmake32
-rw-r--r--Tests/RunCMake/VS10Project/VsVCTargetsPath.cmake3
3 files changed, 39 insertions, 0 deletions
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index 44ccd6b..32b6829 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -28,6 +28,10 @@ run_cmake(VsDpiAwareBadParam)
run_cmake(VsPrecompileHeaders)
run_cmake(VsPrecompileHeadersReuseFromCompilePDBName)
+set(RunCMake_GENERATOR_TOOLSET "VCTargetsPath=$(VCTargetsPath)")
+run_cmake(VsVCTargetsPath)
+unset(RunCMake_GENERATOR_TOOLSET)
+
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05)
run_cmake(VsJustMyCode)
endif()
diff --git a/Tests/RunCMake/VS10Project/VsVCTargetsPath-check.cmake b/Tests/RunCMake/VS10Project/VsVCTargetsPath-check.cmake
new file mode 100644
index 0000000..5b1701c
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsVCTargetsPath-check.cmake
@@ -0,0 +1,32 @@
+macro(check_project_file projectFile)
+ set(insideGlobals FALSE)
+ set(pathFound FALSE)
+
+ if(NOT EXISTS "${projectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${projectFile} does not exist.")
+ return()
+ endif()
+
+ string(REPLACE "${RunCMake_TEST_BINARY_DIR}/" "" projectName ${projectFile})
+
+ file(STRINGS "${projectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<PropertyGroup Label=\"Globals\">.*$")
+ set(insideGlobals TRUE)
+ elseif(insideGlobals)
+ if(line MATCHES "^ *</PropertyGroup>.*$")
+ set(insideGlobals FALSE)
+ elseif(line MATCHES "^ *<VCTargetsPath>(.+)</VCTargetsPath>*$")
+ message(STATUS "Found VCTargetsPath = ${CMAKE_MATCH_1} in PropertyGroup 'Globals' in ${projectName}")
+ set(pathFound TRUE)
+ endif()
+ endif()
+ endforeach()
+ if(NOT pathFound)
+ set(RunCMake_TEST_FAILED "VCTargetsPath not found in \"Globals\" propertygroup in ${projectName}")
+ return() # This should intentionally return from the caller, not the macro
+ endif()
+endmacro()
+
+check_project_file("${RunCMake_TEST_BINARY_DIR}/CMakeFiles/${CMAKE_VERSION}/CompilerIdCXX/CompilerIdCXX.vcxproj")
+check_project_file("${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
diff --git a/Tests/RunCMake/VS10Project/VsVCTargetsPath.cmake b/Tests/RunCMake/VS10Project/VsVCTargetsPath.cmake
new file mode 100644
index 0000000..6a6088f
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsVCTargetsPath.cmake
@@ -0,0 +1,3 @@
+enable_language(CXX)
+
+add_library(foo foo.cpp)