Support creating Mac OS X bundles that embed all dependencies.

This commit is contained in:
Felix Geyer 2012-05-21 20:24:06 +02:00
parent ca7c59d313
commit fa79da37b6
6 changed files with 98 additions and 0 deletions

View File

@ -25,6 +25,7 @@ option(WITH_LTO "Enable Link Time Optimization (LTO)" OFF)
option(WITH_PIE "Build as Position-independent executable (PIE)" OFF)
set( KEEPASSX_VERSION "2.0 alpha 1" )
set( KEEPASSX_VERSION_NUM "1.9.80" )
if("${CMAKE_C_COMPILER}" MATCHES "clang$" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_COMPILER_IS_CLANG 1)
@ -109,6 +110,10 @@ else( APPLE OR MINGW )
set( PROGNAME keepassx )
endif( APPLE OR MINGW )
if(APPLE AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
set(CMAKE_INSTALL_PREFIX "/Applications")
endif()
if(MINGW)
set(BIN_INSTALL_DIR "")
set(DATA_INSTALL_DIR "share")

View File

@ -22,5 +22,25 @@ if(UNIX AND NOT APPLE)
FILES_MATCHING PATTERN "keepassx.png" PATTERN "keepassx.svgz")
endif(UNIX AND NOT APPLE)
if(APPLE)
install(FILES macosx/keepassx.icns DESTINATION ${DATA_INSTALL_DIR})
endif()
install(DIRECTORY icons/application/ DESTINATION ${DATA_INSTALL_DIR}/icons/application
FILES_MATCHING PATTERN "*.png" PATTERN "*.svgz")
add_custom_target(icons
COMMAND png2icns macosx/keepassx.icns
icons/application/16x16/apps/keepassx.png
icons/application/32x32/apps/keepassx.png
icons/application/48x48/apps/keepassx.png
icons/application/128x128/apps/keepassx.png
COMMAND icotool -c -o windows/keepassx.ico
icons/application/16x16/apps/keepassx.png
icons/application/24x24/apps/keepassx.png
icons/application/32x32/apps/keepassx.png
icons/application/48x48/apps/keepassx.png
icons/application/64x64/apps/keepassx.png
icons/application/128x128/apps/keepassx.png
VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PROJECT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${PROGNAME}</string>
<key>CFBundleIconFile</key>
<string>keepassx.icns</string>
<key>CFBundleIdentifier</key>
<string>org.keepassx.keepassx</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PROJECT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${KEEPASSX_VERSION}</string>
<key>CFBundleSignature</key>
<string>KEPX</string>
<key>CFBundleVersion</key>
<string>${KEEPASSX_VERSION_NUM}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright 2010-2012 KeePassX Development Team</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>kdbx</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>keepassx.icns</string>
<key>CFBundleTypeName</key>
<string>KeePassX Password Database</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>kdbx</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
</array>
</dict>
</plist>

BIN
share/macosx/keepassx.icns Normal file

Binary file not shown.

BIN
share/windows/keepassx.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

View File

@ -146,6 +146,30 @@ add_library( keepassx_core STATIC ${keepassx_SOURCES} )
add_executable( ${PROGNAME} WIN32 MACOSX_BUNDLE main.cpp )
target_link_libraries( ${PROGNAME} keepassx_core ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${GCRYPT_LIBRARIES} ${ZLIB_LIBRARIES} )
if(APPLE)
configure_file(${CMAKE_SOURCE_DIR}/share/macosx/Info.plist.cmake ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
set_target_properties(${PROGNAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
endif()
install(TARGETS ${PROGNAME}
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime)
if(APPLE AND NOT (${CMAKE_VERSION} VERSION_LESS 2.8.8))
if(QT_MAC_USE_COCOA AND EXISTS "${QT_LIBRARY_DIR}/Resources/qt_menu.nib")
install(DIRECTORY "${QT_LIBRARY_DIR}/Resources/qt_menu.nib"
DESTINATION "${DATA_INSTALL_DIR}")
endif()
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_FORMAT "UDBZ")
set(CPACK_DMG_VOLUME_NAME "${PROGNAME}")
set(CPACK_SYSTEM_NAME "OSX")
set(CPACK_PACKAGE_FILE_NAME "${PROGNAME}-${KEEPASSX_VERSION_NUM}")
include(CPacK)
include(DeployQt4)
install_qt4_executable(${PROGNAME}.app "qjpeg")
endif()