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}/GameDraw.cpp
39 ${SRCDIR}/GameInitDispose.cpp
40 ${SRCDIR}/GameTick.cpp
49 ${SRCDIR}/Quaternions.cpp
50 ${SRCDIR}/Skeleton.cpp
56 ${SRCDIR}/TGALoader.cpp
59 ${SRCDIR}/OpenGL_Windows.cpp
60 ${SRCDIR}/openal_wrapper.cpp
62 ${SRCDIR}/Settings.cpp
64 ${SRCDIR}/Animation.cpp
78 ${SRCDIR}/PhysicsMath.h
79 ${SRCDIR}/Quaternions.h
92 ${SRCDIR}/openal_wrapper.h
105 ${SRCDIR}/MacCompatibility.cpp
109 ${SRCDIR}/MacCompatibility.h
114 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
115 COMMAND ${CMAKE_RC_COMPILER}
117 -o ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
118 -i${SRCDIR}/win-res/Lugaru.rc
119 DEPENDS ${SRCDIR}/win-res/Lugaru.rc
122 # FIXME: get rid of this.
125 ${SRCDIR}/WinDefs.cpp)
130 ${SRCDIR}/win-res/resource.h)
134 set(PLATFORM_LIBS "-framework Carbon -framework Cocoa -framework OpenGL -framework OpenAL")
140 find_package(OpenGL REQUIRED)
142 # Windows is funky about OpenAL detection
144 pkg_check_modules(OPENAL openal REQUIRED)
145 set(OPENAL_LIBRARY ${OPENAL_LIBRARIES})
147 find_package(OpenAL REQUIRED)
150 find_package(sdl2 REQUIRED)
151 find_package(PNG REQUIRED)
152 find_package(JPEG REQUIRED)
153 find_package(ZLIB REQUIRED)
154 find_package(OggVorbis REQUIRED)
157 ${OPENAL_INCLUDE_DIR}
161 ${OPENGL_INCLUDE_DIR}
163 ${VORBISFILE_INCLUDE_DIR}
165 ${CMAKE_SOURCE_DIR}/Source
168 set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} ${VORBISFILE_LIBRARY} ${OGG_LIBRARY} ${PLATFORM_LIBS})
174 add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H} lugaru_resource.obj)
176 add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H})
179 target_link_libraries(lugaru ${LUGARU_LIBS})
182 add_definitions(-DBinIO_STDINT_HEADER=<stdint.h>)
184 # An alternative would be to use _WIN32 consistently instead of WIN32
185 add_definitions(-DWIN32)
188 add_definitions(-DPLATFORM_LINUX=1 -DPLATFORM_UNIX=1 -DBinIO_STDINT_HEADER=<stdint.h>)
195 set(APPS_ROOT "${CMAKE_INSTALL_PREFIX}/Lugaru.app")
196 set(APPS_BIN "${APPS_ROOT}/Contents/MacOS")
197 set(APPS_DATA "${APPS_ROOT}/Contents/Resources")
201 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX})
203 # Based off Mageia/Fedora MinGW toolchain, might not work on other distros or Windows
204 set(LIBGCC_S libgcc_s_sjlj-1.dll)
205 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") # MinGW64
206 set(LIBGCC_S libgcc_s_seh-1.dll)
207 endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
208 # FIXME: Filter out unneeded DLLs when building against some internal deps
209 set(DLL_ROOT ${CMAKE_FIND_ROOT_PATH}/bin)
210 install(FILES ${DLL_ROOT}/${LIBGCC_S}
211 ${DLL_ROOT}/libjpeg-62.dll
212 ${DLL_ROOT}/libogg-0.dll
213 ${DLL_ROOT}/libpng16-16.dll
214 ${DLL_ROOT}/libstdc++-6.dll
215 ${DLL_ROOT}/libvorbis-0.dll
216 ${DLL_ROOT}/libvorbisfile-3.dll
217 ${DLL_ROOT}/libwinpthread-1.dll
218 ${DLL_ROOT}/OpenAL32.dll
220 ${DLL_ROOT}/zlib1.dll
221 DESTINATION ${CMAKE_INSTALL_PREFIX})
225 set(CMAKE_INSTALL_PREFIX "${APPS_BIN}")
226 install(FILES ${SRCDIR}/mac-res/lugaru.icns DESTINATION ${APPS_DATA})
227 install(FILES ${SRCDIR}/mac-res/Info.plist DESTINATION ${APPS_ROOT}/Contents)
229 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru DESTINATION ${CMAKE_INSTALL_PREFIX})
233 install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${CMAKE_INSTALL_PREFIX})
234 install(FILES ${CMAKE_SOURCE_DIR}/README.md
235 ${CMAKE_SOURCE_DIR}/COPYING.txt
236 ${CMAKE_SOURCE_DIR}/CONTENT-LICENSE.txt
237 DESTINATION ${CMAKE_INSTALL_PREFIX})
241 install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${APPS_ROOT})