up to date newest commit minetest engine (mirror) https://github.com/minetest/minetest
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.
 
 
 
 
 

324 lines
11 KiB

  1. cmake_minimum_required(VERSION 3.5)
  2. # This can be read from ${PROJECT_NAME} after project() is called
  3. project(minetest)
  4. set(PROJECT_NAME_CAPITALIZED "Minetest")
  5. set(CMAKE_CXX_STANDARD 11)
  6. set(GCC_MINIMUM_VERSION "4.8")
  7. set(CLANG_MINIMUM_VERSION "3.4")
  8. # Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing
  9. set(VERSION_MAJOR 5)
  10. set(VERSION_MINOR 4)
  11. set(VERSION_PATCH 0)
  12. set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
  13. # Change to false for releases
  14. set(DEVELOPMENT_BUILD TRUE)
  15. set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
  16. if(VERSION_EXTRA)
  17. set(VERSION_STRING ${VERSION_STRING}-${VERSION_EXTRA})
  18. elseif(DEVELOPMENT_BUILD)
  19. set(VERSION_STRING "${VERSION_STRING}-dev")
  20. endif()
  21. if (CMAKE_BUILD_TYPE STREQUAL Debug)
  22. # Append "-debug" to version string
  23. set(VERSION_STRING "${VERSION_STRING}-debug")
  24. endif()
  25. message(STATUS "*** Will build version ${VERSION_STRING} ***")
  26. # Configuration options
  27. set(DEFAULT_RUN_IN_PLACE FALSE)
  28. if(WIN32)
  29. set(DEFAULT_RUN_IN_PLACE TRUE)
  30. endif()
  31. set(RUN_IN_PLACE ${DEFAULT_RUN_IN_PLACE} CACHE BOOL
  32. "Run directly in source directory structure")
  33. set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
  34. set(BUILD_SERVER FALSE CACHE BOOL "Build server")
  35. set(BUILD_UNITTESTS TRUE CACHE BOOL "Build unittests")
  36. set(WARN_ALL TRUE CACHE BOOL "Enable -Wall for Release build")
  37. if(NOT CMAKE_BUILD_TYPE)
  38. # Default to release
  39. set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
  40. endif()
  41. # Included stuff
  42. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
  43. # This is done here so that relative search paths are more reasonable
  44. find_package(Irrlicht)
  45. # Installation
  46. if(WIN32)
  47. set(SHAREDIR ".")
  48. set(BINDIR "bin")
  49. set(DOCDIR "doc")
  50. set(EXAMPLE_CONF_DIR ".")
  51. set(LOCALEDIR "locale")
  52. elseif(APPLE)
  53. set(BUNDLE_NAME ${PROJECT_NAME}.app)
  54. set(BUNDLE_PATH "${BUNDLE_NAME}")
  55. set(BINDIR ${BUNDLE_NAME}/Contents/MacOS)
  56. set(SHAREDIR ${BUNDLE_NAME}/Contents/Resources)
  57. set(DOCDIR "${SHAREDIR}/${PROJECT_NAME}")
  58. set(EXAMPLE_CONF_DIR ${DOCDIR})
  59. set(LOCALEDIR "${SHAREDIR}/locale")
  60. elseif(UNIX) # Linux, BSD etc
  61. if(RUN_IN_PLACE)
  62. set(SHAREDIR ".")
  63. set(BINDIR "bin")
  64. set(DOCDIR "doc")
  65. set(EXAMPLE_CONF_DIR ".")
  66. set(MANDIR "unix/man")
  67. set(XDG_APPS_DIR "unix/applications")
  68. set(APPDATADIR "unix/metainfo")
  69. set(ICONDIR "unix/icons")
  70. set(LOCALEDIR "locale")
  71. else()
  72. set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
  73. set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
  74. set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
  75. set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
  76. set(EXAMPLE_CONF_DIR ${DOCDIR})
  77. set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
  78. set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/metainfo")
  79. set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
  80. set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/locale")
  81. endif()
  82. endif()
  83. set(CUSTOM_SHAREDIR "" CACHE STRING "Directory to install data files into")
  84. if(NOT CUSTOM_SHAREDIR STREQUAL "")
  85. set(SHAREDIR "${CUSTOM_SHAREDIR}")
  86. message(STATUS "Using SHAREDIR=${SHAREDIR}")
  87. endif()
  88. set(CUSTOM_BINDIR "" CACHE STRING "Directory to install binaries into")
  89. if(NOT CUSTOM_BINDIR STREQUAL "")
  90. set(BINDIR "${CUSTOM_BINDIR}")
  91. message(STATUS "Using BINDIR=${BINDIR}")
  92. endif()
  93. set(CUSTOM_DOCDIR "" CACHE STRING "Directory to install documentation into")
  94. if(NOT CUSTOM_DOCDIR STREQUAL "")
  95. set(DOCDIR "${CUSTOM_DOCDIR}")
  96. if(NOT RUN_IN_PLACE)
  97. set(EXAMPLE_CONF_DIR ${DOCDIR})
  98. endif()
  99. message(STATUS "Using DOCDIR=${DOCDIR}")
  100. endif()
  101. set(CUSTOM_MANDIR "" CACHE STRING "Directory to install manpages into")
  102. if(NOT CUSTOM_MANDIR STREQUAL "")
  103. set(MANDIR "${CUSTOM_MANDIR}")
  104. message(STATUS "Using MANDIR=${MANDIR}")
  105. endif()
  106. set(CUSTOM_EXAMPLE_CONF_DIR "" CACHE STRING "Directory to install example config file into")
  107. if(NOT CUSTOM_EXAMPLE_CONF_DIR STREQUAL "")
  108. set(EXAMPLE_CONF_DIR "${CUSTOM_EXAMPLE_CONF_DIR}")
  109. message(STATUS "Using EXAMPLE_CONF_DIR=${EXAMPLE_CONF_DIR}")
  110. endif()
  111. set(CUSTOM_XDG_APPS_DIR "" CACHE STRING "Directory to install .desktop files into")
  112. if(NOT CUSTOM_XDG_APPS_DIR STREQUAL "")
  113. set(XDG_APPS_DIR "${CUSTOM_XDG_APPS_DIR}")
  114. message(STATUS "Using XDG_APPS_DIR=${XDG_APPS_DIR}")
  115. endif()
  116. set(CUSTOM_ICONDIR "" CACHE STRING "Directory to install icons into")
  117. if(NOT CUSTOM_ICONDIR STREQUAL "")
  118. set(ICONDIR "${CUSTOM_ICONDIR}")
  119. message(STATUS "Using ICONDIR=${ICONDIR}")
  120. endif()
  121. set(CUSTOM_LOCALEDIR "" CACHE STRING "Directory to install l10n files into")
  122. if(NOT CUSTOM_LOCALEDIR STREQUAL "")
  123. set(LOCALEDIR "${CUSTOM_LOCALEDIR}")
  124. message(STATUS "Using LOCALEDIR=${LOCALEDIR}")
  125. endif()
  126. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}")
  127. if(RUN_IN_PLACE)
  128. install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mods/mods_here.txt" DESTINATION "${SHAREDIR}/mods")
  129. install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/textures/texture_packs_here.txt" DESTINATION "${SHAREDIR}/textures")
  130. endif()
  131. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games/minetest_game" DESTINATION "${SHAREDIR}/games/"
  132. COMPONENT "SUBGAME_MINETEST_GAME" OPTIONAL PATTERN ".git*" EXCLUDE )
  133. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games/devtest" DESTINATION "${SHAREDIR}/games/"
  134. COMPONENT "SUBGAME_MINIMAL" OPTIONAL PATTERN ".git*" EXCLUDE )
  135. if(BUILD_CLIENT)
  136. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client/shaders" DESTINATION "${SHAREDIR}/client")
  137. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/textures/base/pack" DESTINATION "${SHAREDIR}/textures/base")
  138. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/fonts" DESTINATION "${SHAREDIR}")
  139. if(RUN_IN_PLACE)
  140. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/clientmods" DESTINATION "${SHAREDIR}")
  141. install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client/serverlist" DESTINATION "${SHAREDIR}/client")
  142. endif()
  143. endif()
  144. install(FILES "README.md" DESTINATION "${DOCDIR}" COMPONENT "Docs")
  145. install(FILES "doc/lua_api.txt" DESTINATION "${DOCDIR}" COMPONENT "Docs")
  146. install(FILES "doc/client_lua_api.txt" DESTINATION "${DOCDIR}" COMPONENT "Docs")
  147. install(FILES "doc/menu_lua_api.txt" DESTINATION "${DOCDIR}" COMPONENT "Docs")
  148. install(FILES "doc/texture_packs.txt" DESTINATION "${DOCDIR}" COMPONENT "Docs")
  149. install(FILES "doc/world_format.txt" DESTINATION "${DOCDIR}" COMPONENT "Docs")
  150. install(FILES "minetest.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")
  151. if(UNIX AND NOT APPLE)
  152. install(FILES "doc/minetest.6" "doc/minetestserver.6" DESTINATION "${MANDIR}/man6")
  153. install(FILES "misc/net.minetest.minetest.desktop" DESTINATION "${XDG_APPS_DIR}")
  154. install(FILES "misc/net.minetest.minetest.appdata.xml" DESTINATION "${APPDATADIR}")
  155. install(FILES "misc/minetest.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps")
  156. install(FILES "misc/minetest-xorg-icon-128.png"
  157. DESTINATION "${ICONDIR}/hicolor/128x128/apps"
  158. RENAME "minetest.png")
  159. endif()
  160. if(APPLE)
  161. install(FILES "misc/minetest-icon.icns" DESTINATION "${SHAREDIR}")
  162. install(FILES "misc/Info.plist" DESTINATION "${BUNDLE_PATH}/Contents")
  163. endif()
  164. # Library pack
  165. find_package(GMP REQUIRED)
  166. find_package(Json REQUIRED)
  167. find_package(Lua REQUIRED)
  168. # JsonCPP doesn't compile well on GCC 4.8
  169. if(NOT ENABLE_SYSTEM_JSONCPP)
  170. set(GCC_MINIMUM_VERSION "4.9")
  171. endif()
  172. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  173. if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${GCC_MINIMUM_VERSION}")
  174. message(FATAL_ERROR "Insufficient gcc version, found ${CMAKE_CXX_COMPILER_VERSION}. "
  175. "Version ${GCC_MINIMUM_VERSION} or higher is required.")
  176. endif()
  177. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  178. if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${CLANG_MINIMUM_VERSION}")
  179. message(FATAL_ERROR "Insufficient clang version, found ${CMAKE_CXX_COMPILER_VERSION}. "
  180. "Version ${CLANG_MINIMUM_VERSION} or higher is required.")
  181. endif()
  182. endif()
  183. # Subdirectories
  184. # Be sure to add all relevant definitions above this
  185. add_subdirectory(src)
  186. # CPack
  187. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A free open-source voxel game engine with easy modding and game creation.")
  188. set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
  189. set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
  190. set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
  191. set(CPACK_PACKAGE_VENDOR "celeron55")
  192. set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")
  193. include(CPackComponent)
  194. cpack_add_component(Docs
  195. DISPLAY_NAME "Documentation"
  196. DESCRIPTION "Documentation about Minetest and Minetest modding"
  197. )
  198. cpack_add_component(SUBGAME_MINETEST_GAME
  199. DISPLAY_NAME "Minetest Game"
  200. DESCRIPTION "The default game bundled in the Minetest engine. Mainly used as a modding base."
  201. GROUP "Games"
  202. )
  203. cpack_add_component(SUBGAME_MINIMAL
  204. DISPLAY_NAME "Development Test"
  205. DESCRIPTION "A basic testing environment used for engine development and sometimes for testing mods."
  206. DISABLED #DISABLED does not mean it is disabled, and is just not selected by default.
  207. GROUP "Games"
  208. )
  209. cpack_add_component_group(Subgames
  210. DESCRIPTION "Games for the Minetest engine."
  211. )
  212. if(WIN32)
  213. # Include all dynamically linked runtime libaries such as MSVCRxxx.dll
  214. include(InstallRequiredSystemLibraries)
  215. if(RUN_IN_PLACE)
  216. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  217. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win64")
  218. else()
  219. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
  220. endif()
  221. set(CPACK_GENERATOR ZIP)
  222. else()
  223. set(CPACK_GENERATOR WIX)
  224. set(CPACK_PACKAGE_NAME "${PROJECT_NAME_CAPITALIZED}")
  225. set(CPACK_PACKAGE_INSTALL_DIRECTORY ".")
  226. set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME} "${PROJECT_NAME_CAPITALIZED}")
  227. set(CPACK_CREATE_DESKTOP_LINKS ${PROJECT_NAME})
  228. set(CPACK_PACKAGING_INSTALL_PREFIX "/${PROJECT_NAME_CAPITALIZED}")
  229. set(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/misc/minetest-icon.ico")
  230. # Supported languages can be found at
  231. # http://wixtoolset.org/documentation/manual/v3/wixui/wixui_localization.html
  232. #set(CPACK_WIX_CULTURES "ar-SA,bg-BG,ca-ES,hr-HR,cs-CZ,da-DK,nl-NL,en-US,et-EE,fi-FI,fr-FR,de-DE")
  233. set(CPACK_WIX_UI_BANNER "${CMAKE_CURRENT_SOURCE_DIR}/misc/CPACK_WIX_UI_BANNER.BMP")
  234. set(CPACK_WIX_UI_DIALOG "${CMAKE_CURRENT_SOURCE_DIR}/misc/CPACK_WIX_UI_DIALOG.BMP")
  235. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/doc/lgpl-2.1.txt")
  236. # The correct way would be to include both x32 and x64 into one installer
  237. # and install the appropriate one.
  238. # CMake does not support that, so there are two separate GUID's
  239. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  240. set(CPACK_WIX_UPGRADE_GUID "745A0FB3-5552-44CA-A587-A91C397CCC56")
  241. else()
  242. set(CPACK_WIX_UPGRADE_GUID "814A2E2D-2779-4BBD-9ACD-FC3BD51FBBA2")
  243. endif()
  244. endif()
  245. elseif(APPLE)
  246. set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
  247. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
  248. set(CPACK_GENERATOR ZIP)
  249. else()
  250. set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
  251. set(CPACK_GENERATOR TGZ)
  252. set(CPACK_SOURCE_GENERATOR TGZ)
  253. endif()
  254. include(CPack)
  255. # Add a target to generate API documentation with Doxygen
  256. find_package(Doxygen)
  257. if(DOXYGEN_FOUND)
  258. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in
  259. ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY)
  260. add_custom_target(doc
  261. ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile
  262. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
  263. COMMENT "Generating API documentation with Doxygen" VERBATIM
  264. )
  265. endif()