osx.cmake 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
  2. find_program(HALIBUT halibut REQUIRED)
  3. set(CPACK_GENERATOR DragNDrop)
  4. set(CPACK_PACKAGE_FILE_NAME Puzzles)
  5. set(CPACK_DMG_VOLUME_NAME "Simon Tatham's Puzzle Collection")
  6. include(CPack)
  7. set(build_individual_puzzles FALSE)
  8. set(CMAKE_OSX_ARCHITECTURES arm64 x86_64)
  9. set(build_gui_programs FALSE) # they don't really fit in the OS X GUI model
  10. function(get_platform_puzzle_extra_source_files OUTVAR NAME)
  11. set(${OUTVAR} PARENT_SCOPE)
  12. endfunction()
  13. function(set_platform_gui_target_properties TARGET)
  14. endfunction()
  15. function(set_platform_puzzle_target_properties NAME TARGET)
  16. endfunction()
  17. function(build_platform_extras)
  18. write_generated_games_header()
  19. set(resources
  20. ${CMAKE_CURRENT_SOURCE_DIR}/osx/Puzzles.icns)
  21. set_source_files_properties(${resources} PROPERTIES
  22. MACOSX_PACKAGE_LOCATION Resources)
  23. add_executable(puzzles MACOSX_BUNDLE
  24. osx.m list.c ${puzzle_sources}
  25. ${resources})
  26. set_target_properties(puzzles PROPERTIES
  27. OUTPUT_NAME Puzzles
  28. MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/osx/Info.plist)
  29. target_compile_definitions(puzzles PRIVATE COMBINED)
  30. target_include_directories(puzzles PRIVATE ${generated_include_dir})
  31. target_link_libraries(puzzles common ${platform_gui_libs} ${platform_libs}
  32. "-framework Cocoa")
  33. get_property(bundle_basename TARGET puzzles PROPERTY OUTPUT_NAME)
  34. set(help_dir ${CMAKE_CURRENT_BINARY_DIR}/${bundle_basename}.app/Contents/Resources/Help)
  35. message(${help_dir})
  36. add_custom_command(OUTPUT ${help_dir}
  37. COMMAND ${CMAKE_COMMAND} -E make_directory ${help_dir}
  38. DEPENDS puzzles)
  39. add_custom_command(OUTPUT ${help_dir}/index.html
  40. COMMAND ${HALIBUT} --html
  41. ${CMAKE_CURRENT_SOURCE_DIR}/osx-help.but
  42. ${CMAKE_CURRENT_SOURCE_DIR}/puzzles.but
  43. DEPENDS
  44. ${help_dir}
  45. ${CMAKE_CURRENT_SOURCE_DIR}/osx-help.but
  46. ${CMAKE_CURRENT_SOURCE_DIR}/puzzles.but
  47. WORKING_DIRECTORY ${help_dir})
  48. add_custom_target(osx_help ALL
  49. DEPENDS ${help_dir}/index.html)
  50. install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Puzzles.app
  51. USE_SOURCE_PERMISSIONS
  52. DESTINATION .)
  53. endfunction()