summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt45
-rw-r--r--Tests/CPackComponents/CMakeLists.txt92
-rw-r--r--Tests/CPackComponents/VerifyResult.cmake48
-rw-r--r--Tests/CPackComponents/mylib.cpp7
-rw-r--r--Tests/CPackComponents/mylib.h1
-rw-r--r--Tests/CPackComponents/mylibapp.cpp6
-rw-r--r--Tests/SimpleInstall/CMakeLists.txt26
-rw-r--r--Tests/SimpleInstallS2/CMakeLists.txt26
8 files changed, 208 insertions, 43 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 03d50fb..74bbc07 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -19,7 +19,7 @@ IF(BUILD_TESTING)
OPTION(CMAKE_RUN_LONG_TESTS
"Should the long tests be run (such as Bootstrap)." ON)
MARK_AS_ADVANCED(CMAKE_RUN_LONG_TESTS)
-
+
IF (CMAKE_RUN_LONG_TESTS)
OPTION(CTEST_TEST_CTEST
"Should the tests that run a full sub ctest process be run?"
@@ -27,6 +27,34 @@ IF(BUILD_TESTING)
MARK_AS_ADVANCED(CTEST_TEST_CTEST)
ENDIF (CMAKE_RUN_LONG_TESTS)
+ # Should CPack tests be run? By default, yes, but...
+ #
+ # Disable packaging test on Apple 10.3 and below. PackageMaker starts
+ # DiskManagementTool as root and disowns it
+ # (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html).
+ # It is left holding open pipe handles and preventing ProcessUNIX from
+ # detecting end-of-data even after its immediate child exits. Then
+ # the test hangs until it times out and is killed. This is a
+ # well-known bug in kwsys process execution that I would love to get
+ # time to fix.
+ #
+ OPTION(CTEST_TEST_CPACK
+ "Should the tests that use '--build-target package' be run?"
+ ON)
+ MARK_AS_ADVANCED(CTEST_TEST_CPACK)
+ IF(APPLE AND CTEST_TEST_CPACK)
+ EXECUTE_PROCESS(
+ COMMAND sw_vers -productVersion
+ OUTPUT_VARIABLE OSX_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ IF(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]")
+ MESSAGE(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4")
+ MESSAGE(STATUS "OSX_VERSION='${OSX_VERSION}'")
+ SET(CTEST_TEST_CPACK OFF)
+ ENDIF(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]")
+ ENDIF(APPLE AND CTEST_TEST_CPACK)
+
# Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value,
# whichever is greater.
SET(CMAKE_LONG_TEST_TIMEOUT 1500)
@@ -259,6 +287,21 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel
"-DSTAGE2:BOOL=1"
--test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2)
+ IF(CTEST_TEST_CPACK)
+ ADD_TEST(CPackComponents ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/CPackComponents"
+ "${CMake_BINARY_DIR}/Tests/CPackComponents"
+ --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-project CPackComponents
+ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-two-config
+ --build-target package
+ --test-command ${CMAKE_CMAKE_COMMAND}
+ "-DCPackComponents_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponents"
+ -P "${CMake_SOURCE_DIR}/Tests/CPackComponents/VerifyResult.cmake")
+ ENDIF(CTEST_TEST_CPACK)
+
ADD_TEST(X11 ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/X11"
diff --git a/Tests/CPackComponents/CMakeLists.txt b/Tests/CPackComponents/CMakeLists.txt
new file mode 100644
index 0000000..e52eaa8
--- /dev/null
+++ b/Tests/CPackComponents/CMakeLists.txt
@@ -0,0 +1,92 @@
+# CPack Example: User-selectable Installation Components
+#
+# In this example, we have a simple library (mylib) with an example
+# application (mylibapp). We create a binary installer that allows
+# users to select which pieces will be installed: the example
+# application, the library binaries, and/or the header file.
+cmake_minimum_required(VERSION 2.6)
+project(CPackComponents)
+
+# Create the mylib library
+add_library(mylib mylib.cpp)
+
+# Create the mylibapp application
+add_executable(mylibapp mylibapp.cpp)
+target_link_libraries(mylibapp mylib)
+
+# Create installation targets. Note that we put each kind of file
+# into a different component via COMPONENT. These components will
+# be used to create the installation components.
+install(TARGETS mylib
+ ARCHIVE
+ DESTINATION lib
+ COMPONENT libraries)
+install(TARGETS mylibapp
+ RUNTIME
+ DESTINATION bin
+ COMPONENT applications)
+install(FILES mylib.h
+ DESTINATION include
+ COMPONENT headers)
+
+# CPack boilerplate for this project
+set(CPACK_PACKAGE_NAME "MyLib")
+set(CPACK_PACKAGE_VENDOR "CMake.org")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyLib - CPack Component Installation Example")
+set(CPACK_PACKAGE_VERSION "1.0.0")
+set(CPACK_PACKAGE_VERSION_MAJOR "1")
+set(CPACK_PACKAGE_VERSION_MINOR "0")
+set(CPACK_PACKAGE_VERSION_PATCH "0")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")
+
+# Tell CPack all of the components to install. The "ALL"
+# refers to the fact that this is the set of components that
+# will be included when CPack is instructed to put everything
+# into the binary installer (the default behavior).
+set(CPACK_COMPONENTS_ALL applications libraries headers)
+
+# Set the displayed names for each of the components to install.
+# These will be displayed in the list of components inside the installer.
+set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "MyLib Application")
+set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
+set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers")
+
+# Provide descriptions for each of the components to install.
+# When the user hovers the mouse over the name of a component,
+# the description will be shown in the "Description" box in the
+# installer. If no descriptions are provided, the "Description"
+# box will be removed.
+set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
+ "An extremely useful application that makes use of MyLib")
+set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
+ "Static libraries used to build programs with MyLib")
+set(CPACK_COMPONENT_HEADERS_DESCRIPTION
+ "C/C++ header files for use with MyLib")
+
+# Put the components into two different groups: "Runtime" and "Development"
+set(CPACK_COMPONENT_APPLICATIONS_GROUP "Runtime")
+set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
+set(CPACK_COMPONENT_HEADERS_GROUP "Development")
+
+# Expand the "Development" group by default, since we have so few components.
+# Also, provide this group with a description.
+set(CPACK_COMPONENT_GROUP_DEVELOPMENT_EXPANDED ON)
+set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
+ "All of the tools you'll ever need to develop software")
+
+# It doesn't make sense to install the headers without the libraries
+# (because you could never use the headers!), so make the headers component
+# depend on the libraries component.
+set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
+
+# Create two installation types with pre-selected components.
+# The "Developer" installation has just the library and headers,
+# while the "Full" installation has everything.
+set(CPACK_ALL_INSTALL_TYPES Full Developer)
+set(CPACK_INSTALL_TYPE_FULL_DISPLAY_NAME "Everything")
+set(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES Developer Full)
+set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
+set(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full)
+
+# Include CPack to introduce the appropriate targets
+include(CPack)
diff --git a/Tests/CPackComponents/VerifyResult.cmake b/Tests/CPackComponents/VerifyResult.cmake
new file mode 100644
index 0000000..3e64a46
--- /dev/null
+++ b/Tests/CPackComponents/VerifyResult.cmake
@@ -0,0 +1,48 @@
+message(STATUS "=============================================================================")
+message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
+message(STATUS "")
+
+if(NOT CPackComponents_BINARY_DIR)
+ message(FATAL_ERROR "CPackComponents_BINARY_DIR not set")
+endif(NOT CPackComponents_BINARY_DIR)
+
+set(expected_file_mask "")
+
+if(WIN32)
+ # Only expect the *.exe installer if it looks like NSIS is
+ # installed on this machine:
+ #
+ find_program(NSIS_MAKENSIS_EXECUTABLE NAMES makensis
+ PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS]
+ DOC "makensis.exe location"
+ )
+ if(NSIS_MAKENSIS_EXECUTABLE)
+ set(expected_file_mask "${CPackComponents_BINARY_DIR}/*.exe")
+ endif(NSIS_MAKENSIS_EXECUTABLE)
+endif(WIN32)
+
+if(APPLE)
+ # Always expect the *.dmg installer - PackageMaker should always
+ # be installed on a development Mac:
+ #
+ set(expected_file_mask "${CPackComponents_BINARY_DIR}/*.dmg")
+endif(APPLE)
+
+if(expected_file_mask)
+ set(expected_count 1)
+ file(GLOB expected_file "${expected_file_mask}")
+
+ message(STATUS "expected_count='${expected_count}'")
+ message(STATUS "expected_file='${expected_file}'")
+ message(STATUS "expected_file_mask='${expected_file_mask}'")
+
+ if(NOT expected_file)
+ message(FATAL_ERROR "error: expected_file does not exist: CPackComponents test fails.")
+ endif(NOT expected_file)
+
+ list(LENGTH expected_file actual_count)
+ message(STATUS "actual_count='${actual_count}'")
+ if(NOT actual_count EQUAL expected_count)
+ message(FATAL_ERROR "error: expected_count does not match actual_count: CPackComponents test fails.")
+ endif(NOT actual_count EQUAL expected_count)
+endif(expected_file_mask)
diff --git a/Tests/CPackComponents/mylib.cpp b/Tests/CPackComponents/mylib.cpp
new file mode 100644
index 0000000..8ddac19
--- /dev/null
+++ b/Tests/CPackComponents/mylib.cpp
@@ -0,0 +1,7 @@
+#include "mylib.h"
+#include "stdio.h"
+
+void mylib_function()
+{
+ printf("This is mylib");
+}
diff --git a/Tests/CPackComponents/mylib.h b/Tests/CPackComponents/mylib.h
new file mode 100644
index 0000000..5d0a822
--- /dev/null
+++ b/Tests/CPackComponents/mylib.h
@@ -0,0 +1 @@
+void mylib_function();
diff --git a/Tests/CPackComponents/mylibapp.cpp b/Tests/CPackComponents/mylibapp.cpp
new file mode 100644
index 0000000..a438ac7
--- /dev/null
+++ b/Tests/CPackComponents/mylibapp.cpp
@@ -0,0 +1,6 @@
+#include "mylib.h"
+
+int main()
+{
+ mylib_function();
+}
diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt
index 23d3d27..34914b6 100644
--- a/Tests/SimpleInstall/CMakeLists.txt
+++ b/Tests/SimpleInstall/CMakeLists.txt
@@ -355,27 +355,11 @@ SET(CMAKE_INSTALL_DEBUG_LIBRARIES 1)
INCLUDE(InstallRequiredSystemLibraries)
INCLUDE(CPack)
-# Disable packaging test on Apple 10.3 and below. PackageMaker starts
-# DiskManagementTool as root and disowns it
-# (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html).
-# It is left holding open pipe handles and preventing ProcessUNIX from
-# detecting end-of-data even after its immediate child exits. Then
-# the test hangs until it times out and is killed. This is a
-# well-known bug in kwsys process execution that I would love to get
-# time to fix.
-SET(PACKAGE_TARGET --build-target package)
-IF(APPLE AND NOT CTEST_TEST_CPACK)
- EXECUTE_PROCESS(
- COMMAND sw_vers -productVersion
- OUTPUT_VARIABLE OSX_VERSION
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- IF("${OSX_VERSION}" MATCHES "^10\\.[0123]" OR "${OSX_VERSION}" MATCHES "ProductVersion:\t10\\.[0123]")
- MESSAGE(STATUS "Disabling package test on OSX < 10.4")
- MESSAGE(STATUS "OSX_VERSION='${OSX_VERSION}'")
- SET(PACKAGE_TARGET)
- ENDIF("${OSX_VERSION}" MATCHES "^10\\.[0123]" OR "${OSX_VERSION}" MATCHES "ProductVersion:\t10\\.[0123]")
-ENDIF(APPLE AND NOT CTEST_TEST_CPACK)
+IF(CTEST_TEST_CPACK)
+ SET(PACKAGE_TARGET --build-target package)
+ELSE(CTEST_TEST_CPACK)
+ SET(PACKAGE_TARGET)
+ENDIF(CTEST_TEST_CPACK)
ADD_CUSTOM_COMMAND(
TARGET ${install_target}
diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt
index 23d3d27..34914b6 100644
--- a/Tests/SimpleInstallS2/CMakeLists.txt
+++ b/Tests/SimpleInstallS2/CMakeLists.txt
@@ -355,27 +355,11 @@ SET(CMAKE_INSTALL_DEBUG_LIBRARIES 1)
INCLUDE(InstallRequiredSystemLibraries)
INCLUDE(CPack)
-# Disable packaging test on Apple 10.3 and below. PackageMaker starts
-# DiskManagementTool as root and disowns it
-# (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html).
-# It is left holding open pipe handles and preventing ProcessUNIX from
-# detecting end-of-data even after its immediate child exits. Then
-# the test hangs until it times out and is killed. This is a
-# well-known bug in kwsys process execution that I would love to get
-# time to fix.
-SET(PACKAGE_TARGET --build-target package)
-IF(APPLE AND NOT CTEST_TEST_CPACK)
- EXECUTE_PROCESS(
- COMMAND sw_vers -productVersion
- OUTPUT_VARIABLE OSX_VERSION
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- IF("${OSX_VERSION}" MATCHES "^10\\.[0123]" OR "${OSX_VERSION}" MATCHES "ProductVersion:\t10\\.[0123]")
- MESSAGE(STATUS "Disabling package test on OSX < 10.4")
- MESSAGE(STATUS "OSX_VERSION='${OSX_VERSION}'")
- SET(PACKAGE_TARGET)
- ENDIF("${OSX_VERSION}" MATCHES "^10\\.[0123]" OR "${OSX_VERSION}" MATCHES "ProductVersion:\t10\\.[0123]")
-ENDIF(APPLE AND NOT CTEST_TEST_CPACK)
+IF(CTEST_TEST_CPACK)
+ SET(PACKAGE_TARGET --build-target package)
+ELSE(CTEST_TEST_CPACK)
+ SET(PACKAGE_TARGET)
+ENDIF(CTEST_TEST_CPACK)
ADD_CUSTOM_COMMAND(
TARGET ${install_target}