CMakeLists.txt 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. add_subdirectory(gui)
  2. file(GLOB_RECURSE allDataFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
  3. fonts/*
  4. help/*
  5. images/*
  6. locale/*
  7. music/*
  8. opening/*.scn
  9. sounds/*
  10. colour.pal
  11. lincityconfig.xml
  12. lincity-ng.desktop
  13. lincity-ng.png
  14. )
  15. foreach(dataFile ${allDataFiles})
  16. add_custom_command(
  17. OUTPUT ${dataFile}
  18. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${dataFile} ${dataFile}
  19. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${dataFile}
  20. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  21. COMMENT "copying ${dataFile} to build directory"
  22. )
  23. cmake_path(GET dataFile PARENT_PATH dataFileDst)
  24. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${dataFile} DESTINATION ${CMAKE_INSTALL_APPDATADIR}/${dataFileDst})
  25. endforeach()
  26. add_custom_target(allDataFiles.target DEPENDS ${allDataFiles})
  27. add_dependencies(lincity-ng allDataFiles.target)
  28. # install the desktop file and icon
  29. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lincity-ng.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
  30. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lincity-ng.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/128x128/apps)
  31. # install desktop file as a sym-link
  32. # install(CODE "
  33. # if(\${CMAKE_INSTALL_PREFIX} EQUAL ${CMAKE_INSTALL_PREFIX})
  34. # message(STATUS \"installing desktop file: \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/applications/lincity-ng.desktop\\nLinks to: ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_APPDATADIR}/lincity-ng.desktop\")
  35. # file(MAKE_DIRECTORY \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/applications/)
  36. # execute_process(COMMAND \${CMAKE_COMMAND} -E create_symlink
  37. # ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_APPDATADIR}/lincity-ng.desktop
  38. # \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/applications/lincity-ng.desktop
  39. # )
  40. # ")
  41. file(GLOB_RECURSE TRANSLATABLE_SOURCES CONFIGURE_DEPENDS
  42. ${CMAKE_SOURCE_DIR}/src/gui/*.cpp
  43. ${CMAKE_SOURCE_DIR}/src/gui/*.hpp
  44. ${CMAKE_SOURCE_DIR}/src/gui/*.h
  45. ${CMAKE_SOURCE_DIR}/src/lincity/*.cpp
  46. ${CMAKE_SOURCE_DIR}/src/lincity/*.hpp
  47. ${CMAKE_SOURCE_DIR}/src/lincity/*.h
  48. ${CMAKE_SOURCE_DIR}/src/lincity-ng/*.cpp
  49. ${CMAKE_SOURCE_DIR}/src/lincity-ng/*.hpp
  50. ${CMAKE_SOURCE_DIR}/src/lincity-ng/*.h
  51. )
  52. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale)
  53. add_custom_command(
  54. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/locale/messages.pot
  55. COMMAND xgettext --keyword='_:1' --keyword='N_:1' -o ${CMAKE_CURRENT_BINARY_DIR}/locale/messages.pot ${TRANSLATABLE_SOURCES}
  56. DEPENDS ${TRANSLATABLE_SOURCES}
  57. COMMENT "generating ${CMAKE_INSTALL_APPDATADIR}/locale/messages.pot"
  58. )
  59. add_custom_target(messages-pot.target DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/locale/messages.pot)
  60. add_dependencies(lincity-ng messages-pot.target)
  61. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/locale/messages.pot DESTINATION ${CMAKE_INSTALL_APPDATADIR}/locale)
  62. file(GLOB_RECURSE ALL_GUI_XML RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS
  63. ${CMAKE_CURRENT_SOURCE_DIR}/gui/*.xml
  64. )
  65. list(TRANSFORM ALL_GUI_XML PREPEND ${CMAKE_CURRENT_BINARY_DIR}/)
  66. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/locale/gui)
  67. add_custom_command(
  68. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/locale/gui/messages.pot
  69. COMMAND xmlgettext ${CMAKE_CURRENT_BINARY_DIR}/locale/gui/messages.pot ${ALL_GUI_XML}
  70. DEPENDS ${ALL_GUI_XML} guiXml guiDialogXml
  71. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  72. COMMENT "generating ${CMAKE_INSTALL_APPDATADIR}/locale/gui/messages.pot"
  73. )
  74. add_custom_target(gui_messages-pot.target DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/locale/gui/messages.pot)
  75. add_dependencies(lincity-ng gui_messages-pot.target)
  76. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/locale/gui/messages.pot DESTINATION ${CMAKE_INSTALL_APPDATADIR}/locale/gui)
  77. set(infoFiles
  78. COPYING
  79. COPYING-data.txt
  80. COPYING-fonts.txt
  81. README.md
  82. RELNOTES
  83. )
  84. foreach(infoFile ${infoFiles})
  85. add_custom_command(
  86. OUTPUT ${infoFile}
  87. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/${infoFile} ${infoFile}
  88. DEPENDS ${CMAKE_SOURCE_DIR}/${infoFile}
  89. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  90. COMMENT "copying ${infoFile} to build directory"
  91. )
  92. cmake_path(GET infoFile PARENT_PATH infoFileDst)
  93. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${infoFile} DESTINATION ${CMAKE_INSTALL_APPDATADIR}/${infoFileDst})
  94. endforeach()
  95. add_custom_target(infoFiles.target DEPENDS ${infoFiles})
  96. add_dependencies(lincity-ng infoFiles.target)