From 6ec7ec20792c5a83bad99066447965baad59b831 Mon Sep 17 00:00:00 2001 From: David Cole Date: Wed, 30 Jul 2008 16:36:22 -0400 Subject: ENH: Add test for the new CPack BundleGenerator. Thanks to Tim Shead for the patch. See issue #7170 for more details. --- Tests/BundleGeneratorTest/BundleIcon.icns | Bin 0 -> 33452 bytes Tests/BundleGeneratorTest/CMakeLists.txt | 24 ++++++++++++++++++++++++ Tests/BundleGeneratorTest/Executable.cxx | 8 ++++++++ Tests/BundleGeneratorTest/Info.plist | 14 ++++++++++++++ Tests/BundleGeneratorTest/Library.cxx | 7 +++++++ Tests/BundleGeneratorTest/StartupCommand | 12 ++++++++++++ Tests/CMakeLists.txt | 13 +++++++++++++ 7 files changed, 78 insertions(+) create mode 100644 Tests/BundleGeneratorTest/BundleIcon.icns create mode 100644 Tests/BundleGeneratorTest/CMakeLists.txt create mode 100644 Tests/BundleGeneratorTest/Executable.cxx create mode 100644 Tests/BundleGeneratorTest/Info.plist create mode 100644 Tests/BundleGeneratorTest/Library.cxx create mode 100755 Tests/BundleGeneratorTest/StartupCommand diff --git a/Tests/BundleGeneratorTest/BundleIcon.icns b/Tests/BundleGeneratorTest/BundleIcon.icns new file mode 100644 index 0000000..8808dd6 Binary files /dev/null and b/Tests/BundleGeneratorTest/BundleIcon.icns differ diff --git a/Tests/BundleGeneratorTest/CMakeLists.txt b/Tests/BundleGeneratorTest/CMakeLists.txt new file mode 100644 index 0000000..e671d40 --- /dev/null +++ b/Tests/BundleGeneratorTest/CMakeLists.txt @@ -0,0 +1,24 @@ +PROJECT(BundleGeneratorTest) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.7) + +# Build a shared library and install it in lib/ +ADD_LIBRARY(Library SHARED Library.cxx) +INSTALL(TARGETS Library DESTINATION lib) + +# Build an executable and install it in bin/ +ADD_EXECUTABLE(Executable Executable.cxx) +TARGET_LINK_LIBRARIES(Executable Library) +INSTALL(TARGETS Executable DESTINATION bin) + +# Use the bundle-generator for packaging ... +SET(CPACK_GENERATOR "Bundle") +SET(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/BundleIcon.icns") +SET(CPACK_BUNDLE_NAME "BundleGeneratorTest") +SET(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist") +SET(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/StartupCommand") +SET(CPACK_PACKAGE_DESCRIPTION "Project for testing OSX bundle generation") +SET(CPACK_PACKAGE_NAME "BundleGeneratorTest") +SET(CPACK_PACKAGE_VERSION "0.1") +INCLUDE(CPack) + diff --git a/Tests/BundleGeneratorTest/Executable.cxx b/Tests/BundleGeneratorTest/Executable.cxx new file mode 100644 index 0000000..8107f78 --- /dev/null +++ b/Tests/BundleGeneratorTest/Executable.cxx @@ -0,0 +1,8 @@ +extern void print_message(const char* const Message); + +int main(int argc, char* argv[]) +{ + print_message("Howdy, World!\n"); + return 0; +} + diff --git a/Tests/BundleGeneratorTest/Info.plist b/Tests/BundleGeneratorTest/Info.plist new file mode 100644 index 0000000..e5a7d00 --- /dev/null +++ b/Tests/BundleGeneratorTest/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleExecutable + BundleGeneratorTest + CFBundleIconFile + BundleGeneratorTest.icns + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + + diff --git a/Tests/BundleGeneratorTest/Library.cxx b/Tests/BundleGeneratorTest/Library.cxx new file mode 100644 index 0000000..1403c68 --- /dev/null +++ b/Tests/BundleGeneratorTest/Library.cxx @@ -0,0 +1,7 @@ +#include + +void print_message(const char* const Message) +{ + std::cout << Message; +} + diff --git a/Tests/BundleGeneratorTest/StartupCommand b/Tests/BundleGeneratorTest/StartupCommand new file mode 100755 index 0000000..5bc5ad2 --- /dev/null +++ b/Tests/BundleGeneratorTest/StartupCommand @@ -0,0 +1,12 @@ +#!/bin/sh + +BUNDLE="`echo "$0" | sed -e 's/\/Contents\/MacOS\/.*//'`" +RESOURCES="$BUNDLE/Contents/Resources" + +echo "BUNDLE: $BUNDLE" +echo "RESOURCES: $RESOURCES" + +export DYLD_LIBRARY_PATH=$RESOURCES/lib + +exec "$RESOURCES/bin/Executable" + diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index f2601c8..d1ddb10 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -709,6 +709,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel ADD_TEST_MACRO(ObjC++ ObjC++) ENDIF (APPLE AND CMAKE_COMPILER_IS_GNUCXX) + IF(APPLE AND CTEST_TEST_CPACK) + ADD_TEST(BundleGeneratorTest ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/BundleGeneratorTest" + "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-target package + --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory" + ) + ENDIF(APPLE AND CTEST_TEST_CPACK) + IF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS) CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES) -- cgit v0.12