2
0

CMakeLists.txt 7.3 KB

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