3 cmake_minimum_required(VERSION 3.5)
4 cmake_policy(SET CMP0004 OLD)
8 set(SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/Source")
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")
17 if(NOT CMAKE_INSTALL_PREFIX AND WIN32)
18 set(CMAKE_INSTALL_PREFIX "C:/Lugaru")
19 endif(NOT CMAKE_INSTALL_PREFIX AND WIN32)
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.")
29 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
38 ${SRCDIR}/ConsoleCmds.cpp
40 ${SRCDIR}/GameDraw.cpp
41 ${SRCDIR}/GameInitDispose.cpp
42 ${SRCDIR}/GameTick.cpp
51 ${SRCDIR}/Quaternions.cpp
52 ${SRCDIR}/Skeleton.cpp
61 ${SRCDIR}/openal_wrapper.cpp
63 ${SRCDIR}/Settings.cpp
65 ${SRCDIR}/Animation.cpp
73 ${SRCDIR}/ConsoleCmds.h
80 ${SRCDIR}/PhysicsMath.h
81 ${SRCDIR}/Quaternions.h
93 ${SRCDIR}/openal_wrapper.h
94 ${SRCDIR}/optionparser.h
100 ${SRCDIR}/Animation.h
107 ${SRCDIR}/MacCompatibility.cpp
111 ${SRCDIR}/MacCompatibility.h
116 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
117 COMMAND ${CMAKE_RC_COMPILER}
119 -o ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
120 -i${SRCDIR}/win-res/Lugaru.rc
121 DEPENDS ${SRCDIR}/win-res/Lugaru.rc
124 # FIXME: get rid of this.
127 ${SRCDIR}/WinDefs.cpp)
132 ${SRCDIR}/win-res/resource.h)
136 set(PLATFORM_LIBS "-framework Carbon -framework Cocoa -framework OpenGL -framework OpenAL")
142 find_package(OpenGL REQUIRED)
144 # Windows is funky about OpenAL detection
146 pkg_check_modules(OPENAL openal REQUIRED)
147 set(OPENAL_LIBRARY ${OPENAL_LIBRARIES})
149 find_package(OpenAL REQUIRED)
152 find_package(sdl2 REQUIRED)
153 find_package(PNG REQUIRED)
154 find_package(JPEG REQUIRED)
155 find_package(ZLIB REQUIRED)
156 find_package(OggVorbis REQUIRED)
159 ${OPENAL_INCLUDE_DIR}
163 ${OPENGL_INCLUDE_DIR}
165 ${VORBISFILE_INCLUDE_DIR}
167 ${CMAKE_SOURCE_DIR}/Source
170 set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} ${VORBISFILE_LIBRARY} ${OGG_LIBRARY} ${PLATFORM_LIBS})
176 add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H} lugaru_resource.obj)
178 add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H})
181 target_link_libraries(lugaru ${LUGARU_LIBS})
184 add_definitions(-DBinIO_STDINT_HEADER=<stdint.h>)
186 # An alternative would be to use _WIN32 consistently instead of WIN32
187 add_definitions(-DWIN32)
190 add_definitions(-DPLATFORM_LINUX=1 -DPLATFORM_UNIX=1 -DBinIO_STDINT_HEADER=<stdint.h>)
197 set(APPS_ROOT "${CMAKE_INSTALL_PREFIX}/Lugaru.app")
198 set(APPS_BIN "${APPS_ROOT}/Contents/MacOS")
199 set(APPS_DATA "${APPS_ROOT}/Contents/Resources")
203 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX})
205 # Based off Mageia/Fedora MinGW toolchain, might not work on other distros or Windows
206 set(LIBGCC_S libgcc_s_sjlj-1.dll)
207 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") # MinGW64
208 set(LIBGCC_S libgcc_s_seh-1.dll)
209 endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
210 # FIXME: Filter out unneeded DLLs when building against some internal deps
211 set(DLL_ROOT ${CMAKE_FIND_ROOT_PATH}/bin)
212 install(FILES ${DLL_ROOT}/${LIBGCC_S}
213 ${DLL_ROOT}/libjpeg-62.dll
214 ${DLL_ROOT}/libogg-0.dll
215 ${DLL_ROOT}/libpng16-16.dll
216 ${DLL_ROOT}/libstdc++-6.dll
217 ${DLL_ROOT}/libvorbis-0.dll
218 ${DLL_ROOT}/libvorbisfile-3.dll
219 ${DLL_ROOT}/libwinpthread-1.dll
220 ${DLL_ROOT}/OpenAL32.dll
222 ${DLL_ROOT}/zlib1.dll
223 DESTINATION ${CMAKE_INSTALL_PREFIX})
227 set(CMAKE_INSTALL_PREFIX "${APPS_BIN}")
228 install(FILES ${SRCDIR}/mac-res/lugaru.icns DESTINATION ${APPS_DATA})
229 install(FILES ${SRCDIR}/mac-res/Info.plist DESTINATION ${APPS_ROOT}/Contents)
231 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru DESTINATION ${CMAKE_INSTALL_PREFIX})
235 install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${CMAKE_INSTALL_PREFIX})
236 install(FILES ${CMAKE_SOURCE_DIR}/README.md
237 ${CMAKE_SOURCE_DIR}/COPYING.txt
238 ${CMAKE_SOURCE_DIR}/CONTENT-LICENSE.txt
239 DESTINATION ${CMAKE_INSTALL_PREFIX})
243 install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${APPS_ROOT})