From d5ac0b43081dec10bb116a5e98c2264197b3281f Mon Sep 17 00:00:00 2001 From: nschimme Date: Sun, 14 Jun 2009 21:24:45 +0000 Subject: [PATCH] More Mac OS X bundle support for CMake/CPack git-svn-id: svn://svn.code.sf.net/p/mmapper/code/trunk/mmapper@164 14c008a5-6e10-0410-bf79-c100e0f1932b --- CMakeLists.txt | 22 ++++++++++++++++++---- build.sh | 2 +- src/CMakeLists.txt | 39 +++++++++++++++++++++++++++++++++------ 3 files changed, 52 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7b1f1077..1b1063760 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,9 @@ else (NOT MINGW) message(STATUS "Warning: MingW requires zlib to be installed manually") endif (NOT MINGW) +# Version +set(VERSION "2.0.4-final2") + # Get SVN revision number find_package(Subversion) if (Subversion_FOUND) @@ -36,10 +39,21 @@ if (UNIX) endif (UNIX) if (APPLE) - # In order to build a universal binary we need the following two lines: - add_definitions(-DCMAKE_OSX_SYSROOT="/Developer/SDKs/MacOSX10.4u.sdk") - add_definitions(-DCMAKE_OSX_ARCHITECTURES="ppc;i386") - message(STATUS "Warning: For deployment you should have compiled Qt statically") + # This is bundle metadata to create "bundles" and "Universal Binaries" on + # Mac OS X + # http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_build_universal_binaries_on_Mac_OS_X.3F + # By the way, there is a bug in the cross-compilation SDKs for + # Tiger in Leopard, so you need to follow these instructions: + # http://groups.google.com/group/vim_mac/browse_thread/thread/064da55ec412e768 + # which means typing the following command in Terminal.app: + # $ sudo ln -s /Developer/SDKs/MacOSX10.4u.sdk/usr/lib/crt1.o /Developer/SDKs/MacOSX10.4u.sdk/usr/lib/crt1.10.5.o + + # In order to build a universal binary we need the following line: + set(CMAKE_OSX_ARCHITECTURES ppc;i386) + + # To support much older OSX machines we need the following lines: + #set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.4u.sdk) + #set(CMAKE_FIND_ROOT_PATH /Developer/SDKs/MacOSX10.4u.sdk) endif (APPLE) add_subdirectory(src) diff --git a/build.sh b/build.sh index ebdff3df3..c496f0885 100755 --- a/build.sh +++ b/build.sh @@ -16,4 +16,4 @@ else cd build fi -cmake ../ -DCMAKE_INSTALL_REFIX=. && make -j$JFLAG && make install +cmake ../ -DCMAKE_INSTALL_REFIX=. && make -j$JFLAG && make package diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cecc9b788..ea9afcb62 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -154,7 +154,7 @@ QT4_WRAP_CPP(mmapper_MOC_SRCS ${mmapper_MOC_HDRS}) QT4_WRAP_UI(mmapper_UIS_H ${mmapper_UIS}) QT4_ADD_RESOURCES(mmapper_RCC_SRCS ${mmapper_RCS}) -add_executable(mmapper WIN32 +add_executable(mmapper WIN32 MACOSX_BUNDLE ${mmapper_SRCS} ${mmapper_MOC_SRCS} ${mmapper_UIS_H} @@ -288,17 +288,26 @@ endif (WIN32) # Apple Install Settings if (APPLE) + # Bundle the libraries with the binary (requires Qt 4.5) + add_custom_command( + TARGET mmapper + POST_BUILD + COMMAND macdeployqt ${CMAKE_CURRENT_BINARY_DIR}/mmapper.app + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Deploying the Qt Framework onto the bundle" + ) + # Install Executables install( TARGETS mmapper - RUNTIME DESTINATION bin + BUNDLE DESTINATION ../Applications/MMapper COMPONENT applications ) # Install Map install( FILES ${PROJECT_SOURCE_DIR}/map/arda.mm2 - DESTINATION bin + DESTINATION ../Applications/MMapper COMPONENT map ) @@ -306,14 +315,32 @@ if (APPLE) install(FILES "${PROJECT_SOURCE_DIR}/doc/Installation Guide.URL" "${PROJECT_SOURCE_DIR}/doc/mapping_advice.txt" - DESTINATION bin + DESTINATION ../Applications/MMapper COMPONENT help ) + + # If we are supporting older machines, use the following + set(CPACK_OSX_PACKAGE_VERSION 10.5) + + # Package Settings + set(CPACK_GENERATOR "PackageMaker") + set(CPACK_SOURCE_GENERATOR "TGZ") + + # Libraries are bundled directly + set(CPACK_COMPONENT_LIBRARIES_HIDDEN TRUE) + + # Bundle Properties + #SET(MACOSX_BUNDLE_ICON_FILE icon.icns) + SET(MACOSX_BUNDLE_BUNDLE_NAME MMapper) + SET(MACOSX_BUNDLE_BUNDLE_VERSION ${VERSION}) + SET(MACOSX_BUNDLE_SHORT_VERSION_STRING ${VERSION}) + SET(MACOSX_BUNDLE_LONG_VERSION_STRING "Version ${VERSION}") + endif (APPLE) # More General CPack Settings set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt") -set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/INSTALL.txt") +#set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/INSTALL.txt") set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") set(CPACK_PACKAGE_VENDOR "Nils Schimmelmann") set(CPACK_PACKAGE_CONTACT "nschimme@gmail.com") @@ -321,7 +348,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A mud mapper especially written for the m if (SVN_BUILD) set(CPACK_PACKAGE_VERSION "svn-build-${SVN_BUILD}") else (SVN_BUILD) - set(CPACK_PACKAGE_VERSION "2.0.4-final2") + set(CPACK_PACKAGE_VERSION ${VERSION}) endif (SVN_BUILD) set(CPACK_PACKAGE_VERSION_MAJOR "2") set(CPACK_PACKAGE_VERSION_MINOR "0")