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
15 set(VERSION_PATCH 4-dev)
17 set(VERSION_PATCH ${VERSION_PATCH}-${VERSION_EXTRA})
19 set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
21 MESSAGE(STATUS "*** Will build version ${VERSION_STRING} ***")
23 # Configuration options
26 set(RUN_IN_PLACE 1 CACHE BOOL "Run directly in source directory structure")
28 set(RUN_IN_PLACE 0 CACHE BOOL "Run directly in source directory structure")
31 set(BUILD_CLIENT 1 CACHE BOOL "Build client")
33 set(BUILD_SERVER 0 CACHE BOOL "Build server")
35 set(BUILD_SERVER 1 CACHE BOOL "Build server")
38 set(WARN_ALL 1 CACHE BOOL "Enable -Wall for Release build")
40 if(NOT CMAKE_BUILD_TYPE)
42 set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
46 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
47 include(${CMAKE_SOURCE_DIR}/cmake/Modules/misc.cmake)
49 # This is done here so that relative search paths are more reasnable
50 find_package(Irrlicht)
60 set(EXAMPLE_CONF_DIR ".")
61 set(LOCALEDIR "locale")
63 # Random placeholders; this isn't usually used and may not work
64 # See https://github.com/toabi/minetest-mac/
65 set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
67 set(DOCDIR "share/doc/${PROJECT_NAME}")
68 set(EXAMPLE_CONF_DIR ${DOCDIR})
69 set(LOCALEDIR "locale")
70 elseif(UNIX) # Linux, BSD etc
75 set(EXAMPLE_CONF_DIR ".")
76 set(MANDIR "unix/man")
77 set(XDG_APPS_DIR "unix/applications")
78 set(ICONDIR "unix/icons")
79 set(LOCALEDIR "locale")
81 set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
82 set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
83 set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
84 set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
85 set(EXAMPLE_CONF_DIR ${DOCDIR})
86 set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
87 set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
88 set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/locale")
92 set(CUSTOM_SHAREDIR "" CACHE STRING "Directory to install data files into")
93 if(NOT CUSTOM_SHAREDIR STREQUAL "")
94 set(SHAREDIR "${CUSTOM_SHAREDIR}")
95 message(STATUS "Using SHAREDIR=${SHAREDIR}")
97 set(CUSTOM_BINDIR "" CACHE STRING "Directory to install binaries into")
98 if(NOT CUSTOM_BINDIR STREQUAL "")
99 set(BINDIR "${CUSTOM_BINDIR}")
100 message(STATUS "Using BINDIR=${BINDIR}")
102 set(CUSTOM_DOCDIR "" CACHE STRING "Directory to install documentation into")
103 if(NOT CUSTOM_DOCDIR STREQUAL "")
104 set(DOCDIR "${CUSTOM_DOCDIR}")
105 message(STATUS "Using DOCDIR=${DOCDIR}")
107 set(CUSTOM_MANDIR "" CACHE STRING "Directory to install manpages into")
108 if(NOT CUSTOM_MANDIR STREQUAL "")
109 set(MANDIR "${CUSTOM_MANDIR}")
110 message(STATUS "Using MANDIR=${MANDIR}")
112 set(CUSTOM_EXAMPLE_CONF_DIR "" CACHE STRING "Directory to install example config file into")
113 if(NOT CUSTOM_EXAMPLE_CONF_DIR STREQUAL "")
114 set(EXAMPLE_CONF_DIR "${CUSTOM_EXAMPLE_CONF_DIR}")
115 message(STATUS "Using EXAMPLE_CONF_DIR=${EXAMPLE_CONF_DIR}")
117 set(CUSTOM_XDG_APPS_DIR "" CACHE STRING "Directory to install .desktop files into")
118 if(NOT CUSTOM_XDG_APPS_DIR STREQUAL "")
119 set(XDG_APPS_DIR "${CUSTOM_XDG_APPS_DIR}")
120 message(STATUS "Using XDG_APPS_DIR=${XDG_APPS_DIR}")
122 set(CUSTOM_ICONDIR "" CACHE STRING "Directory to install icons into")
123 if(NOT CUSTOM_ICONDIR STREQUAL "")
124 set(ICONDIR "${CUSTOM_ICONDIR}")
125 message(STATUS "Using ICONDIR=${ICONDIR}")
127 set(CUSTOM_LOCALEDIR "" CACHE STRING "Directory to install l10n files into")
128 if(NOT CUSTOM_LOCALEDIR STREQUAL "")
129 set(LOCALEDIR "${CUSTOM_LOCALEDIR}")
130 message(STATUS "Using LOCALEDIR=${LOCALEDIR}")
133 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}")
134 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/client" DESTINATION "${SHAREDIR}")
135 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games/minimal" DESTINATION "${SHAREDIR}/games")
136 set(MINETEST_GAME_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/games/minetest_game")
137 if(EXISTS ${MINETEST_GAME_SOURCE} AND IS_DIRECTORY ${MINETEST_GAME_SOURCE})
138 install(FILES ${MINETEST_GAME_SOURCE}/game.conf DESTINATION "${SHAREDIR}/games/minetest_game/")
139 install(FILES ${MINETEST_GAME_SOURCE}/README.txt DESTINATION "${SHAREDIR}/games/minetest_game/")
140 install(DIRECTORY ${MINETEST_GAME_SOURCE}/mods DESTINATION "${SHAREDIR}/games/minetest_game")
143 #install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/sounds/base/pack" DESTINATION "${SHAREDIR}/sounds/base")
144 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/textures/base/pack" DESTINATION "${SHAREDIR}/textures/base")
147 install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/mods/minetest/mods_here.txt" DESTINATION "${SHAREDIR}/mods/minetest")
148 install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/textures/all/textures_here.txt" DESTINATION "${SHAREDIR}/textures/all")
151 install(FILES "README.txt" DESTINATION "${DOCDIR}")
152 install(FILES "doc/lua_api.txt" DESTINATION "${DOCDIR}")
153 install(FILES "doc/mapformat.txt" DESTINATION "${DOCDIR}")
154 install(FILES "minetest.conf.example" DESTINATION "${EXAMPLE_CONF_DIR}")
157 install(FILES "doc/minetest.6" "doc/minetestserver.6" DESTINATION "${MANDIR}/man6")
158 install(FILES "misc/minetest.desktop" DESTINATION "${XDG_APPS_DIR}")
159 install(FILES "misc/minetest-icon.svg" DESTINATION "${ICONDIR}/hicolor/scalable/apps")
164 # Be sure to add all relevant definitions above this
167 add_subdirectory(src)
171 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An InfiniMiner/Minecraft inspired game")
172 set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
173 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
174 set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
175 set(CPACK_PACKAGE_VENDOR "celeron55")
176 set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")
179 # For some reason these aren't copied otherwise
180 # NOTE: For some reason now it seems to work without these
182 # install(FILES bin/minetest.exe DESTINATION bin)
185 # install(FILES bin/minetestserver.exe DESTINATION bin)
188 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
190 set(CPACK_GENERATOR ZIP)
192 # This might be needed for some installer
193 #set(CPACK_PACKAGE_EXECUTABLES bin/minetest.exe "Minetest" bin/minetestserver.exe "Minetest Server")
196 # see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29
198 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
199 set(CPACK_PACKAGE_ICON "")
200 set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
201 set(CPACK_BUNDLE_ICON "")
202 set(CPACK_BUNDLE_PLIST "")
203 set(CPACK_BUNDLE_STARTUP_COMMAND "Contents/MacOS/${PROJECT_NAME}")
204 set(CPACK_GENERATOR "Bundle")
206 set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
207 set(CPACK_GENERATOR TGZ)
208 set(CPACK_SOURCE_GENERATOR TGZ)