summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorFabian Otto <fabian.otto@rohde-schwarz.com>2016-02-25 21:04:05 (GMT)
committerBrad King <brad.king@kitware.com>2016-02-26 15:52:13 (GMT)
commit6122909c33bea1256867a40a09e0eafa569e8c8b (patch)
treef47eba39b8d9cd9cb8c522f44c32807e9ad13c57 /Tests/RunCMake
parent6b0a664c1639b19ccc652a4be5f9824d0bf88e48 (diff)
downloadCMake-6122909c33bea1256867a40a09e0eafa569e8c8b.zip
CMake-6122909c33bea1256867a40a09e0eafa569e8c8b.tar.gz
CMake-6122909c33bea1256867a40a09e0eafa569e8c8b.tar.bz2
VS: Add option to set `ConfigurationType` of a .vcxproj file
Add a VS_CONFIGURATION_TYPE target property to set this value explicitly. This is useful to build a Windows Kernel Mode Driver, for example.
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/VS10Project/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake24
-rw-r--r--Tests/RunCMake/VS10Project/VsConfigurationType.cmake3
-rw-r--r--Tests/RunCMake/VS10Project/foo.cpp1
6 files changed, 37 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 0a388c5..5bef629 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -236,6 +236,10 @@ if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]")
add_RunCMake_test(SolutionGlobalSections)
endif()
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^6789]|[6789][0-9])")
+ add_RunCMake_test(VS10Project)
+endif()
+
if(XCODE_VERSION AND NOT "${XCODE_VERSION}" VERSION_LESS 3)
add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION})
endif()
diff --git a/Tests/RunCMake/VS10Project/CMakeLists.txt b/Tests/RunCMake/VS10Project/CMakeLists.txt
new file mode 100644
index 0000000..91baae7
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.5.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
new file mode 100644
index 0000000..cc2cc2e
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -0,0 +1,2 @@
+include(RunCMake)
+run_cmake(VsConfigurationType)
diff --git a/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake b/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake
new file mode 100644
index 0000000..4690970
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsConfigurationType-check.cmake
@@ -0,0 +1,24 @@
+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(propertyFound FALSE)
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<ConfigurationType>(.*)</ConfigurationType>$")
+ set(propertyFound TRUE)
+ set(expectedValue "MyValue")
+ set(actualValue ${CMAKE_MATCH_1})
+ if(NOT (${actualValue} STREQUAL ${expectedValue}))
+ set(RunCMake_TEST_FAILED "ConfigurationType \"${actualValue}\" differs from expected value \"${expectedValue}\".")
+ return()
+ endif()
+ endif()
+endforeach()
+
+if(NOT propertyFound)
+ set(RunCMake_TEST_FAILED "Property ConfigurationType not found in project file.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsConfigurationType.cmake b/Tests/RunCMake/VS10Project/VsConfigurationType.cmake
new file mode 100644
index 0000000..a73dfe8
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsConfigurationType.cmake
@@ -0,0 +1,3 @@
+enable_language(CXX)
+add_library(foo foo.cpp)
+set_target_properties(foo PROPERTIES VS_CONFIGURATION_TYPE "MyValue")
diff --git a/Tests/RunCMake/VS10Project/foo.cpp b/Tests/RunCMake/VS10Project/foo.cpp
new file mode 100644
index 0000000..2fb55ee
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/foo.cpp
@@ -0,0 +1 @@
+void foo() { }