summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VS10Project
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-10-18 13:01:36 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-10-18 13:01:48 (GMT)
commitb34b4c5eac27bfc4a1e46f2b46ba17f5be6a8565 (patch)
treecca98eb61f39604776d35cf96dc78872246a8f8b /Tests/RunCMake/VS10Project
parentc867981c9d9bc8548d34f726940cd50b8d05d71c (diff)
parente7d57bc3c35e7c47746caf91591ef748b9ce3012 (diff)
downloadCMake-b34b4c5eac27bfc4a1e46f2b46ba17f5be6a8565.zip
CMake-b34b4c5eac27bfc4a1e46f2b46ba17f5be6a8565.tar.gz
CMake-b34b4c5eac27bfc4a1e46f2b46ba17f5be6a8565.tar.bz2
Merge topic 'vs-vctargetspath'
e7d57bc3c3 VS: Propagate CMAKE_VS_GLOBALS into custom targets 45b4b4b930 VS: Propagate CMAKE_VS_GLOBALS into compiler id projects 548e9051a4 VS: Add support to override VCTargetsPath through toolset 99e83d4235 cmake: Teach --build mode to load CMAKE_GENERATOR_TOOLSET Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3817
Diffstat (limited to 'Tests/RunCMake/VS10Project')
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/VS10Project/VsGlobals-check.cmake93
-rw-r--r--Tests/RunCMake/VS10Project/VsGlobals.cmake7
-rw-r--r--Tests/RunCMake/VS10Project/VsVCTargetsPath-check.cmake32
-rw-r--r--Tests/RunCMake/VS10Project/VsVCTargetsPath.cmake3
5 files changed, 100 insertions, 39 deletions
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index ebc4d1c..1487161 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -29,6 +29,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/VsGlobals-check.cmake b/Tests/RunCMake/VS10Project/VsGlobals-check.cmake
index 0e7fd45..6a30099 100644
--- a/Tests/RunCMake/VS10Project/VsGlobals-check.cmake
+++ b/Tests/RunCMake/VS10Project/VsGlobals-check.cmake
@@ -1,44 +1,65 @@
-set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
-if(NOT EXISTS "${vcProjectFile}")
- set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
- return()
-endif()
+macro(check_project_file projectFile)
+ if(NOT EXISTS "${projectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${projectFile} does not exist.")
+ return()
+ endif()
+
+ string(REPLACE "${RunCMake_TEST_BINARY_DIR}/" "" projectName ${projectFile})
-set(InsideGlobals FALSE)
-set(DefaultLanguageSet FALSE)
-set(MinimumVisualStudioVersionSet FALSE)
+ set(InsideGlobals FALSE)
+ set(DefaultLanguageSet FALSE)
+ set(MinimumVisualStudioVersionSet FALSE)
+ set(TestPropertySet FALSE)
-file(STRINGS "${vcProjectFile}" lines)
-foreach(line IN LISTS lines)
- if(line MATCHES "^ *<PropertyGroup Label=\"Globals\"> *$")
- set(InsideGlobals TRUE)
- elseif(line MATCHES "^ *<DefaultLanguage>([a-zA-Z\\-]+)</DefaultLanguage> *$")
- if("${CMAKE_MATCH_1}" STREQUAL "en-US")
- if(InsideGlobals)
- message(STATUS "foo.vcxproj has correct DefaultLanguage global property")
- set(DefaultLanguageSet TRUE)
- else()
- message(STATUS "DefaultLanguage is set but not within \"Globals\" property group")
+ file(STRINGS "${projectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<PropertyGroup Label=\"Globals\"> *$")
+ set(InsideGlobals TRUE)
+ elseif(line MATCHES "^ *<DefaultLanguage>([a-zA-Z\\-]+)</DefaultLanguage> *$")
+ if("${CMAKE_MATCH_1}" STREQUAL "en-US")
+ if(InsideGlobals)
+ message(STATUS "${projectName} has correct DefaultLanguage global property")
+ set(DefaultLanguageSet TRUE)
+ else()
+ message(STATUS "DefaultLanguage is set but not within \"Globals\" property group")
+ endif()
endif()
- endif()
- elseif(line MATCHES "^ *<MinimumVisualStudioVersion>([0-9\\.]+)</MinimumVisualStudioVersion> *$")
- if("${CMAKE_MATCH_1}" STREQUAL "14.0")
- if(InsideGlobals)
- message(STATUS "foo.vcxproj has correct MinimumVisualStudioVersion global property")
- set(MinimumVisualStudioVersionSet TRUE)
- else()
- message(STATUS "MinimumVisualStudioVersion is set but not within \"Globals\" property group")
+ elseif(line MATCHES "^ *<MinimumVisualStudioVersion>([0-9\\.]+)</MinimumVisualStudioVersion> *$")
+ if("${CMAKE_MATCH_1}" STREQUAL "10.0")
+ if(InsideGlobals)
+ message(STATUS "${projectName} has correct MinimumVisualStudioVersion global property")
+ set(MinimumVisualStudioVersionSet TRUE)
+ else()
+ message(STATUS "MinimumVisualStudioVersion is set but not within \"Globals\" property group")
+ endif()
+ endif()
+ elseif(line MATCHES "^ *<TestProperty>(.+)</TestProperty> *$")
+ if("${CMAKE_MATCH_1}" STREQUAL "TestValue")
+ if(InsideGlobals)
+ message(STATUS "${projectName} has correct TestProperty global property")
+ set(TestPropertySet TRUE)
+ else()
+ message(STATUS "TestProperty is set but not within \"Globals\" property group")
+ endif()
endif()
endif()
+ endforeach()
+
+ if(NOT DefaultLanguageSet)
+ set(RunCMake_TEST_FAILED "DefaultLanguage not found or not set correctly in ${projectName}.")
+ return()
+ endif()
+
+ if(NOT MinimumVisualStudioVersionSet)
+ set(RunCMake_TEST_FAILED "MinimumVisualStudioVersion not found or not set correctly in ${projectName}.")
+ return()
endif()
-endforeach()
-if(NOT DefaultLanguageSet)
- set(RunCMake_TEST_FAILED "DefaultLanguageSet not found or not set correctly.")
- return()
-endif()
+ if(NOT TestPropertySet)
+ set(RunCMake_TEST_FAILED "TestProperty not found or not set correctly in ${projectName}.")
+ return()
+ endif()
+endmacro()
-if(NOT MinimumVisualStudioVersionSet)
- set(RunCMake_TEST_FAILED "MinimumVisualStudioVersionSet not found or not set correctly.")
- return()
-endif()
+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/VsGlobals.cmake b/Tests/RunCMake/VS10Project/VsGlobals.cmake
index a3ed5af..09d806d 100644
--- a/Tests/RunCMake/VS10Project/VsGlobals.cmake
+++ b/Tests/RunCMake/VS10Project/VsGlobals.cmake
@@ -1,8 +1,9 @@
-enable_language(CXX)
-
set(CMAKE_VS_GLOBALS
"DefaultLanguage=en-US"
- "MinimumVisualStudioVersion=14.0"
+ "MinimumVisualStudioVersion=10.0"
+ "TestProperty=TestValue"
)
+enable_language(CXX)
+
add_library(foo foo.cpp)
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)