소스 검색

Make it buildable as bundle on OSX

Dominik Schmidt 14 년 전
부모
커밋
ccac3dcf95
6개의 변경된 파일151개의 추가작업 그리고 44개의 파일을 삭제
  1. 11 2
      CMakeLists.txt
  2. 46 21
      OwnCloudCPack.cmake
  3. BIN
      admin/osx/DMGBackground.png
  4. BIN
      admin/osx/DS_Store.in
  5. 36 0
      cmake/modules/MacOSXBundleInfo.plist.in
  6. 58 21
      src/CMakeLists.txt

+ 11 - 2
CMakeLists.txt

@@ -6,6 +6,12 @@ set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
 include(${CMAKE_SOURCE_DIR}/VERSION.cmake)
 include(GNUInstallDirs)
 
+if(NOT DEFINED BUILD_OWNCLOUD_OSX_BUNDLE OR NOT APPLE)
+    set(BUILD_OWNCLOUD_OSX_BUNDLE OFF)
+elseif(BUILD_OWNCLOUD_OSX_BUNDLE)
+    set(OWNCLOUD_OSX_BUNDLE "owncloud.app")
+endif()
+
 find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtXml QtNetwork QtTest REQUIRED )
 find_package(Csync)
 
@@ -56,6 +62,9 @@ set(TRANSLATIONS ${CMAKE_SOURCE_DIR}/translations/mirall_de.ts)
 add_subdirectory(src)
 # add_subdirectory(test)
 
-install( FILES exclude.lst DESTINATION ${CMAKE_INSTALL_SYSCONFDIR})
-
+if(BUILD_OWNCLOUD_OSX_BUNDLE)
+    install( FILES exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources )
+else()
+    install( FILES exclude.lst DESTINATION ${CMAKE_INSTALL_SYSCONFDIR} )
+endif()
 

+ 46 - 21
OwnCloudCPack.cmake

@@ -1,35 +1,60 @@
-INCLUDE( InstallRequiredSystemLibraries )
+include( InstallRequiredSystemLibraries )
 
-SET( CPACK_PACKAGE_CONTACT  "Dominik Schmidt <domme@tomahawk-player.org>" )
+set( CPACK_PACKAGE_CONTACT  "Dominik Schmidt <domme@tomahawk-player.org>" )
 
-SET( APPLICATION_NAME "ownCloud Client")
+set( APPLICATION_NAME "ownCloud Client")
 
-SET( CPACK_PACKAGE_FILE_NAME  owncloud-setup )    # Package file name without extension. Also a directory of installer  cmake-2.5.0-Linux-i686
+set( CPACK_PACKAGE_VERSION_MAJOR  1 )
+set( CPACK_PACKAGE_VERSION_MINOR  0 )
+set( CPACK_PACKAGE_VERSION_PATCH  0 )
+set( CPACK_PACKAGE_VERSION  ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} )
 
-# CPACK_GENERATOR   CPack generator to be used  STGZ;TGZ;TZ
-# CPACK_INCLUDE_TOPLEVEL_DIRECTORY    Controls whether CPack adds a top-level directory, usually of the form ProjectName-Version-OS, to the top of package tree.  0 to disable, 1 to enable
-# CPACK_INSTALL_CMAKE_PROJECTS    List of four values: Build directory, Project Name, Project Component, Directory in the package     /home/andy/vtk/CMake-bin;CMake;ALL;/
-SET( CPACK_PACKAGE_DESCRIPTION_FILE  "${CMAKE_SOURCE_DIR}/README.md" ) # File used as a description of a project     /path/to/project/ReadMe.txt
-SET( CPACK_PACKAGE_DESCRIPTION_SUMMARY  "ownCloud Syncing Client" ) #  Description summary of a project
-# CPACK_PACKAGE_EXECUTABLES   List of pairs of executables and labels. Used by the NSIS generator to create Start Menu shortcuts.     ccmake;CMake
-SET( CPACK_PACKAGE_INSTALL_DIRECTORY  ${APPLICATION_NAME} )     # Installation directory on the target system -> C:\Program Files\fellody
-SET( CPACK_PACKAGE_INSTALL_REGISTRY_KEY ${APPLICATION_NAME} )  # Registry key used when installing this project  CMake 2.5.0
-SET( CPACK_PACKAGE_NAME  ${APPLICATION_NAME} ) # Package name, defaults to the project name
-SET( CPACK_PACKAGE_VENDOR  "http://owncloud.com" )   # Package vendor name
+if(APPLE)
+    set( CPACK_GENERATOR "DragNDrop" )
+    set( CPACK_SOURCE_GENERATOR "")
+    set( CPACK_PACKAGE_FILE_NAME ownCloudClientSetup-${CPACK_PACKAGE_VERSION} )
+    set( CPACK_PACKAGE_ICON ${CMAKE_BINARY_DIR}/src/ownCloud.icns)
 
-SET( CPACK_PACKAGE_VERSION_MAJOR  1 )
-SET( CPACK_PACKAGE_VERSION_MINOR  0 )
-SET( CPACK_PACKAGE_VERSION_PATCH  0 )
-SET( CPACK_PACKAGE_VERSION  ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} )
+    set( CPACK_DMG_DS_STORE "${CMAKE_SOURCE_DIR}/admin/osx/DS_Store.in")
+    set( CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/admin/osx/DMGBackground.png" )
 
-# SET( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt" ) # License file for the project, used by the STGZ, NSIS, and PackageMaker generators.  /home/andy/vtk/CMake/Copyright.txt
+    set( CPACK_DMG_FORMAT "UDBZ" )
+    set( CPACK_DMG_VOLUME_NAME "${APPLICATION_NAME}")
 
+    # did not work with cmake 2.8.7, so we override MacOSXBundleInfo.plist.in
+    #set( CPACK_BUNDLE_PLIST ${CMAKE_SOURCE_DIR}/admin/osx/Info.plist )
 
-SET( CPACK_TOPLEVEL_TAG "unused" ) # Directory for the installed files.  - needed to provide anything to avoid an error# CPACK_INSTALL_COMMANDS  Extra commands to install components.
+    # do we need these?
+    #set( CPACK_SYSTEM_NAME "OSX" )
+    #set( CPACK_PACKAGE_NAME "FOO" )
+    #set( CPACK_BUNDLE_NAME "BAR" )
+endif()
+
+
+
+
+if(WIN32)
+    set( CPACK_PACKAGE_FILE_NAME  owncloud-client-setup )
+    # Package file name without extension. Also a directory of installer  cmake-2.5.0-Linux-i686
+    # CPACK_GENERATOR   CPack generator to be used  STGZ;TGZ;TZ
+    # CPACK_INCLUDE_TOPLEVEL_DIRECTORY    Controls whether CPack adds a top-level directory, usually of the form ProjectName-Version-OS, to the top of package tree.  0 to disable, 1 to enable
+    # CPACK_INSTALL_CMAKE_PROJECTS    List of four values: Build directory, Project Name, Project Component, Directory in the package     /home/andy/vtk/CMake-bin;CMake;ALL;/
+    set( CPACK_PACKAGE_DESCRIPTION_FILE  "${CMAKE_SOURCE_DIR}/README.md" ) # File used as a description of a project     /path/to/project/ReadMe.txt
+    set( CPACK_PACKAGE_DESCRIPTION_SUMMARY  "ownCloud Syncing Client" ) #  Description summary of a project
+    # CPACK_PACKAGE_EXECUTABLES   List of pairs of executables and labels. Used by the NSIS generator to create Start Menu shortcuts.     ccmake;CMake
+    set( CPACK_PACKAGE_INSTALL_DIRECTORY  ${APPLICATION_NAME} )     # Installation directory on the target system -> C:\Program Files\fellody
+    set( CPACK_PACKAGE_INSTALL_REGISTRY_KEY ${APPLICATION_NAME} )  # Registry key used when installing this project  CMake 2.5.0
+    set( CPACK_PACKAGE_NAME  ${APPLICATION_NAME} ) # Package name, defaults to the project name
+    set( CPACK_PACKAGE_VENDOR  "http://owncloud.com" )   # Package vendor name
+endif()
+
+# set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt" ) # License file for the project, used by the STGZ, NSIS, and PackageMaker generators.  /home/andy/vtk/CMake/Copyright.txt
+
+
+set( CPACK_TOPLEVEL_TAG "unused" ) # Directory for the installed files.  - needed to provide anything to avoid an error# CPACK_INSTALL_COMMANDS  Extra commands to install components.
 
 
 # Set the options file that needs to be included inside CMakeCPackOptions.cmake
-#SET(QT_DIALOG_CPACK_OPTIONS_FILE ${CMake_BINARY_DIR}/Source/QtDialog/QtDialogCPack.cmake)
 configure_file("${CMAKE_SOURCE_DIR}/CPackOptions.cmake.in"
     "${CMAKE_BINARY_DIR}/CPackOptions.cmake" @ONLY)
 set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_BINARY_DIR}/CPackOptions.cmake") # File included at cpack time, once per generator after setting CPACK_GENERATOR to the actual generator being used; allows per-generator setting of CPACK_* variables at cpack time.  ${PROJECT_BINARY_DIR}/CPackOptions.cmake

BIN
admin/osx/DMGBackground.png


BIN
admin/osx/DS_Store.in


+ 36 - 0
cmake/modules/MacOSXBundleInfo.plist.in

@@ -0,0 +1,36 @@
+<?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>CFBundleExecutable</key>
+        <string>owncloud</string>
+        <key>CFBundleGetInfoString</key>
+        <string></string>
+        <key>CFBundleIconFile</key>
+        <string>ownCloud.icns</string>
+        <key>CFBundleIdentifier</key>
+        <string>org.owncloud</string>
+        <key>CFBundleInfoDictionaryVersion</key>
+        <string>6.0</string>
+        <key>CFBundleLongVersionString</key>
+        <string>owncloud FIXME</string>
+        <key>CFBundleName</key>
+        <string>owncloudBundleName</string>
+        <key>CFBundlePackageType</key>
+        <string>APPL</string>
+        <key>CFBundleShortVersionString</key>
+        <string>0.1.0 FIXME</string>
+        <key>CFBundleSignature</key>
+        <string>????</string>
+        <key>CFBundleVersion</key>
+        <string>owncloud FIXME 0.1.0</string>
+        <key>CSResourcesFileMapped</key>
+        <true/>
+        <key>LSUIElement</key>
+        <true/>
+        <key>NSHumanReadableCopyright</key>
+        <string>2012 owncloud.org</string>
+</dict>
+</plist>

+ 58 - 21
src/CMakeLists.txt

@@ -98,39 +98,76 @@ qt4_add_translation(mirall_I18N ${TRANSLATIONS})
 add_library(mirall_static STATIC ${mirall_SRCS} ${mirall_UI_SRCS} ${mirallMoc} ${mirall_HEADERS} ${MIRALL_RC_SRC} ${mirall_I18N})
 target_link_libraries(mirall_static ${QT_LIBRARIES})
 
-add_executable( mirall main.cpp )
-set( final_src ${mirall_HEADERS}
-	${MIRALL_RC_SRC} ${mirall_SRCS} ${mirall_UI_SRCS} ${mirallMoc} ${mirall_HEADERS} ${mirall_I18N})
+set( final_src
+    ${mirall_HEADERS}
+    ${MIRALL_RC_SRC}
+    ${mirall_SRCS}
+    ${mirall_UI_SRCS}
+    ${mirallMoc}
+    ${mirall_HEADERS}
+    ${mirall_I18N}
+)
 
 # add executable icon on windows and osx
 include( AddAppIconMacro )
-kde4_add_app_icon( final_src "${CMAKE_CURRENT_SOURCE_DIR}/../resources/mirall-*.png" )
+set(ownCloud_old ${ownCloud})
+kde4_add_app_icon( ownCloud "${CMAKE_CURRENT_SOURCE_DIR}/../resources/mirall-*.png" )
+list(APPEND final_src ${ownCloud})
+set(ownCloud ${ownCloud_old})
 
-add_executable(owncloud WIN32 main.cpp ${final_src})
-# add_executable(owncloud  main.cpp ${final_src})
+if(NOT BUILD_OWNCLOUD_OSX_BUNDLE)
+    set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
 
-SET(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
-SET_TARGET_PROPERTIES( mirall PROPERTIES
-        RUNTIME_OUTPUT_DIRECTORY  ${BIN_OUTPUT_DIRECTORY} )
-SET_TARGET_PROPERTIES( owncloud PROPERTIES
+    install(FILES mirall.png DESTINATION share/icons/hicolor/48x48/apps)
+
+    # we may not add MACOSX_BUNDLE here, if not building one
+    add_executable(owncloud WIN32 main.cpp ${final_src})
+
+    # mirall is not built for the bundle
+    add_executable( mirall WIN32 main.cpp )
+    target_link_libraries(mirall mirall_static)
+    target_link_libraries(mirall ${CSYNC_LIBRARY})
+    set_target_properties( mirall PROPERTIES
         RUNTIME_OUTPUT_DIRECTORY  ${BIN_OUTPUT_DIRECTORY} )
+    install(TARGETS mirall
+        RUNTIME DESTINATION bin
+        LIBRARY DESTINATION lib
+        ARCHIVE DESTINATION lib
+        BUNDLE  DESTINATION library
+    )
+else()
+    set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
+    include(DeployQt4)
+
+    set(CMAKE_INSTALL_PREFIX ".") # Examples use /Applications. hurmpf.
+    set(MACOSX_BUNDLE_ICON_FILE "ownCloud.icns")
+
+    # we must add MACOSX_BUNDLE only if building a bundle
+    add_executable(owncloud WIN32 MACOSX_BUNDLE main.cpp ${final_src})
+
+    #FIXME: hardcoded path
+    install(FILES /usr/local/lib/csync-0/csync_owncloud.so DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Plugins)
+    list(APPEND dirs "/usr/local/lib")
+endif()
 
-target_link_libraries(mirall mirall_static)
 
+set_target_properties( owncloud PROPERTIES
+        RUNTIME_OUTPUT_DIRECTORY  ${BIN_OUTPUT_DIRECTORY}
+)
 target_link_libraries(owncloud ${QT_LIBRARIES} )
 
-target_link_libraries(mirall ${CSYNC_LIBRARY})
 target_link_libraries(owncloud ${CSYNC_LIBRARY})
 
-install(TARGETS mirall
-	RUNTIME DESTINATION bin
-	LIBRARY DESTINATION lib
-	ARCHIVE DESTINATION lib )
 install(TARGETS owncloud
-	RUNTIME DESTINATION bin
-	LIBRARY DESTINATION lib
-	ARCHIVE DESTINATION lib )
-
-install(FILES mirall.png DESTINATION share/icons/hicolor/48x48/apps
+        RUNTIME DESTINATION bin
+        LIBRARY DESTINATION lib
+        ARCHIVE DESTINATION lib
+        BUNDLE  DESTINATION "."
 )
 
+#FIXME: find a nice solution to make the second if(BUILD_OWNCLOUD_OSX_BUNDLE) unneccessary
+# currently it needs to be done because the code right above needs to be executed no matter
+# if building a bundle or not and the install_qt4_executable needs to be called afterwards
+if(BUILD_OWNCLOUD_OSX_BUNDLE)
+    install_qt4_executable(${OWNCLOUD_OSX_BUNDLE} "" "${OWNCLOUD_OSX_BUNDLE}/Contents/Plugins/csync_owncloud.so" ${dirs})
+endif()