1 cmake_minimum_required(VERSION 2.6)
3 if(${CMAKE_VERSION} STREQUAL "2.8.2")
4 # Bug http://vtk.org/Bug/view.php?id=11020
5 message(WARNING "CMake/CPack version 2.8.2 will not create working .deb packages!")
8 # This can be read from ${PROJECT_NAME} after project() is called
10 set(PROJECT_NAME_CAPITALIZED "Minetest")
13 # Also remember to set PROTOCOL_VERSION in network/networkprotocol.h when releasing
17 set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
19 # Change to false for releases
20 set(DEVELOPMENT_BUILD TRUE)
22 set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
24 set(VERSION_STRING ${VERSION_STRING}-${VERSION_EXTRA})
25 elseif(DEVELOPMENT_BUILD)
26 set(VERSION_STRING "${VERSION_STRING}-dev")
29 message(STATUS "*** Will build version ${VERSION_STRING} ***")
32 # Configuration options
33 set(DEFAULT_RUN_IN_PLACE FALSE)
35 set(DEFAULT_RUN_IN_PLACE TRUE)
37 set(RUN_IN_PLACE ${DEFAULT_RUN_IN_PLACE} CACHE BOOL
38 "Run directly in source directory structure")
41 set(BUILD_CLIENT TRUE CACHE BOOL "Build client")
42 set(BUILD_SERVER FALSE CACHE BOOL "Build server")
45 set(WARN_ALL TRUE CACHE BOOL "Enable -Wall for Release build")
47 if(NOT CMAKE_BUILD_TYPE)
49 set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
54 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
57 # This is done here so that relative search paths are more reasonable
58 find_package(Irrlicht)
67 set(EXAMPLE_CONF_DIR ".")
68 set(LOCALEDIR "locale")
70 set(BUNDLE_NAME ${PROJECT_NAME}.app)
71 set(BUNDLE_PATH "${BUNDLE_NAME}")
72 set(BINDIR ${BUNDLE_NAME}/Contents/MacOS)
73 set(SHAREDIR ${BUNDLE_NAME}/Contents/Resources)
74 set(DOCDIR "${SHAREDIR}/${PROJECT_NAME}")
75 set(EXAMPLE_CONF_DIR ${DOCDIR})
76 set(LOCALEDIR "${SHAREDIR}/locale")
77 elseif(UNIX) # Linux, BSD etc
82 set(EXAMPLE_CONF_DIR ".")
83 set(MANDIR "unix/man")
84 set(XDG_APPS_DIR "unix/applications")
85 set(APPDATADIR "unix/appdata")
86 set(ICONDIR "unix/icons")
87 set(LOCALEDIR "locale")
89 set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
90 set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
91 set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
92 set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
93 set(EXAMPLE_CONF_DIR ${DOCDIR})
94 set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
95 set(APPDATADIR "${CMAKE_INSTALL_PREFIX}/share/appdata")
96 set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
97 set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/locale")
101 set(CUSTOM_SHAREDIR "" CACHE STRING "Directory to install data files into")
102 if(NOT CUSTOM_SHAREDIR STREQUAL "")
103 set(SHAREDIR "${CUSTOM_SHAREDIR}")
104 message(STATUS "Using SHAREDIR=${SHAREDIR}")
107 set(CUSTOM_BINDIR "" CACHE STRING "Directory to install binaries into")
108 if(NOT CUSTOM_BINDIR STREQUAL "")
109 set(BINDIR "${CUSTOM_BINDIR}")
110 message(STATUS "Using BINDIR=${BINDIR}")
113 set(CUSTOM_DOCDIR "" CACHE STRING "Directory to install documentation into")
114 if(NOT CUSTOM_DOCDIR STREQUAL "")
115 set(DOCDIR "${CUSTOM_DOCDIR}")
116 message(STATUS "Using DOCDIR=${DOCDIR}")
119 set(CUSTOM_MANDIR "" CACHE STRING "Directory to install manpages into")
120 if(NOT CUSTOM_MANDIR STREQUAL "")
121 set(MANDIR "${CUSTOM_MANDIR}")
122 message(STATUS "Using MANDIR=${MANDIR}")
125 set(CUSTOM_EXAMPLE_CONF_DIR "" CACHE STRING "Directory to install example config file into")
126 if(NOT CUSTOM_EXAMPLE_CONF_DIR STREQUAL "")
127 set(EXAMPLE_CONF_DIR "${CUSTOM_EXAMPLE_CONF_DIR}")
128 message(STATUS "Using EXAMPLE_CONF_DIR=${EXAMPLE_CONF_DIR}")
131 set(CUSTOM_XDG_APPS_DIR "" CACHE STRING "Directory to install .desktop files into")
132 if(NOT CUSTOM_XDG_APPS_DIR STREQUAL "")
133 set(XDG_APPS_DIR "${CUSTOM_XDG_APPS_DIR}")
134 message(STATUS "Using XDG_APPS_DIR=${XDG_APPS_DIR}")
137 set(CUSTOM_ICONDIR "" CACHE STRING "Directory to install icons into")
138 if(NOT CUSTOM_ICONDIR STREQUAL "")
139 set(ICONDIR "${CUSTOM_ICONDIR}")
140 message(STATUS "Using ICONDIR=${ICONDIR}")
143 set(CUSTOM_LOCALEDIR "" CACHE STRING "Directory to install l10n files into")
144 if(NOT CUSTOM_LOCALEDIR STREQUAL "")
145 set(LOCALEDIR "${CUSTOM_LOCALEDIR}")
146 message(STATUS "Using LOCALEDIR=${LOCALEDIR}")
150 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}")
151 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client" DESTINATION "${SHAREDIR}")
152 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games/minimal" DESTINATION "${SHAREDIR}/games")
153 set(MINETEST_GAME_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/games/minetest_game")
154 if(EXISTS ${MINETEST_GAME_SOURCE} AND IS_DIRECTORY ${MINETEST_GAME_SOURCE})
155 install(FILES ${MINETEST_GAME_SOURCE}/game.conf DESTINATION "${SHAREDIR}/games/minetest_game/")
156 install(FILES ${MINETEST_GAME_SOURCE}/README.txt DESTINATION "${SHAREDIR}/games/minetest_game/")
157 install(DIRECTORY ${MINETEST_GAME_SOURCE}/mods DESTINATION "${SHAREDIR}/games/minetest_game")
158 install(DIRECTORY ${MINETEST_GAME_SOURCE}/menu DESTINATION "${SHAREDIR}/games/minetest_game")
161 #install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/sounds/base/pack" DESTINATION "${SHAREDIR}/sounds/base")
162 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/textures/base/pack" DESTINATION "${SHAREDIR}/textures/base")
165 install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mods/mods_here.txt" DESTINATION "${SHAREDIR}/mods")
166 install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/textures/texture_packs_here.txt" DESTINATION "${SHAREDIR}/textures")
169 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/fonts" DESTINATION "${SHAREDIR}")
171 install(FILES "README.txt" DESTINATION "${DOCDIR}")
172 install(FILES "doc/lua_api.txt" DESTINATION "${DOCDIR}")
173 install(FILES "doc/menu_lua_api.txt" DESTINATION "${DOCDIR}")
174 install(FILES "doc/world_format.txt" DESTINATION "${DOCDIR}")
175 install(FILES "minetest.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")
177 if(UNIX AND NOT APPLE)
178 install(FILES "doc/minetest.6" "doc/minetestserver.6" DESTINATION "${MANDIR}/man6")
179 install(FILES "misc/minetest.desktop" DESTINATION "${XDG_APPS_DIR}")
180 install(FILES "misc/minetest.appdata.xml" DESTINATION "${APPDATADIR}")
181 install(FILES "misc/minetest.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps")
185 install(FILES "misc/minetest-icon.icns" DESTINATION "${SHAREDIR}")
186 install(FILES "misc/Info.plist" DESTINATION "${BUNDLE_PATH}/Contents")
191 # Be sure to add all relevant definitions above this
193 add_subdirectory(src)
198 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An InfiniMiner/Minecraft inspired game")
199 set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
200 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
201 set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
202 set(CPACK_PACKAGE_VENDOR "celeron55")
203 set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")
206 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
207 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win64")
209 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
212 set(CPACK_GENERATOR ZIP)
214 set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
215 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
216 set(CPACK_GENERATOR ZIP)
218 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
219 set(CPACK_GENERATOR TGZ)
220 set(CPACK_SOURCE_GENERATOR TGZ)
226 # Add a target to generate API documentation with Doxygen
227 find_package(Doxygen)
229 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in
230 ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY)
231 add_custom_target(doc
232 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile
233 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc
234 COMMENT "Generating API documentation with Doxygen" VERBATIM