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(${CMAKE_VERSION} STREQUAL "2.8.2")
7 # This can be read from ${PROJECT_NAME} after project() is called
10 set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
12 # Also remember to set PROTOCOL_VERSION in clientserver.h when releasing
17 set(VERSION_PATCH ${VERSION_PATCH}-${VERSION_EXTRA})
19 # Comment the following line during release
20 set(VERSION_PATCH ${VERSION_PATCH}-dev)
22 set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
24 MESSAGE(STATUS "*** Will build version ${VERSION_STRING} ***")
26 # Configuration options
29 set(RUN_IN_PLACE 1 CACHE BOOL "Run directly in source directory structure")
31 set(RUN_IN_PLACE 0 CACHE BOOL "Run directly in source directory structure")
34 # RUN_IN_PLACE is exported as a #define value, ensure it's 1/0 instead of ON/OFF
41 set(BUILD_CLIENT 1 CACHE BOOL "Build client")
43 set(BUILD_SERVER 0 CACHE BOOL "Build server")
45 set(BUILD_SERVER 1 CACHE BOOL "Build server")
48 set(WARN_ALL 1 CACHE BOOL "Enable -Wall for Release build")
50 if(NOT CMAKE_BUILD_TYPE)
52 set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
56 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
57 include(${CMAKE_SOURCE_DIR}/cmake/Modules/misc.cmake)
59 # This is done here so that relative search paths are more reasnable
60 find_package(Irrlicht)
70 set(EXAMPLE_CONF_DIR ".")
71 set(LOCALEDIR "locale")
73 # Random placeholders; this isn't usually used and may not work
74 # See https://github.com/toabi/minetest-mac/
75 set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
77 set(DOCDIR "share/doc/${PROJECT_NAME}")
78 set(EXAMPLE_CONF_DIR ${DOCDIR})
79 set(LOCALEDIR "locale")
80 elseif(UNIX) # Linux, BSD etc
85 set(EXAMPLE_CONF_DIR ".")
86 set(MANDIR "unix/man")
87 set(XDG_APPS_DIR "unix/applications")
88 set(ICONDIR "unix/icons")
89 set(LOCALEDIR "locale")
91 set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
92 set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
93 set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
94 set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
95 set(EXAMPLE_CONF_DIR ${DOCDIR})
96 set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
97 set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
98 set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/locale")
102 set(CUSTOM_SHAREDIR "" CACHE STRING "Directory to install data files into")
103 if(NOT CUSTOM_SHAREDIR STREQUAL "")
104 set(SHAREDIR "${CUSTOM_SHAREDIR}")
105 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}")
112 set(CUSTOM_DOCDIR "" CACHE STRING "Directory to install documentation into")
113 if(NOT CUSTOM_DOCDIR STREQUAL "")
114 set(DOCDIR "${CUSTOM_DOCDIR}")
115 message(STATUS "Using DOCDIR=${DOCDIR}")
117 set(CUSTOM_MANDIR "" CACHE STRING "Directory to install manpages into")
118 if(NOT CUSTOM_MANDIR STREQUAL "")
119 set(MANDIR "${CUSTOM_MANDIR}")
120 message(STATUS "Using MANDIR=${MANDIR}")
122 set(CUSTOM_EXAMPLE_CONF_DIR "" CACHE STRING "Directory to install example config file into")
123 if(NOT CUSTOM_EXAMPLE_CONF_DIR STREQUAL "")
124 set(EXAMPLE_CONF_DIR "${CUSTOM_EXAMPLE_CONF_DIR}")
125 message(STATUS "Using EXAMPLE_CONF_DIR=${EXAMPLE_CONF_DIR}")
127 set(CUSTOM_XDG_APPS_DIR "" CACHE STRING "Directory to install .desktop files into")
128 if(NOT CUSTOM_XDG_APPS_DIR STREQUAL "")
129 set(XDG_APPS_DIR "${CUSTOM_XDG_APPS_DIR}")
130 message(STATUS "Using XDG_APPS_DIR=${XDG_APPS_DIR}")
132 set(CUSTOM_ICONDIR "" CACHE STRING "Directory to install icons into")
133 if(NOT CUSTOM_ICONDIR STREQUAL "")
134 set(ICONDIR "${CUSTOM_ICONDIR}")
135 message(STATUS "Using ICONDIR=${ICONDIR}")
137 set(CUSTOM_LOCALEDIR "" CACHE STRING "Directory to install l10n files into")
138 if(NOT CUSTOM_LOCALEDIR STREQUAL "")
139 set(LOCALEDIR "${CUSTOM_LOCALEDIR}")
140 message(STATUS "Using LOCALEDIR=${LOCALEDIR}")
143 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}")
144 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client" DESTINATION "${SHAREDIR}")
145 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games/minimal" DESTINATION "${SHAREDIR}/games")
146 set(MINETEST_GAME_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/games/minetest_game")
147 if(EXISTS ${MINETEST_GAME_SOURCE} AND IS_DIRECTORY ${MINETEST_GAME_SOURCE})
148 install(FILES ${MINETEST_GAME_SOURCE}/game.conf DESTINATION "${SHAREDIR}/games/minetest_game/")
149 install(FILES ${MINETEST_GAME_SOURCE}/README.txt DESTINATION "${SHAREDIR}/games/minetest_game/")
150 install(DIRECTORY ${MINETEST_GAME_SOURCE}/mods DESTINATION "${SHAREDIR}/games/minetest_game")
151 install(DIRECTORY ${MINETEST_GAME_SOURCE}/menu DESTINATION "${SHAREDIR}/games/minetest_game")
154 #install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/sounds/base/pack" DESTINATION "${SHAREDIR}/sounds/base")
155 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/textures/base/pack" DESTINATION "${SHAREDIR}/textures/base")
158 install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mods/mods_here.txt" DESTINATION "${SHAREDIR}/mods")
159 install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/textures/texture_packs_here.txt" DESTINATION "${SHAREDIR}/textures")
162 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/fonts" DESTINATION "${SHAREDIR}")
164 install(FILES "README.txt" DESTINATION "${DOCDIR}")
165 install(FILES "doc/lua_api.txt" DESTINATION "${DOCDIR}")
166 install(FILES "doc/mapformat.txt" DESTINATION "${DOCDIR}")
167 install(FILES "minetest.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")
170 install(FILES "doc/minetest.6" "doc/minetestserver.6" DESTINATION "${MANDIR}/man6")
171 install(FILES "misc/minetest.desktop" DESTINATION "${XDG_APPS_DIR}")
172 install(FILES "misc/minetest-icon.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps")
177 # Be sure to add all relevant definitions above this
180 add_subdirectory(src)
184 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An InfiniMiner/Minecraft inspired game")
185 set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
186 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
187 set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
188 set(CPACK_PACKAGE_VENDOR "celeron55")
189 set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")
192 # For some reason these aren't copied otherwise
193 # NOTE: For some reason now it seems to work without these
195 # install(FILES bin/minetest.exe DESTINATION bin)
198 # install(FILES bin/minetestserver.exe DESTINATION bin)
201 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
203 set(CPACK_GENERATOR ZIP)
205 # This might be needed for some installer
206 #set(CPACK_PACKAGE_EXECUTABLES bin/minetest.exe "Minetest" bin/minetestserver.exe "Minetest Server")
209 # see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29
211 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
212 set(CPACK_PACKAGE_ICON "")
213 set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
214 set(CPACK_BUNDLE_ICON "")
215 set(CPACK_BUNDLE_PLIST "")
216 set(CPACK_BUNDLE_STARTUP_COMMAND "Contents/MacOS/${PROJECT_NAME}")
217 set(CPACK_GENERATOR "Bundle")
219 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
220 set(CPACK_GENERATOR TGZ)
221 set(CPACK_SOURCE_GENERATOR TGZ)