summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VS10Project
diff options
context:
space:
mode:
authorPetr Polezhaev <petr.polezhaev@larian.com>2019-12-12 10:50:52 (GMT)
committerPetr Polezhaev <petr.polezhaev@larian.com>2019-12-16 12:00:44 (GMT)
commit7bcef355bfa25e8d9d2dbc015b04831a7cf8c5a9 (patch)
treed10ee4fcb11f59d5e8a972e95949522d16e2f8f5 /Tests/RunCMake/VS10Project
parentb289544810e4417cff3e46228e3471457b0be0e4 (diff)
downloadCMake-7bcef355bfa25e8d9d2dbc015b04831a7cf8c5a9.zip
CMake-7bcef355bfa25e8d9d2dbc015b04831a7cf8c5a9.tar.gz
CMake-7bcef355bfa25e8d9d2dbc015b04831a7cf8c5a9.tar.bz2
Vs: Add test for VS_WINRT_BY_DEFAULT
Diffstat (limited to 'Tests/RunCMake/VS10Project')
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake66
-rw-r--r--Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake16
3 files changed, 86 insertions, 0 deletions
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index 1487161..5cbe333 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -1,3 +1,5 @@
+cmake_policy(SET CMP0057 NEW)
+
include(RunCMake)
cmake_policy(SET CMP0054 NEW)
@@ -29,6 +31,8 @@ run_cmake(VsDpiAwareBadParam)
run_cmake(VsPrecompileHeaders)
run_cmake(VsPrecompileHeadersReuseFromCompilePDBName)
+run_cmake(VsWinRTByDefault)
+
set(RunCMake_GENERATOR_TOOLSET "VCTargetsPath=$(VCTargetsPath)")
run_cmake(VsVCTargetsPath)
unset(RunCMake_GENERATOR_TOOLSET)
diff --git a/Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake b/Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake
new file mode 100644
index 0000000..d352946
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake
@@ -0,0 +1,66 @@
+macro(checkCompileAsWinRT projectPath)
+ if(RunCMake_TEST_FAILED)
+ return()
+ endif()
+
+ if (NOT EXISTS "${projectPath}")
+ set(RunCMake_TEST_FAILED "Project file ${projectPath} does not exist.")
+ return()
+ endif()
+
+ get_filename_component(projectName "${projectPath}" NAME_WE)
+
+ cmake_parse_arguments("" "" "GLOBAL" "OVERRIDES_ENABLE;OVERRIDES_DISABLE" ${ARGN})
+
+ unset(sourceOverride)
+
+ file(STRINGS "${projectPath}" lines)
+ set(foundGlobalWinRT false)
+
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<CompileAsWinRT( Condition=\"[^\\\"]+\")?>(true|false)</CompileAsWinRT>$")
+ set(value ${CMAKE_MATCH_2})
+
+ if(sourceOverride)
+ set(expectedList)
+
+ if(value)
+ set(expectedList _OVERRIDES_ENABLE)
+ else()
+ set(expectedList _OVERRIDES_DISABLE)
+ endif()
+
+ if(NOT sourceOverride IN_LIST ${expectedList})
+ set(RunCMake_TEST_FAILED
+ "${projectName}: Unexpected CompileAsWinRT override ${value} for ${sourceOverride}")
+ return()
+ endif()
+ else()
+ if (NOT _GLOBAL STREQUAL value)
+ set(RunCMake_TEST_FAILED
+ "${projectName}: Global CompileAsWinRT value is ${value}, but expected ${_GLOBAL}")
+ return()
+ endif()
+
+ set(foundGlobalWinRT true)
+ endif()
+ elseif(line MATCHES "^ *<ClCompile Include=\"([^\"]+)\">$")
+ get_filename_component(sourceOverride "${CMAKE_MATCH_1}" NAME)
+ elseif(line MATCHES "^ *</ClCompile>$")
+ unset(sourceOverride)
+ endif()
+ endforeach()
+
+ if(NOT foundGlobalWinRT AND DEFINED _GLOBAL)
+ set(RunCMake_TEST_FAILED "${projectName}: Global CompileAsWinRT not found or have invalid value, but expected")
+ return()
+ endif()
+endmacro()
+
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/noFlagOnlyC.vcxproj" GLOBAL true OVERRIDES_DISABLE empty.c)
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/noFlagMixedCAndCxx.vcxproj" GLOBAL true OVERRIDES_DISABLE empty.c)
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/noFlagOnlyCxx.vcxproj" GLOBAL true)
+
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/flagOnlyC.vcxproj" GLOBAL true OVERRIDES_DISABLE empty.c)
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/flagMixedCAndCxx.vcxproj" GLOBAL true OVERRIDES_DISABLE empty.c)
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/flagOnlyCxx.vcxproj" GLOBAL true)
diff --git a/Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake b/Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake
new file mode 100644
index 0000000..139048b
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake
@@ -0,0 +1,16 @@
+set(CMAKE_VS_WINRT_BY_DEFAULT true)
+
+enable_language(C)
+enable_language(CXX)
+
+add_library(noFlagOnlyC empty.c)
+add_library(noFlagMixedCAndCXX empty.c foo.cpp)
+add_library(noFlagOnlyCXX foo.cpp)
+
+add_library(flagOnlyC empty.c)
+add_library(flagMixedCAndCXX empty.c foo.cpp)
+add_library(flagOnlyCXX foo.cpp)
+
+target_compile_options(flagOnlyC PRIVATE /ZW)
+target_compile_options(flagMixedCAndCXX PRIVATE /ZW)
+target_compile_options(flagOnlyCXX PRIVATE /ZW)