]> git.jsancho.org Git - lugaru.git/blob - CMakeLists.txt
Cleaned up dialog handling using a Dialog class
[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 -pedantic -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}/main.cpp
36     ${SRCDIR}/Frustum.cpp
37     ${SRCDIR}/Account.cpp
38     ${SRCDIR}/ConsoleCmds.cpp
39     ${SRCDIR}/Dialog.cpp
40     ${SRCDIR}/Game.cpp
41     ${SRCDIR}/GameDraw.cpp
42     ${SRCDIR}/GameInitDispose.cpp
43     ${SRCDIR}/GameTick.cpp
44     ${SRCDIR}/Globals.cpp
45     ${SRCDIR}/Lights.cpp
46     ${SRCDIR}/Menu.cpp
47     ${SRCDIR}/Models.cpp
48     ${SRCDIR}/Objects.cpp
49     ${SRCDIR}/pack.c
50     ${SRCDIR}/Person.cpp
51     ${SRCDIR}/private.c
52     ${SRCDIR}/Quaternions.cpp
53     ${SRCDIR}/Skeleton.cpp
54     ${SRCDIR}/Skybox.cpp
55     ${SRCDIR}/Sprite.cpp
56     ${SRCDIR}/Terrain.cpp
57     ${SRCDIR}/Texture.cpp
58     ${SRCDIR}/Text.cpp
59     ${SRCDIR}/ImageIO.cpp
60     ${SRCDIR}/unpack.c
61     ${SRCDIR}/Weapons.cpp
62     ${SRCDIR}/openal_wrapper.cpp
63     ${SRCDIR}/Input.cpp
64     ${SRCDIR}/Settings.cpp
65     ${SRCDIR}/Stereo.cpp
66     ${SRCDIR}/Animation.cpp
67     ${SRCDIR}/Sounds.cpp
68     ${SRCDIR}/Awards.cpp
69 )
70
71 set(LUGARU_H
72     ${SRCDIR}/Frustum.h
73     ${SRCDIR}/Account.h
74     ${SRCDIR}/ConsoleCmds.h
75     ${SRCDIR}/Dialog.h
76     ${SRCDIR}/Game.h
77     ${SRCDIR}/Lights.h
78     ${SRCDIR}/Menu.h
79     ${SRCDIR}/Models.h
80     ${SRCDIR}/Objects.h
81     ${SRCDIR}/Person.h
82     ${SRCDIR}/PhysicsMath.h
83     ${SRCDIR}/Quaternions.h
84     ${SRCDIR}/Random.h
85     ${SRCDIR}/Skeleton.h
86     ${SRCDIR}/Skybox.h
87     ${SRCDIR}/Sprite.h
88     ${SRCDIR}/ImageIO.h
89     ${SRCDIR}/Terrain.h
90     ${SRCDIR}/Texture.h
91     ${SRCDIR}/Text.h
92     ${SRCDIR}/Weapons.h
93     ${SRCDIR}/Input.h
94     ${SRCDIR}/binio.h
95     ${SRCDIR}/openal_wrapper.h
96     ${SRCDIR}/optionparser.h
97     ${SRCDIR}/gamegl.h
98     ${SRCDIR}/glstubs.h
99     ${SRCDIR}/private.h
100     ${SRCDIR}/Settings.h
101     ${SRCDIR}/Stereo.h
102     ${SRCDIR}/Animation.h
103     ${SRCDIR}/Sounds.h
104 )
105
106 if(UNIX)
107     set(LUGARU_SRCS
108         ${LUGARU_SRCS}
109         ${SRCDIR}/MacCompatibility.cpp
110     )
111     set(LUGARU_H
112         ${LUGARU_H}
113         ${SRCDIR}/MacCompatibility.h
114     )
115 endif(UNIX)
116
117 if(WIN32)
118     add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
119                        COMMAND ${CMAKE_RC_COMPILER}
120                        -I${SRCDIR}/win-res
121                        -o ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
122                        -i${SRCDIR}/win-res/Lugaru.rc
123                        DEPENDS ${SRCDIR}/win-res/Lugaru.rc
124     )
125
126     # FIXME: get rid of this.
127     set(LUGARU_SRCS
128         ${LUGARU_SRCS}
129         ${SRCDIR}/WinDefs.cpp)
130
131     set(LUGARU_H
132         ${LUGARU_H}
133         ${SRCDIR}/WinDefs.h
134         ${SRCDIR}/win-res/resource.h)
135 endif(WIN32)
136
137 if(APPLE)
138     set(PLATFORM_LIBS "-framework Carbon -framework Cocoa -framework OpenGL -framework OpenAL")
139 endif(APPLE)
140
141
142 ### Dependencies
143
144 find_package(OpenGL REQUIRED)
145
146 # Windows is funky about OpenAL detection
147 if(WIN32)
148     pkg_check_modules(OPENAL openal REQUIRED)
149     set(OPENAL_LIBRARY ${OPENAL_LIBRARIES})
150 else(WIN32)
151     find_package(OpenAL REQUIRED)
152 endif(WIN32)
153
154 find_package(sdl2 REQUIRED)
155 find_package(PNG REQUIRED)
156 find_package(JPEG REQUIRED)
157 find_package(ZLIB REQUIRED)
158 find_package(OggVorbis REQUIRED)
159
160 include_directories(
161     ${OPENAL_INCLUDE_DIR}
162     ${JPEG_INCLUDE_DIR}
163     ${PNG_INCLUDE_DIR}
164     ${ZLIB_INCLUDE_DIR}
165     ${OPENGL_INCLUDE_DIR}
166     ${SDL2_INCLUDE_DIRS}
167     ${VORBISFILE_INCLUDE_DIR}
168     ${OGG_INCLUDE_DIR}
169     ${CMAKE_SOURCE_DIR}/Source
170 )
171
172 set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} ${VORBISFILE_LIBRARY} ${OGG_LIBRARY} ${PLATFORM_LIBS})
173
174
175 ### Definitions
176
177 if(WIN32)
178     add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H} lugaru_resource.obj)
179 else(WIN32)
180     add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H})
181 endif(WIN32)
182
183 target_link_libraries(lugaru ${LUGARU_LIBS})
184
185 if(WIN32)
186     add_definitions(-DBinIO_STDINT_HEADER=<stdint.h>)
187     if(MINGW)
188         # An alternative would be to use _WIN32 consistently instead of WIN32
189         add_definitions(-DWIN32)
190     endif(MINGW)
191 else(WIN32)
192     add_definitions(-DPLATFORM_LINUX=1 -DPLATFORM_UNIX=1 -DBinIO_STDINT_HEADER=<stdint.h>)
193 endif(WIN32)
194
195
196 ### Installation
197
198 if(APPLE)
199     set(APPS_ROOT "${CMAKE_INSTALL_PREFIX}/Lugaru.app")
200     set(APPS_BIN "${APPS_ROOT}/Contents/MacOS")
201     set(APPS_DATA "${APPS_ROOT}/Contents/Resources")
202 endif(APPLE)
203
204 if(WIN32)
205     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX})
206     if(MINGW)
207         # Based off Mageia/Fedora MinGW toolchain, might not work on other distros or Windows
208         set(LIBGCC_S libgcc_s_sjlj-1.dll)
209         if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") # MinGW64
210             set(LIBGCC_S libgcc_s_seh-1.dll)
211         endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
212         # FIXME: Filter out unneeded DLLs when building against some internal deps
213         set(DLL_ROOT ${CMAKE_FIND_ROOT_PATH}/bin)
214         install(FILES ${DLL_ROOT}/${LIBGCC_S}
215                       ${DLL_ROOT}/libjpeg-62.dll
216                       ${DLL_ROOT}/libogg-0.dll
217                       ${DLL_ROOT}/libpng16-16.dll
218                       ${DLL_ROOT}/libstdc++-6.dll
219                       ${DLL_ROOT}/libvorbis-0.dll
220                       ${DLL_ROOT}/libvorbisfile-3.dll
221                       ${DLL_ROOT}/libwinpthread-1.dll
222                       ${DLL_ROOT}/OpenAL32.dll
223                       ${DLL_ROOT}/SDL2.dll
224                       ${DLL_ROOT}/zlib1.dll
225                 DESTINATION ${CMAKE_INSTALL_PREFIX})
226     endif(MINGW)
227 else(WIN32)
228     if(APPLE)
229         set(CMAKE_INSTALL_PREFIX "${APPS_BIN}")
230         install(FILES ${SRCDIR}/mac-res/lugaru.icns DESTINATION ${APPS_DATA})
231         install(FILES ${SRCDIR}/mac-res/Info.plist DESTINATION ${APPS_ROOT}/Contents)
232     endif(APPLE)
233     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru DESTINATION ${CMAKE_INSTALL_PREFIX})
234 endif(WIN32)
235
236 if(NOT APPLE)
237     install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${CMAKE_INSTALL_PREFIX})
238     install(FILES ${CMAKE_SOURCE_DIR}/README.md
239                   ${CMAKE_SOURCE_DIR}/COPYING.txt
240                   ${CMAKE_SOURCE_DIR}/CONTENT-LICENSE.txt
241             DESTINATION ${CMAKE_INSTALL_PREFIX})
242 endif(NOT APPLE)
243
244 if(APPLE)
245     install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${APPS_ROOT})
246 endif(APPLE)