You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. cmake_minimum_required(VERSION 2.6)
  2. if(${CMAKE_VERSION} STREQUAL "2.8.2")
  3. # Bug http://vtk.org/Bug/view.php?id=11020
  4. message(WARNING "CMake/CPack version 2.8.2 will not create working .deb packages!")
  5. endif()
  6. # This can be read from ${PROJECT_NAME} after project() is called
  7. project(BlockColor)
  8. set(PROJECT_NAME_CAPITALIZED "BlockColor")
  9. # Works only for cmake 3.1 and greater
  10. set(CMAKE_CXX_STANDARD 11)
  11. # Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing
  12. set(VERSION_MAJOR 2)
  13. set(VERSION_MINOR 0)
  14. set(VERSION_PATCH 0)
  15. set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
  16. # Change to false for releases
  17. set(DEVELOPMENT_BUILD FALSE)
  18. set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
  19. if(VERSION_EXTRA)
  20. set(VERSION_STRING ${VERSION_STRING}-${VERSION_EXTRA})
  21. elseif(DEVELOPMENT_BUILD)
  22. set(VERSION_STRING "${VERSION_STRING}-dev")
  23. endif()
  24. if (CMAKE_BUILD_TYPE STREQUAL Debug)
  25. # Append "-debug" to version string
  26. set(VERSION_STRING "${VERSION_STRING}-debug")
  27. endif()
  28. message(STATUS "*** Will build version ${VERSION_STRING} ***")
  29. # Configuration options
  30. set(DEFAULT_RUN_IN_PLACE FALSE)
  31. if(WIN32)
  32. set(DEFAULT_RUN_IN_PLACE TRUE)
  33. endif()
  34. set(RUN_IN_PLACE ${DEFAULT_RUN_IN_PLACE} CACHE BOOL
  35. "Run directly in source directory structure")
  36. set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
  37. set(BUILD_SERVER FALSE CACHE BOOL "Build server")
  38. set(WARN_ALL TRUE CACHE BOOL "Enable -Wall for Release build")
  39. if(NOT CMAKE_BUILD_TYPE)
  40. # Default to release
  41. set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
  42. endif()
  43. # Included stuff
  44. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
  45. # This is done here so that relative search paths are more reasonable
  46. find_package(Irrlicht)
  47. # Installation
  48. if(WIN32)
  49. set(SHAREDIR ".")
  50. set(BINDIR "bin")
  51. set(DOCDIR "doc")
  52. set(EXAMPLE_CONF_DIR ".")
  53. set(LOCALEDIR "locale")
  54. elseif(APPLE)
  55. set(BUNDLE_NAME ${PROJECT_NAME}.app)
  56. set(BUNDLE_PATH "${BUNDLE_NAME}")
  57. set(BINDIR ${BUNDLE_NAME}/Contents/MacOS)
  58. set(SHAREDIR ${BUNDLE_NAME}/Contents/Resources)
  59. set(DOCDIR "${SHAREDIR}/${PROJECT_NAME}")
  60. set(EXAMPLE_CONF_DIR ${DOCDIR})
  61. set(LOCALEDIR "${SHAREDIR}/locale")
  62. elseif(UNIX) # Linux, BSD etc
  63. if(RUN_IN_PLACE)
  64. set(SHAREDIR ".")
  65. set(BINDIR "bin")
  66. set(DOCDIR "doc")
  67. set(EXAMPLE_CONF_DIR ".")
  68. set(MANDIR "unix/man")
  69. set(XDG_APPS_DIR "unix/applications")
  70. set(APPDATADIR "unix/metainfo")
  71. set(ICONDIR "unix/icons")
  72. set(LOCALEDIR "locale")
  73. else()
  74. set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
  75. set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
  76. set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
  77. set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
  78. set(EXAMPLE_CONF_DIR ${DOCDIR})
  79. set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
  80. set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/metainfo")
  81. set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
  82. set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/locale")
  83. endif()
  84. endif()
  85. set(CUSTOM_SHAREDIR "" CACHE STRING "Directory to install data files into")
  86. if(NOT CUSTOM_SHAREDIR STREQUAL "")
  87. set(SHAREDIR "${CUSTOM_SHAREDIR}")
  88. message(STATUS "Using SHAREDIR=${SHAREDIR}")
  89. endif()
  90. set(CUSTOM_BINDIR "" CACHE STRING "Directory to install binaries into")
  91. if(NOT CUSTOM_BINDIR STREQUAL "")
  92. set(BINDIR "${CUSTOM_BINDIR}")
  93. message(STATUS "Using BINDIR=${BINDIR}")
  94. endif()
  95. set(CUSTOM_DOCDIR "" CACHE STRING "Directory to install documentation into")
  96. if(NOT CUSTOM_DOCDIR STREQUAL "")
  97. set(DOCDIR "${CUSTOM_DOCDIR}")
  98. if(NOT RUN_IN_PLACE)
  99. set(EXAMPLE_CONF_DIR ${DOCDIR})
  100. endif()
  101. message(STATUS "Using DOCDIR=${DOCDIR}")
  102. endif()
  103. set(CUSTOM_MANDIR "" CACHE STRING "Directory to install manpages into")
  104. if(NOT CUSTOM_MANDIR STREQUAL "")
  105. set(MANDIR "${CUSTOM_MANDIR}")
  106. message(STATUS "Using MANDIR=${MANDIR}")
  107. endif()
  108. set(CUSTOM_EXAMPLE_CONF_DIR "" CACHE STRING "Directory to install example config file into")
  109. if(NOT CUSTOM_EXAMPLE_CONF_DIR STREQUAL "")
  110. set(EXAMPLE_CONF_DIR "${CUSTOM_EXAMPLE_CONF_DIR}")
  111. message(STATUS "Using EXAMPLE_CONF_DIR=${EXAMPLE_CONF_DIR}")
  112. endif()
  113. set(CUSTOM_XDG_APPS_DIR "" CACHE STRING "Directory to install .desktop files into")
  114. if(NOT CUSTOM_XDG_APPS_DIR STREQUAL "")
  115. set(XDG_APPS_DIR "${CUSTOM_XDG_APPS_DIR}")
  116. message(STATUS "Using XDG_APPS_DIR=${XDG_APPS_DIR}")
  117. endif()
  118. set(CUSTOM_ICONDIR "" CACHE STRING "Directory to install icons into")
  119. if(NOT CUSTOM_ICONDIR STREQUAL "")
  120. set(ICONDIR "${CUSTOM_ICONDIR}")
  121. message(STATUS "Using ICONDIR=${ICONDIR}")
  122. endif()
  123. set(CUSTOM_LOCALEDIR "" CACHE STRING "Directory to install l10n files into")
  124. if(NOT CUSTOM_LOCALEDIR STREQUAL "")
  125. set(LOCALEDIR "${CUSTOM_LOCALEDIR}")
  126. message(STATUS "Using LOCALEDIR=${LOCALEDIR}")
  127. endif()
  128. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}")
  129. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/worlds" DESTINATION "${SHAREDIR}")
  130. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client" DESTINATION "${SHAREDIR}")
  131. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/clientmods" DESTINATION "${SHAREDIR}")
  132. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games" DESTINATION "${SHAREDIR}" PATTERN ".git*" EXCLUDE)
  133. if(BUILD_CLIENT)
  134. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/textures" DESTINATION "${SHAREDIR}")
  135. endif()
  136. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/fonts" DESTINATION "${SHAREDIR}")
  137. install(FILES "README.md" DESTINATION "${DOCDIR}")
  138. install(FILES "doc/lua_api.txt" DESTINATION "${DOCDIR}")
  139. install(FILES "doc/menu_lua_api.txt" DESTINATION "${DOCDIR}")
  140. install(FILES "doc/texture_packs.txt" DESTINATION "${DOCDIR}")
  141. install(FILES "doc/world_format.txt" DESTINATION "${DOCDIR}")
  142. install(FILES "blockcolor.conf" DESTINATION "${EXAMPLE_CONF_DIR}")
  143. if(UNIX AND NOT APPLE)
  144. install(FILES "doc/BlockColor.6" "doc/BlockColorServer.6" DESTINATION "${MANDIR}/man6")
  145. install(FILES "misc/BlockColor.desktop" DESTINATION "${XDG_APPS_DIR}")
  146. install(FILES "misc/BlockColor.appdata.xml" DESTINATION "${APPDATADIR}")
  147. install(FILES "misc/BlockColor.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps")
  148. install(FILES "misc/BlockColor-xorg-icon-128.png"
  149. DESTINATION "${ICONDIR}/hicolor/128x128/apps"
  150. RENAME "BlockColor.png")
  151. endif()
  152. if(APPLE)
  153. install(FILES "misc/BlockColor-icon.icns" DESTINATION "${SHAREDIR}")
  154. install(FILES "misc/Info.plist" DESTINATION "${BUNDLE_PATH}/Contents")
  155. endif()
  156. # Library pack
  157. find_package(GMP REQUIRED)
  158. find_package(Json REQUIRED)
  159. find_package(Lua REQUIRED)
  160. # Subdirectories
  161. # Be sure to add all relevant definitions above this
  162. add_subdirectory(src)
  163. # CPack
  164. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A Sandbox Creative Game with 8 Colors")
  165. set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
  166. set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
  167. set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
  168. set(CPACK_PACKAGE_VENDOR "MrChiantos")
  169. set(CPACK_PACKAGE_CONTACT "julienetnel@gmail.com")
  170. if(WIN32)
  171. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  172. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win64")
  173. else()
  174. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
  175. endif()
  176. set(CPACK_GENERATOR ZIP)
  177. elseif(APPLE)
  178. set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
  179. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
  180. set(CPACK_GENERATOR ZIP)
  181. else()
  182. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
  183. set(CPACK_GENERATOR TGZ)
  184. set(CPACK_SOURCE_GENERATOR TGZ)
  185. endif()
  186. include(CPack)
  187. # Add a target to generate API documentation with Doxygen
  188. find_package(Doxygen)
  189. if(DOXYGEN_FOUND)
  190. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in
  191. ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY)
  192. add_custom_target(doc
  193. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile
  194. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
  195. COMMENT "Generating API documentation with Doxygen" VERBATIM
  196. )
  197. endif()