diff options
author | Brad King <brad.king@kitware.com> | 2020-04-29 14:50:26 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-04-29 14:50:42 (GMT) |
commit | d63c442a6bcec287afb32a88c80b68cb141f49f4 (patch) | |
tree | 0434fc1cd2e3251e14a21287afba01563e52a0e3 /Tests | |
parent | 959acdc9e6af291b7f8c3ac530496322745385a2 (diff) | |
parent | 197b4cbe186cd31a490fc3cfcaace55bd7123829 (diff) | |
download | CMake-d63c442a6bcec287afb32a88c80b68cb141f49f4.zip CMake-d63c442a6bcec287afb32a88c80b68cb141f49f4.tar.gz CMake-d63c442a6bcec287afb32a88c80b68cb141f49f4.tar.bz2 |
Merge topic 'vs_platform_toolset'
197b4cbe18 VS: Add option for per-target PlatformToolset
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4682
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/VsPlatformToolset-check.cmake | 36 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/VsPlatformToolset.cmake | 6 |
3 files changed, 43 insertions, 0 deletions
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 5ccca01..06ccaae 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -33,6 +33,7 @@ run_cmake(VsPrecompileHeadersReuseFromCompilePDBName) run_cmake(VsDeployEnabled) run_cmake(VsSettings) run_cmake(VsSourceSettingsTool) +run_cmake(VsPlatformToolset) run_cmake(VsWinRTByDefault) diff --git a/Tests/RunCMake/VS10Project/VsPlatformToolset-check.cmake b/Tests/RunCMake/VS10Project/VsPlatformToolset-check.cmake new file mode 100644 index 0000000..416220b --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsPlatformToolset-check.cmake @@ -0,0 +1,36 @@ +macro(ReadPlatformToolset tgt outvar) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.") + return() + endif() + + set(HAVE_PlatformToolset 0) + + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<PlatformToolset>([^<>]+)</PlatformToolset>") + set(${outvar} "${CMAKE_MATCH_1}") + set(HAVE_PlatformToolset 1) + break() + endif() + endforeach() + + if(NOT HAVE_PlatformToolset) + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <PlatformToolset> field.") + return() + endif() +endmacro() + +ReadPlatformToolset(NormalPlatformToolset NORMAL_TOOLSET) +ReadPlatformToolset(OverridenPlatformToolset OVERRIDEN_TOOLSET) + +if (NOT "${OVERRIDEN_TOOLSET}" STREQUAL "MyCustomToolset") + set(RunCMake_TEST_FAILED "Failed to override the platform toolset") + return() +endif() + +if ("${NORMAL_TOOLSET}" STREQUAL "MyCustomToolset") + set(RunCMake_TEST_FAILED "Main toolset was overriden (it shouldn't)") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsPlatformToolset.cmake b/Tests/RunCMake/VS10Project/VsPlatformToolset.cmake new file mode 100644 index 0000000..dce9717 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsPlatformToolset.cmake @@ -0,0 +1,6 @@ +enable_language(CXX) + +add_library(NormalPlatformToolset foo.cpp) +add_library(OverridenPlatformToolset foo.cpp) +set_target_properties(OverridenPlatformToolset + PROPERTIES VS_PLATFORM_TOOLSET MyCustomToolset) |