]> git.lizzy.rs Git - dragonfireclient.git/blob - src/CMakeLists.txt
CMake stuff works now on linux and windows... and should be possible to make to work...
[dragonfireclient.git] / src / CMakeLists.txt
1 project(minetest)
2 cmake_minimum_required( VERSION 2.6 )
3
4 if(RUN_IN_PLACE)
5         add_definitions ( -DRUN_IN_PLACE )
6 endif(RUN_IN_PLACE)
7
8 if(UNIX)
9         # Unix
10         if(BUILD_CLIENT)
11                 find_package(X11 REQUIRED)
12                 find_package(OpenGL REQUIRED)
13                 find_package(JPEG REQUIRED)
14                 find_package(BZip2 REQUIRED)
15         endif(BUILD_CLIENT)
16         find_package(ZLIB REQUIRED)
17         set(SERVER_PLATFORM_LIBS -lpthread)
18 elseif(WIN32)
19         # Windows
20         # Surpress some warnings
21         add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
22         # Zlib stuff
23         set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
24                         CACHE PATH "Zlib include directory")
25         set(ZLIB_LIBRARIES "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.lib"
26                         CACHE PATH "Path to zlibwapi.lib")
27         set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll"
28                         CACHE PATH "Path to zlibwapi.dll (for installation)")
29 endif()
30
31 configure_file(
32         "${PROJECT_SOURCE_DIR}/config.h.in"
33         "${PROJECT_BINARY_DIR}/config.h"
34 )
35
36 set(minetest_SRCS
37         porting.cpp
38         guiMessageMenu.cpp
39         materials.cpp
40         guiTextInputMenu.cpp
41         guiInventoryMenu.cpp
42         irrlichtwrapper.cpp
43         guiPauseMenu.cpp
44         defaultsettings.cpp
45         mapnode.cpp
46         tile.cpp
47         voxel.cpp
48         mapblockobject.cpp
49         inventory.cpp
50         debug.cpp
51         serialization.cpp
52         light.cpp
53         filesys.cpp
54         connection.cpp
55         environment.cpp
56         client.cpp
57         server.cpp
58         socket.cpp
59         mapblock.cpp
60         mapsector.cpp
61         heightmap.cpp
62         map.cpp
63         player.cpp
64         utility.cpp
65         main.cpp
66         test.cpp
67 )
68
69 set(minetestserver_SRCS
70         porting.cpp
71         materials.cpp
72         defaultsettings.cpp
73         mapnode.cpp
74         voxel.cpp
75         mapblockobject.cpp
76         inventory.cpp
77         debug.cpp
78         serialization.cpp
79         light.cpp
80         filesys.cpp
81         connection.cpp
82         environment.cpp
83         server.cpp
84         socket.cpp
85         mapblock.cpp
86         mapsector.cpp
87         heightmap.cpp
88         map.cpp
89         player.cpp
90         utility.cpp
91         servermain.cpp
92         test.cpp
93 )
94
95 include_directories(
96         ${PROJECT_BINARY_DIR}
97         ${IRRLICHT_INCLUDE_DIR}
98         ${ZLIB_INCLUDE_DIR}
99         ${CMAKE_BUILD_TYPE}
100         "${PROJECT_SOURCE_DIR}/jthread"
101 )
102
103 set(EXECUTABLE_OUTPUT_PATH ../bin)
104
105 if(BUILD_CLIENT)
106         add_executable(minetest ${minetest_SRCS})
107         target_link_libraries(
108                 minetest
109                 ${ZLIB_LIBRARIES}
110                 ${IRRLICHT_LIBRARY}
111                 ${OPENGL_LIBRARIES}
112                 ${JPEG_LIBRARIES}
113                 ${BZIP2_LIBRARIES}
114                 jthread
115         )
116 endif(BUILD_CLIENT)
117 if(BUILD_SERVER)
118         add_executable(minetestserver ${minetestserver_SRCS})
119         target_link_libraries(
120                 minetestserver
121                 ${ZLIB_LIBRARIES}
122                 jthread
123                 ${SERVER_PLATFORM_LIBS}
124         )
125 endif(BUILD_SERVER)
126
127 # Set some optimizations and tweaks
128 if( UNIX )
129         # Unix
130         
131         set(UNIX_FLAGS "-Wall")
132
133         if(BUILD_CLIENT)
134                 set_target_properties(minetest PROPERTIES COMPILE_FLAGS
135                                 "${UNIX_FLAGS}")
136         endif(BUILD_CLIENT)
137
138         if(BUILD_SERVER)
139                 set_target_properties(minetestserver PROPERTIES COMPILE_FLAGS
140                                 "${UNIX_FLAGS} -DSERVER")
141         endif(BUILD_SERVER)
142
143 else( UNIX )
144         # Windows
145         
146         if(BUILD_CLIENT)
147                 # EHa enables SEH exceptions (used for catching segfaults)
148                 set_target_properties(minetest PROPERTIES COMPILE_FLAGS
149                                 "/O2 /Ob2 /Oi /Ot /Oy /GL /EHa")
150         endif(BUILD_CLIENT)
151
152         if(BUILD_SERVER)
153                 # EHa enables SEH exceptions (used for catching segfaults)
154                 set_target_properties(minetestserver PROPERTIES COMPILE_FLAGS
155                                 "/O2 /Ob2 /Oi /Ot /Oy /GL /EHa /D SERVER")
156         endif(BUILD_SERVER)
157
158 endif( UNIX )
159
160 #
161 # Installation
162 #
163
164 if(WIN32)
165         set(DATADIR "data")
166         set(BINDIR "bin")
167 elseif(APPLE)
168         set(DATADIR "share/minetest")
169         set(BINDIR "bin")
170 elseif(UNIX)
171         set(DATADIR "share/minetest")
172         set(BINDIR "bin")
173 endif()
174
175 if(BUILD_CLIENT)
176         install(TARGETS minetest DESTINATION ${BINDIR})
177
178         file(GLOB images "${CMAKE_CURRENT_SOURCE_DIR}/../data/*.png")
179
180         install(FILES ${images} DESTINATION ${DATADIR})
181
182         if(WIN32)
183                 if(DEFINED IRRLICHT_DLL)
184                         install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR})
185                 endif()
186                 if(DEFINED ZLIB_DLL)
187                         install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
188                 endif()
189         endif()
190 endif(BUILD_CLIENT)
191
192 if(BUILD_SERVER)
193         install(TARGETS minetestserver DESTINATION ${BINDIR})
194 endif(BUILD_SERVER)
195
196 # Subdirectories
197
198 add_subdirectory(jthread)
199
200 #end