summaryrefslogtreecommitdiffstats
path: root/Tests/MissingInstall
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2013-12-25 16:59:24 (GMT)
committerNils Gladitz <nilsgladitz@gmail.com>2014-01-08 15:28:14 (GMT)
commitbe0458c5620d611a772fd3a25312cf5ae6cb492c (patch)
treea026c5ba04bd2404ce29ae77b22485a865f92bd2 /Tests/MissingInstall
parentb87ce492ab4600091262593499095ea5db1ae0ca (diff)
downloadCMake-be0458c5620d611a772fd3a25312cf5ae6cb492c.zip
CMake-be0458c5620d611a772fd3a25312cf5ae6cb492c.tar.gz
CMake-be0458c5620d611a772fd3a25312cf5ae6cb492c.tar.bz2
InstallRules: added new variable to disable generation of install rules
The boolean variable CMAKE_SKIP_INSTALL_RULES allows disabling generation of install rules for projects which don't want them.
Diffstat (limited to 'Tests/MissingInstall')
-rw-r--r--Tests/MissingInstall/CMakeLists.txt25
-rw-r--r--Tests/MissingInstall/ExpectInstallFail.cmake18
-rw-r--r--Tests/MissingInstall/mybin.cpp1
3 files changed, 44 insertions, 0 deletions
diff --git a/Tests/MissingInstall/CMakeLists.txt b/Tests/MissingInstall/CMakeLists.txt
new file mode 100644
index 0000000..91624f7
--- /dev/null
+++ b/Tests/MissingInstall/CMakeLists.txt
@@ -0,0 +1,25 @@
+cmake_minimum_required (VERSION 2.8.12)
+project(TestMissingInstall)
+
+set(CMAKE_SKIP_INSTALL_RULES ON)
+
+# Skip the dependency that causes a build when installing. This
+# avoids infinite loops when the post-build rule below installs.
+set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY 1)
+set(CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY 1)
+
+if(CMAKE_CONFIGURATION_TYPES)
+ set(MULTI_CONFIG ON)
+else()
+ set(MULTI_CONFIG OFF)
+endif()
+
+add_executable(mybin mybin.cpp)
+install(TARGETS mybin RUNTIME DESTINATION bin)
+
+add_custom_command(TARGET mybin
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} "-DMULTI_CONFIG=${MULTI_CONFIG}"
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/ExpectInstallFail.cmake
+ COMMENT "Install Project"
+)
diff --git a/Tests/MissingInstall/ExpectInstallFail.cmake b/Tests/MissingInstall/ExpectInstallFail.cmake
new file mode 100644
index 0000000..3d677bf
--- /dev/null
+++ b/Tests/MissingInstall/ExpectInstallFail.cmake
@@ -0,0 +1,18 @@
+if(MULTI_CONFIG)
+ set(SI_CONFIG --config $<CONFIGURATION>)
+else()
+ set(SI_CONFIG)
+endif()
+
+execute_process(
+ COMMAND ${CMAKE_COMMAND}
+ --build .
+ --target install ${SI_CONFIG}
+ RESULT_VARIABLE RESULT
+ OUTPUT_VARIABLE OUTPUT
+ ERROR_VARIABLE ERROR
+)
+
+if(RESULT EQUAL 0)
+ message(FATAL_ERROR "install should have failed")
+endif()
diff --git a/Tests/MissingInstall/mybin.cpp b/Tests/MissingInstall/mybin.cpp
new file mode 100644
index 0000000..237c8ce
--- /dev/null
+++ b/Tests/MissingInstall/mybin.cpp
@@ -0,0 +1 @@
+int main() {}