Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Setup CMake to build for macOS
[xestiaab/.git] / source / CMakeFunctions / Application.cmake
index 87a6208..d3b44f7 100644 (file)
@@ -34,29 +34,13 @@ set(FILE_LIST main.cpp
               frmUpdate.cpp
               frmUpdate.h)
 
-if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+if(APPLE)
     list(APPEND FILE_LIST frmEditAccount.mm
-                             frmNewAccount.mm)
+                          frmNewAccount.mm
+                          frmMain.mm
+                          os/osx/XestiaAddressBook.icns)
 endif()
 
-if (MSVC)
-    list(APPEND FILE_LIST os/msw/xestiaab.rc)
-    add_executable(xestiaab WIN32
-        ${FILE_LIST})
-else()
-    add_executable(xestiaab
-        ${FILE_LIST})
-endif()
-
-
-message("${RUNTIME_OUTPUT_NAME_bitmapcode}")
-
-target_include_directories(xestiaab
-    PUBLIC
-    ".")
-    
-add_dependencies(xestiaab bitmapcode)
-    
 list(APPEND LIBRARIES ${wxWidgets_LIBRARIES}
                       ${LIBXML2_LIBRARY}
                       sfml-audio
@@ -80,10 +64,68 @@ if (MSVC)
                           crypt32)
 endif()
 
-target_link_libraries(xestiaab
-    LINK_PUBLIC
-    ${LIBRARIES}
-)
+if (MSVC)
+    list(APPEND FILE_LIST os/msw/xestiaab.rc)
+    add_executable(xestiaab WIN32
+        ${FILE_LIST})
+elseif(APPLE)
+    # Main icons
+    set_source_files_properties(os/osx/XestiaAddressBook.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
+    set(MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/os/osx/Info.plist")
+    set(CMAKE_BUILD_PATH_USE_ORIGIN TRUE)
+    set(APPS "\${CMAKE_INSTALL_PREFIX}/xestiaab.app")
+    set(DIR ${CMAKE_BINARY_DIR})
+    
+    install(CODE "include(BundleUtilities)
+        fixup_bundle(\"${APPS}\" \"\" \"\")")
+
+    # Documentation
+    file(GLOB DocumentationFiles ${CMAKE_SOURCE_DIR}/../docs/*.fodt)
+    set_source_files_properties(${DocumentationFiles} 
+        PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
+
+    add_executable(xestiaab MACOSX_BUNDLE
+        ${FILE_LIST}
+        ${DocumentationFiles}
+        ${FrameworkFiles})
+    
+    install(TARGETS xestiaab
+        BUNDLE DESTINATION . COMPONENT Runtime
+        RUNTIME DESTINATION bin COMPONENT Runtime)
+
+    target_link_libraries(xestiaab LINK_PUBLIC
+                          stdc++
+                          objc
+                          ${COREFOUNDATION_FRAMEWORK}
+                          ${SECURITY_FRAMEWORK}
+                          ${SECURITYINTERFACE_FRAMEWORK}
+                          ${LIBRARIES})
+
+    set_target_properties(xestiaab PROPERTIES
+                          MACOSX_BUNDLE TRUE
+                          MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/os/osx/Info.plist)
+        
+    add_custom_command(
+        TARGET xestiaab
+        COMMAND ${CMAKE_COMMAND} -D SRC=$<TARGET_BUNDLE_DIR:xestiaab>/Contents/MacOS/xestiaab
+                                 -D DST=$<TARGET_BUNDLE_DIR:xestiaab>/Contents/Frameworks
+                                 -D SFML_FRAMEWORKS_LOCATION=${SFML_FRAMEWORKS_LOCATION}
+                                 -P ${CMAKE_CURRENT_SOURCE_DIR}/CMakeFunctions/CopyLibraries.cmake
+        POST_BUILD
+    )
+else()
+    add_executable(xestiaab
+        ${FILE_LIST})
+endif()
+
+
+message("${RUNTIME_OUTPUT_NAME_bitmapcode}")
+
+target_include_directories(xestiaab
+    PUBLIC
+    ".")
+    
+add_dependencies(xestiaab bitmapcode)
 
 file(GLOB DOCUMENTATION_INSTALL_FILES "${CMAKE_SOURCE_DIR}/../docs/*")
 foreach(ITEM ${DOCUMENTATION_INSTALL_FILES})
@@ -93,9 +135,3 @@ foreach(ITEM ${DOCUMENTATION_INSTALL_FILES})
         list(APPEND DOCUMENTATION_DEPLOY_DIRECTORIES "${ITEM}")
     endif()
 endforeach()
-
-install(TARGETS xestiaab RUNTIME DESTINATION bin)
-install(TARGETS odthelpbrowser RUNTIME DESTINATION bin)
-install(FILES ${CMAKE_SOURCE_DIR}/xestiaab.1 DESTINATION share/man/man1)
-install(FILES ${DOCUMENTATION_DEPLOY_FILES} DESTINATION share/doc/xestiaab)
-install(FILES ${DOCUMENTATION_DEPLOY_DIRECTORIES} DESTINATION share/doc/xestiaab)
\ No newline at end of file
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy