summaryrefslogtreecommitdiff
path: root/Tests/VSExcludeFromDefaultBuild
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2013-08-13 07:48:01 -0400
committerAnas Nashif <anas.nashif@intel.com>2013-08-13 07:48:01 -0400
commit297c63fa65327491a2b50e521b661c5835a19fe4 (patch)
treecf30d58014e240eb5e4417727d8f137cdbe75828 /Tests/VSExcludeFromDefaultBuild
parentef8aa19c33e83ff019595fd7f8fdc29c35c336a3 (diff)
downloadcmake-297c63fa65327491a2b50e521b661c5835a19fe4.tar.gz
cmake-297c63fa65327491a2b50e521b661c5835a19fe4.tar.bz2
cmake-297c63fa65327491a2b50e521b661c5835a19fe4.zip
Imported Upstream version 2.8.11.2upstream/2.8.11.2sandbox/pcoval/previous/upstream
Diffstat (limited to 'Tests/VSExcludeFromDefaultBuild')
-rw-r--r--Tests/VSExcludeFromDefaultBuild/CMakeLists.txt32
-rw-r--r--Tests/VSExcludeFromDefaultBuild/ClearExes.cmake4
-rw-r--r--Tests/VSExcludeFromDefaultBuild/ResultTest.cmake23
-rw-r--r--Tests/VSExcludeFromDefaultBuild/main.c4
4 files changed, 63 insertions, 0 deletions
diff --git a/Tests/VSExcludeFromDefaultBuild/CMakeLists.txt b/Tests/VSExcludeFromDefaultBuild/CMakeLists.txt
new file mode 100644
index 000000000..d30414b4b
--- /dev/null
+++ b/Tests/VSExcludeFromDefaultBuild/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 2.8.9)
+project(VSExcludeFromDefaultBuild)
+
+# First step is to clear all .exe files in output so that possible past
+# failures of this test do not prevent it from succeeding.
+add_custom_target(ClearExes ALL
+ COMMAND "${CMAKE_COMMAND}"
+ -Ddir=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/ClearExes.cmake
+ VERBATIM)
+
+# Make sure ClearExes is executed before other targets are built
+function(add_test_executable target)
+ add_executable("${target}" ${ARGN})
+ add_dependencies("${target}" ClearExes)
+endfunction()
+
+add_test_executable(DefaultBuilt main.c)
+
+add_test_executable(AlwaysBuilt main.c)
+set_target_properties(AlwaysBuilt PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD FALSE)
+
+add_test_executable(NeverBuilt main.c)
+set_target_properties(NeverBuilt PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE)
+
+foreach(config ${CMAKE_CONFIGURATION_TYPES})
+ string(TOUPPER ${config} Config)
+ add_test_executable(BuiltIn${config} main.c)
+ set_target_properties(BuiltIn${config} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD TRUE EXCLUDE_FROM_DEFAULT_BUILD_${Config} FALSE)
+ add_test_executable(ExcludedIn${config} main.c)
+ set_target_properties(ExcludedIn${config} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_${Config} TRUE)
+endforeach()
diff --git a/Tests/VSExcludeFromDefaultBuild/ClearExes.cmake b/Tests/VSExcludeFromDefaultBuild/ClearExes.cmake
new file mode 100644
index 000000000..ece30ad00
--- /dev/null
+++ b/Tests/VSExcludeFromDefaultBuild/ClearExes.cmake
@@ -0,0 +1,4 @@
+file(GLOB exeFiles "${dir}/*.exe")
+foreach(exeFile IN LISTS exeFiles)
+ file(REMOVE "${exeFile}")
+endforeach()
diff --git a/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake b/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake
new file mode 100644
index 000000000..8fb00bfad
--- /dev/null
+++ b/Tests/VSExcludeFromDefaultBuild/ResultTest.cmake
@@ -0,0 +1,23 @@
+message(STATUS "Testing configuration ${activeConfig}.")
+
+macro(TestExists exeName)
+ set(exeFile "${dir}/${activeConfig}/${exeName}.exe")
+ if(${ARGN} EXISTS "${exeFile}")
+ message(STATUS "File ${exeFile} was correctly found ${ARGN} to exist.")
+ else()
+ message(FATAL_ERROR "File ${exeFile} was expected ${ARGN} to exist!")
+ endif()
+endmacro()
+
+TestExists(DefaultBuilt)
+TestExists(AlwaysBuilt)
+TestExists(NeverBuilt NOT)
+foreach(config ${allConfigs})
+ if(config STREQUAL activeConfig)
+ TestExists(BuiltIn${config})
+ TestExists(ExcludedIn${config} NOT)
+ else()
+ TestExists(BuiltIn${config} NOT)
+ TestExists(ExcludedIn${config})
+ endif()
+endforeach()
diff --git a/Tests/VSExcludeFromDefaultBuild/main.c b/Tests/VSExcludeFromDefaultBuild/main.c
new file mode 100644
index 000000000..8488f4e58
--- /dev/null
+++ b/Tests/VSExcludeFromDefaultBuild/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}