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/")
37 ${SRCDIR}/ConsoleCmds.cpp
39 ${SRCDIR}/GameDraw.cpp
40 ${SRCDIR}/GameInitDispose.cpp
41 ${SRCDIR}/GameTick.cpp
50 ${SRCDIR}/Quaternions.cpp
51 ${SRCDIR}/Skeleton.cpp
60 ${SRCDIR}/OpenGL_Windows.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
106 ${SRCDIR}/MacCompatibility.cpp
110 ${SRCDIR}/MacCompatibility.h
115 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
116 COMMAND ${CMAKE_RC_COMPILER}
118 -o ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
119 -i${SRCDIR}/win-res/Lugaru.rc
120 DEPENDS ${SRCDIR}/win-res/Lugaru.rc
123 # FIXME: get rid of this.
126 ${SRCDIR}/WinDefs.cpp)
131 ${SRCDIR}/win-res/resource.h)
135 set(PLATFORM_LIBS "-framework Carbon -framework Cocoa -framework OpenGL -framework OpenAL")
141 find_package(OpenGL REQUIRED)
143 # Windows is funky about OpenAL detection
145 pkg_check_modules(OPENAL openal REQUIRED)
146 set(OPENAL_LIBRARY ${OPENAL_LIBRARIES})
148 find_package(OpenAL REQUIRED)
151 find_package(sdl2 REQUIRED)
152 find_package(PNG REQUIRED)
153 find_package(JPEG REQUIRED)
154 find_package(ZLIB REQUIRED)
155 find_package(OggVorbis REQUIRED)
158 ${OPENAL_INCLUDE_DIR}
162 ${OPENGL_INCLUDE_DIR}
164 ${VORBISFILE_INCLUDE_DIR}
166 ${CMAKE_SOURCE_DIR}/Source
169 set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} ${VORBISFILE_LIBRARY} ${OGG_LIBRARY} ${PLATFORM_LIBS})
175 add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H} lugaru_resource.obj)
177 add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H})
180 target_link_libraries(lugaru ${LUGARU_LIBS})
183 add_definitions(-DBinIO_STDINT_HEADER=<stdint.h>)
185 # An alternative would be to use _WIN32 consistently instead of WIN32
186 add_definitions(-DWIN32)
189 add_definitions(-DPLATFORM_LINUX=1 -DPLATFORM_UNIX=1 -DBinIO_STDINT_HEADER=<stdint.h>)
196 set(APPS_ROOT "${CMAKE_INSTALL_PREFIX}/Lugaru.app")
197 set(APPS_BIN "${APPS_ROOT}/Contents/MacOS")
198 set(APPS_DATA "${APPS_ROOT}/Contents/Resources")
202 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX})
204 # Based off Mageia/Fedora MinGW toolchain, might not work on other distros or Windows
205 set(LIBGCC_S libgcc_s_sjlj-1.dll)
206 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") # MinGW64
207 set(LIBGCC_S libgcc_s_seh-1.dll)
208 endif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
209 # FIXME: Filter out unneeded DLLs when building against some internal deps
210 set(DLL_ROOT ${CMAKE_FIND_ROOT_PATH}/bin)
211 install(FILES ${DLL_ROOT}/${LIBGCC_S}
212 ${DLL_ROOT}/libjpeg-62.dll
213 ${DLL_ROOT}/libogg-0.dll
214 ${DLL_ROOT}/libpng16-16.dll
215 ${DLL_ROOT}/libstdc++-6.dll
216 ${DLL_ROOT}/libvorbis-0.dll
217 ${DLL_ROOT}/libvorbisfile-3.dll
218 ${DLL_ROOT}/libwinpthread-1.dll
219 ${DLL_ROOT}/OpenAL32.dll
221 ${DLL_ROOT}/zlib1.dll
222 DESTINATION ${CMAKE_INSTALL_PREFIX})
226 set(CMAKE_INSTALL_PREFIX "${APPS_BIN}")
227 install(FILES ${SRCDIR}/mac-res/lugaru.icns DESTINATION ${APPS_DATA})
228 install(FILES ${SRCDIR}/mac-res/Info.plist DESTINATION ${APPS_ROOT}/Contents)
230 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru DESTINATION ${CMAKE_INSTALL_PREFIX})
234 install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${CMAKE_INSTALL_PREFIX})
235 install(FILES ${CMAKE_SOURCE_DIR}/README.md
236 ${CMAKE_SOURCE_DIR}/COPYING.txt
237 ${CMAKE_SOURCE_DIR}/CONTENT-LICENSE.txt
238 DESTINATION ${CMAKE_INSTALL_PREFIX})
242 install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${APPS_ROOT})