CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. set(STORYBOARDS Main.storyboard)
  2. set(SOURCES
  3. main.m
  4. AppDelegate.h
  5. AppDelegate.mm
  6. ViewController.h
  7. ViewController.m
  8. MacUI.mm
  9. ${STORYBOARDS}
  10. )
  11. add_executable(MacUpdater ${SOURCES})
  12. add_dependencies(MacUpdater dolphin_scmrev)
  13. set_target_properties(MacUpdater PROPERTIES
  14. MACOSX_BUNDLE true
  15. MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist"
  16. OUTPUT_NAME "Dolphin Updater")
  17. target_compile_options(MacUpdater PRIVATE -x objective-c++)
  18. # Copy icon into the bundle
  19. target_sources(MacUpdater PRIVATE "${CMAKE_SOURCE_DIR}/Data/Dolphin.icns")
  20. set_source_files_properties("${CMAKE_SOURCE_DIR}/Data/Dolphin.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  21. target_link_libraries(MacUpdater PRIVATE
  22. "-framework Cocoa"
  23. "-framework AppKit"
  24. "-framework CoreData"
  25. "-framework Foundation"
  26. uicommon
  27. updatercommon
  28. )
  29. # Compile storyboards (Adapted from https://gitlab.kitware.com/cmake/community/wikis/doc/tutorials/OSX-InterfaceBuilderFiles)
  30. # Make sure we can find the 'ibtool' program. If we can NOT find it we
  31. # skip generation of this project
  32. find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
  33. if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
  34. message(SEND_ERROR "ibtool can not be found and is needed to compile the .storyboard files. It should have been installed with
  35. the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin")
  36. endif()
  37. foreach(sb ${STORYBOARDS})
  38. set(output $<TARGET_BUNDLE_DIR:MacUpdater>/Contents/Resources/${sb}c)
  39. set(input ${CMAKE_CURRENT_SOURCE_DIR}/${sb})
  40. add_custom_command(TARGET MacUpdater POST_BUILD
  41. COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text --compile ${output} ${input}
  42. DEPENDS ${input}
  43. COMMENT "Compiling Storyboard ${sb}...")
  44. endforeach()
  45. if(NOT SKIP_POSTPROCESS_BUNDLE)
  46. # Update library references to make the bundle portable
  47. include(DolphinPostprocessBundle)
  48. dolphin_postprocess_bundle(MacUpdater)
  49. # Fix rpath
  50. add_custom_command(TARGET MacUpdater
  51. POST_BUILD COMMAND
  52. ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/"
  53. $<TARGET_FILE:MacUpdater>)
  54. endif()
  55. if(MACOS_CODE_SIGNING)
  56. add_custom_command(TARGET MacUpdater
  57. POST_BUILD
  58. COMMAND "${CMAKE_SOURCE_DIR}/Tools/mac-codesign.sh"
  59. "${MACOS_CODE_SIGNING_IDENTITY}"
  60. "$<TARGET_BUNDLE_DIR:MacUpdater>"
  61. )
  62. endif()