e07ca8cef17767455455e7d4239b09190bb83749
[oweals/minetest.git] / CMakeLists.txt
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")
6
7 # This can be read from ${PROJECT_NAME} after project() is called
8 project(minetest)
9
10 # Also remember to set PROTOCOL_VERSION in clientserver.h when releasing
11 set(VERSION_MAJOR 0)
12 set(VERSION_MINOR 4)
13 set(VERSION_PATCH dev-20111113)
14 set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
15
16 MESSAGE(STATUS "*** Will build version ${VERSION_STRING} ***")
17
18 # Configuration options
19
20 if(WIN32)
21         set(RUN_IN_PLACE 1 CACHE BOOL "Run directly in source directory structure")
22 else()
23         set(RUN_IN_PLACE 0 CACHE BOOL "Run directly in source directory structure")
24 endif()
25
26 set(BUILD_CLIENT 1 CACHE BOOL "Build client")
27 if(WIN32)
28         set(BUILD_SERVER 0 CACHE BOOL "Build server")
29 else()
30         set(BUILD_SERVER 1 CACHE BOOL "Build server")
31 endif()
32
33 set(WARN_ALL 1 CACHE BOOL "Enable -Wall for Release build")
34
35 if(NOT CMAKE_BUILD_TYPE)
36         # Default to release
37         set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE)
38 endif()
39
40 # Included stuff
41 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
42 include(${CMAKE_SOURCE_DIR}/cmake/Modules/misc.cmake)
43
44 # This is done here so that relative search paths are more reasnable
45 find_package(Irrlicht)
46
47 #
48 # Installation
49 #
50
51 if(WIN32)
52         set(DATADIR "data")
53         set(BINDIR "bin")
54         set(DOCDIR "doc")
55         set(EXAMPLE_CONF_DIR ".")
56 elseif(APPLE)
57         # random placeholders
58         set(DATADIR "share/${PROJECT_NAME}")
59         set(BINDIR "bin")
60         set(DOCDIR "share/doc/${PROJECT_NAME}")
61         set(EXAMPLE_CONF_DIR ".")
62 elseif(UNIX) # Linux, BSD etc
63         set(DATADIR "share/${PROJECT_NAME}")
64         set(BINDIR "bin")
65         set(DOCDIR "share/doc/${PROJECT_NAME}")
66         set(EXAMPLE_CONF_DIR "share/doc/${PROJECT_NAME}")
67 endif()
68
69 install(FILES "README.txt" DESTINATION "${DOCDIR}")
70 install(FILES "doc/changelog.txt" DESTINATION "${DOCDIR}")
71 install(FILES "minetest.conf.example" DESTINATION "${DOCDIR}")
72
73 #
74 # Subdirectories
75 # Be sure to add all relevant definitions above this
76 #
77
78 add_subdirectory(src)
79
80 # CPack
81
82 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An InfiniMiner/Minecraft inspired game")
83 set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
84 set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
85 set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
86 set(CPACK_PACKAGE_VENDOR "celeron55")
87 set(CPACK_PACKAGE_CONTACT "Perttu Ahola <celeron55@gmail.com>")
88
89 if(WIN32)
90         # For some reason these aren't copied otherwise
91         # NOTE: For some reason now it seems to work without these
92         #if(BUILD_CLIENT)
93         #       install(FILES bin/minetest.exe DESTINATION bin)
94         #endif()
95         #if(BUILD_SERVER)
96         #       install(FILES bin/minetestserver.exe DESTINATION bin)
97         #endif()
98
99         set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32")
100
101         set(CPACK_GENERATOR ZIP)
102
103         # This might be needed for some installer
104         #set(CPACK_PACKAGE_EXECUTABLES bin/minetest.exe "Minetest" bin/minetestserver.exe "Minetest Server")
105 elseif(APPLE)
106         # TODO
107         # see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29
108         #
109         set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx")
110         set(CPACK_PACKAGE_ICON "")
111         set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
112         set(CPACK_BUNDLE_ICON "")
113         set(CPACK_BUNDLE_PLIST "")
114         set(CPACK_BUNDLE_STARTUP_COMMAND "Contents/MacOS/${PROJECT_NAME}")
115         set(CPACK_GENERATOR "Bundle")
116 else()
117         set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux")
118         set(CPACK_GENERATOR TGZ)
119         set(CPACK_SOURCE_GENERATOR TGZ)
120 endif()
121
122 include(CPack)
123