]> git.jsancho.org Git - lugaru.git/blob - CMakeLists.txt
Removed unused file and code
[lugaru.git] / CMakeLists.txt
1 project(lugaru)
2
3 cmake_minimum_required(VERSION 3.5)
4 cmake_policy(SET CMP0004 OLD)
5
6 include(FindPkgConfig)
7
8 set(SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/Source")
9
10
11 ### CMake config
12
13 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 --std=c++11")
14 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-parentheses -g -pg --std=c++11")
15 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wno-parentheses -O2 -std=c++11")
16
17 if(NOT CMAKE_INSTALL_PREFIX AND WIN32)
18     set(CMAKE_INSTALL_PREFIX "C:/Lugaru")
19 endif(NOT CMAKE_INSTALL_PREFIX AND WIN32)
20
21 if(APPLE)
22     set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX")
23     set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING
24         "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value")
25     set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.10.sdk" CACHE PATH
26         "The product will be built against the headers and libraries located inside the indicated SDK.")
27 endif(APPLE)
28
29 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
30
31
32 ### Sources
33
34 set(LUGARU_SRCS
35     ${SRCDIR}/Frustum.cpp
36     ${SRCDIR}/Account.cpp
37     ${SRCDIR}/Game.cpp
38     ${SRCDIR}/GameDraw.cpp
39     ${SRCDIR}/GameInitDispose.cpp
40     ${SRCDIR}/GameTick.cpp
41     ${SRCDIR}/Globals.cpp
42     ${SRCDIR}/Lights.cpp
43     ${SRCDIR}/Menu.cpp
44     ${SRCDIR}/Models.cpp
45     ${SRCDIR}/Objects.cpp
46     ${SRCDIR}/pack.c
47     ${SRCDIR}/Person.cpp
48     ${SRCDIR}/private.c
49     ${SRCDIR}/Quaternions.cpp
50     ${SRCDIR}/Skeleton.cpp
51     ${SRCDIR}/Skybox.cpp
52     ${SRCDIR}/Sprite.cpp
53     ${SRCDIR}/Terrain.cpp
54     ${SRCDIR}/Texture.cpp
55     ${SRCDIR}/Text.cpp
56     ${SRCDIR}/TGALoader.cpp
57     ${SRCDIR}/unpack.c
58     ${SRCDIR}/Weapons.cpp
59     ${SRCDIR}/OpenGL_Windows.cpp
60     ${SRCDIR}/openal_wrapper.cpp
61     ${SRCDIR}/Input.cpp
62     ${SRCDIR}/Settings.cpp
63     ${SRCDIR}/Stereo.cpp
64     ${SRCDIR}/Animation.cpp
65     ${SRCDIR}/Sounds.cpp
66     ${SRCDIR}/Awards.cpp
67 )
68
69 set(LUGARU_H
70     ${SRCDIR}/Frustum.h
71     ${SRCDIR}/Account.h
72     ${SRCDIR}/Game.h
73     ${SRCDIR}/Lights.h
74     ${SRCDIR}/Menu.h
75     ${SRCDIR}/Models.h
76     ${SRCDIR}/Objects.h
77     ${SRCDIR}/Person.h
78     ${SRCDIR}/PhysicsMath.h
79     ${SRCDIR}/Quaternions.h
80     ${SRCDIR}/Random.h
81     ${SRCDIR}/Skeleton.h
82     ${SRCDIR}/Skybox.h
83     ${SRCDIR}/Sprite.h
84     ${SRCDIR}/TGALoader.h
85     ${SRCDIR}/Terrain.h
86     ${SRCDIR}/Texture.h
87     ${SRCDIR}/Text.h
88     ${SRCDIR}/Weapons.h
89     ${SRCDIR}/Input.h
90     ${SRCDIR}/binio.h
91     ${SRCDIR}/openal_wrapper.h
92     ${SRCDIR}/gamegl.h
93     ${SRCDIR}/glstubs.h
94     ${SRCDIR}/private.h
95     ${SRCDIR}/Settings.h
96     ${SRCDIR}/Stereo.h
97     ${SRCDIR}/Animation.h
98     ${SRCDIR}/Sounds.h
99 )
100
101 if(UNIX)
102     set(LUGARU_SRCS
103         ${LUGARU_SRCS}
104         ${SRCDIR}/MacCompatibility.cpp
105     )
106     set(LUGARU_H
107         ${LUGARU_H}
108         ${SRCDIR}/MacCompatibility.h
109     )
110 endif(UNIX)
111
112 if(WIN32)
113     add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
114                        COMMAND ${CMAKE_RC_COMPILER}
115                        -I${SRCDIR}/win-res
116                        -o ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
117                        -i${SRCDIR}/win-res/Lugaru.rc
118                        DEPENDS ${SRCDIR}/win-res/Lugaru.rc
119     )
120
121     # FIXME: get rid of this.
122     set(LUGARU_SRCS
123         ${LUGARU_SRCS}
124         ${SRCDIR}/WinDefs.cpp)
125
126     set(LUGARU_H
127         ${LUGARU_H}
128         ${SRCDIR}/WinDefs.h
129         ${SRCDIR}/win-res/resource.h)
130 endif(WIN32)
131
132 if(APPLE)
133     set(PLATFORM_LIBS "-framework Carbon -framework Cocoa -framework OpenGL -framework OpenAL")
134 endif(APPLE)
135
136
137 ### Dependencies
138
139 find_package(OpenGL REQUIRED)
140
141 # Windows is funky about OpenAL detection
142 if(WIN32)
143     pkg_check_modules(OPENAL openal REQUIRED)
144     set(OPENAL_LIBRARY ${OPENAL_LIBRARIES})
145 else(WIN32)
146     find_package(OpenAL REQUIRED)
147 endif(WIN32)
148
149 find_package(sdl2 REQUIRED)
150 find_package(PNG REQUIRED)
151 find_package(JPEG REQUIRED)
152 find_package(ZLIB REQUIRED)
153 find_package(OggVorbis REQUIRED)
154
155 include_directories(
156     ${OPENAL_INCLUDE_DIR}
157     ${JPEG_INCLUDE_DIR}
158     ${PNG_INCLUDE_DIR}
159     ${ZLIB_INCLUDE_DIR}
160     ${OPENGL_INCLUDE_DIR}
161     ${SDL2_INCLUDE_DIRS}
162     ${VORBISFILE_INCLUDE_DIR}
163     ${OGG_INCLUDE_DIR}
164     ${CMAKE_SOURCE_DIR}/Source
165 )
166
167 set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} ${VORBISFILE_LIBRARY} ${OGG_LIBRARY} ${PLATFORM_LIBS})
168
169
170 ### Definitions
171
172 if(WIN32)
173     add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H} lugaru_resource.obj)
174 else(WIN32)
175     add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H})
176 endif(WIN32)
177
178 target_link_libraries(lugaru ${LUGARU_LIBS})
179
180 if(WIN32)
181     add_definitions(-DBinIO_STDINT_HEADER=<stdint.h>)
182     if(MINGW)
183         # An alternative would be to use _WIN32 consistently instead of WIN32
184         add_definitions(-DWIN32)
185     endif(MINGW)
186 else(WIN32)
187     add_definitions(-DPLATFORM_LINUX=1 -DPLATFORM_UNIX=1 -DBinIO_STDINT_HEADER=<stdint.h>)
188 endif(WIN32)
189
190
191 ### Installation
192
193 if(APPLE)
194     set(APPS_ROOT "${CMAKE_INSTALL_PREFIX}/Lugaru.app")
195     set(APPS_BIN "${APPS_ROOT}/Contents/MacOS")
196     set(APPS_DATA "${APPS_ROOT}/Contents/Resources")
197 endif(APPLE)
198
199 if(WIN32)
200     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX})
201     if(MINGW)
202         # Based off Mageia/Fedora MinGW toolchain, might not work on other distros or Windows
203         set(LIBGCC_S libgcc_s_sjlj-1.dll)
204         if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") # MinGW64
205             set(LIBGCC_S libgcc_s_seh-1.dll)
206         endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
207         # FIXME: Filter out unneeded DLLs when building against some internal deps
208         set(DLL_ROOT ${CMAKE_FIND_ROOT_PATH}/bin)
209         install(FILES ${DLL_ROOT}/${LIBGCC_S}
210                       ${DLL_ROOT}/libjpeg-62.dll
211                       ${DLL_ROOT}/libogg-0.dll
212                       ${DLL_ROOT}/libpng16-16.dll
213                       ${DLL_ROOT}/libstdc++-6.dll
214                       ${DLL_ROOT}/libvorbis-0.dll
215                       ${DLL_ROOT}/libvorbisfile-3.dll
216                       ${DLL_ROOT}/libwinpthread-1.dll
217                       ${DLL_ROOT}/OpenAL32.dll
218                       ${DLL_ROOT}/SDL2.dll
219                       ${DLL_ROOT}/zlib1.dll
220                 DESTINATION ${CMAKE_INSTALL_PREFIX})
221     endif(MINGW)
222 else(WIN32)
223     if(APPLE)
224         set(CMAKE_INSTALL_PREFIX "${APPS_BIN}")
225         install(FILES ${SRCDIR}/mac-res/lugaru.icns DESTINATION ${APPS_DATA})
226         install(FILES ${SRCDIR}/mac-res/Info.plist DESTINATION ${APPS_ROOT}/Contents)
227     endif(APPLE)
228     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru DESTINATION ${CMAKE_INSTALL_PREFIX})
229 endif(WIN32)
230
231 if(NOT APPLE)
232     install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${CMAKE_INSTALL_PREFIX})
233     install(FILES ${CMAKE_SOURCE_DIR}/README.md
234                   ${CMAKE_SOURCE_DIR}/COPYING.txt
235                   ${CMAKE_SOURCE_DIR}/CONTENT-LICENSE.txt
236             DESTINATION ${CMAKE_INSTALL_PREFIX})
237 endif(NOT APPLE)
238
239 if(APPLE)
240     install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${APPS_ROOT})
241 endif(APPLE)