CMakeLists.txt 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 15)
  13. set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
  14. # Change to false for releases
  15. set(DEVELOPMENT_BUILD FALSE)
  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. if(NOT RUN_IN_PLACE)
  93. set(EXAMPLE_CONF_DIR ${DOCDIR})
  94. endif()
  95. message(STATUS "Using DOCDIR=${DOCDIR}")
  96. endif()
  97. set(CUSTOM_MANDIR "" CACHE STRING "Directory to install manpages into")
  98. if(NOT CUSTOM_MANDIR STREQUAL "")
  99. set(MANDIR "${CUSTOM_MANDIR}")
  100. message(STATUS "Using MANDIR=${MANDIR}")
  101. endif()
  102. set(CUSTOM_EXAMPLE_CONF_DIR "" CACHE STRING "Directory to install example config file into")
  103. if(NOT CUSTOM_EXAMPLE_CONF_DIR STREQUAL "")
  104. set(EXAMPLE_CONF_DIR "${CUSTOM_EXAMPLE_CONF_DIR}")
  105. message(STATUS "Using EXAMPLE_CONF_DIR=${EXAMPLE_CONF_DIR}")
  106. endif()
  107. set(CUSTOM_XDG_APPS_DIR "" CACHE STRING "Directory to install .desktop files into")
  108. if(NOT CUSTOM_XDG_APPS_DIR STREQUAL "")
  109. set(XDG_APPS_DIR "${CUSTOM_XDG_APPS_DIR}")
  110. message(STATUS "Using XDG_APPS_DIR=${XDG_APPS_DIR}")
  111. endif()
  112. set(CUSTOM_ICONDIR "" CACHE STRING "Directory to install icons into")
  113. if(NOT CUSTOM_ICONDIR STREQUAL "")
  114. set(ICONDIR "${CUSTOM_ICONDIR}")
  115. message(STATUS "Using ICONDIR=${ICONDIR}")
  116. endif()
  117. set(CUSTOM_LOCALEDIR "" CACHE STRING "Directory to install l10n files into")
  118. if(NOT CUSTOM_LOCALEDIR STREQUAL "")
  119. set(LOCALEDIR "${CUSTOM_LOCALEDIR}")
  120. message(STATUS "Using LOCALEDIR=${LOCALEDIR}")
  121. endif()
  122. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}")
  123. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client" DESTINATION "${SHAREDIR}")
  124. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games" DESTINATION "${SHAREDIR}" PATTERN ".git*" EXCLUDE)
  125. if(BUILD_CLIENT)
  126. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/textures/base/pack" DESTINATION "${SHAREDIR}/textures/base")
  127. endif()
  128. if(RUN_IN_PLACE)
  129. install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mods/mods_here.txt" DESTINATION "${SHAREDIR}/mods")
  130. install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/textures/texture_packs_here.txt" DESTINATION "${SHAREDIR}/textures")
  131. endif()
  132. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/fonts" DESTINATION "${SHAREDIR}")
  133. install(FILES "README.txt" DESTINATION "${DOCDIR}")
  134. install(FILES "doc/lua_api.txt" DESTINATION "${DOCDIR}")
  135. install(FILES "doc/menu_lua_api.txt" DESTINATION "${DOCDIR}")
  136. install(FILES "doc/texture_packs.txt" DESTINATION "${DOCDIR}")
  137. install(FILES "doc/world_format.txt" DESTINATION "${DOCDIR}")
  138. install(FILES "minetest.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")
  139. if(UNIX AND NOT APPLE)
  140. install(FILES "doc/minetest.6" "doc/minetestserver.6" DESTINATION "${MANDIR}/man6")
  141. install(FILES "misc/minetest.desktop" DESTINATION "${XDG_APPS_DIR}")
  142. install(FILES "misc/minetest.appdata.xml" DESTINATION "${APPDATADIR}")
  143. install(FILES "misc/minetest.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps")
  144. install(FILES "misc/minetest-xorg-icon-128.png"
  145. DESTINATION "${ICONDIR}/hicolor/128x128/apps"
  146. RENAME "minetest.png")
  147. endif()
  148. if(APPLE)
  149. install(FILES "misc/minetest-icon.icns" DESTINATION "${SHAREDIR}")
  150. install(FILES "misc/Info.plist" DESTINATION "${BUNDLE_PATH}/Contents")
  151. endif()
  152. # Subdirectories
  153. # Be sure to add all relevant definitions above this
  154. add_subdirectory(src)
  155. # CPack
  156. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An InfiniMiner/Minecraft inspired game")
  157. set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
  158. set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
  159. set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
  160. set(CPACK_PACKAGE_VENDOR "celeron55")
  161. set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")
  162. if(WIN32)
  163. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  164. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win64")
  165. else()
  166. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
  167. endif()
  168. set(CPACK_GENERATOR ZIP)
  169. elseif(APPLE)
  170. set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
  171. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
  172. set(CPACK_GENERATOR ZIP)
  173. else()
  174. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
  175. set(CPACK_GENERATOR TGZ)
  176. set(CPACK_SOURCE_GENERATOR TGZ)
  177. endif()
  178. include(CPack)
  179. # Add a target to generate API documentation with Doxygen
  180. find_package(Doxygen)
  181. if(DOXYGEN_FOUND)
  182. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in
  183. ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY)
  184. add_custom_target(doc
  185. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile
  186. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
  187. COMMENT "Generating API documentation with Doxygen" VERBATIM
  188. )
  189. endif()