3 cmake_minimum_required(VERSION 3.5)
5 set(SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/Source")
6 set(DEPDIR "${CMAKE_CURRENT_SOURCE_DIR}/Dependencies")
8 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 --std=c++11")
9 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -pg --std=c++11")
10 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -O2 -std=c++11")
12 if(NOT LUGARU_INSTALL_PREFIX)
14 set(LUGARU_INSTALL_PREFIX "C:/Lugaru" CACHE PATH
15 "LUGARU_INSTALL_PREFIX: Install path prefix, prepended onto install directories."
18 set(LUGARU_INSTALL_PREFIX "/usr/local/lugaru" CACHE PATH
19 "CMAKE_INSTALL_PREFIX: Install path prefix, prepended onto install directories."
22 endif(NOT LUGARU_INSTALL_PREFIX)
24 set(CMAKE_INSTALL_PREFIX "${LUGARU_INSTALL_PREFIX}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
27 set(OPENGL_gl_LIBRARY "-lopengl32" CACHE STRING "OpenGL library for Win32" FORCE)
28 set(OPENGL_glu_LIBRARY "-lglu32" CACHE STRING "GLU library for Win32" FORCE)
32 set(CMAKE_OSX_ARCHITECTURES "i386;x86_64;ppc" CACHE STRING "Build architectures for OSX")
33 set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5" CACHE STRING
34 "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked. Set to empty string for default value")
35 set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk" CACHE PATH
36 "The product will be built against the headers and libraries located inside the indicated SDK.")
40 # Save our sanity; Set all available libraries to internal by default
41 set(LUGARU_FORCE_INTERNAL_SDL True)
42 set(LUGARU_FORCE_INTERNAL_GLU True)
43 set(LUGARU_FORCE_INTERNAL_JPEG True)
44 set(LUGARU_FORCE_INTERNAL_PNG True)
45 set(LUGARU_FORCE_INTERNAL_VORBIS True)
46 set(LUGARU_FORCE_INTERNAL_ZLIB True)
47 set(LUGARU_FORCE_INTERNAL_OPENAL True)
50 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
56 ${SRCDIR}/GameDraw.cpp
57 ${SRCDIR}/GameInitDispose.cpp
58 ${SRCDIR}/GameTick.cpp
67 ${SRCDIR}/Quaternions.cpp
68 ${SRCDIR}/Skeleton.cpp
74 ${SRCDIR}/TGALoader.cpp
77 ${SRCDIR}/OpenGL_Windows.cpp
78 ${SRCDIR}/openal_wrapper.cpp
80 ${SRCDIR}/Settings.cpp
82 ${SRCDIR}/Animation.cpp
96 ${SRCDIR}/PhysicsMath.h
97 ${SRCDIR}/Quaternions.h
102 ${SRCDIR}/TGALoader.h
110 ${SRCDIR}/openal_wrapper.h
116 ${SRCDIR}/Animation.h
123 ${SRCDIR}/MacCompatibility.cpp
127 ${SRCDIR}/MacCompatibility.h
131 if(MSVC) # MSVC non-C99 support biting us hard
134 ${DEPDIR}/msinttypes/stdint.h
135 ${DEPDIR}/msinttypes/inttypes.h
142 # !!! FIXME: get rid of WinDefs.{cpp,h}
145 ${SRCDIR}/WinDefs.cpp
146 ${SRCDIR}/win-res/Lugaru.rc)
151 ${SRCDIR}/win-res/resource.h)
155 set(PLATFORM_LIBS "-framework Carbon -framework Cocoa -framework OpenGL -framework OpenAL")
158 # Deal with dependencies...
159 find_package(OpenGL REQUIRED)
160 # force this include dir no matter what on Windows, so we get sane headers.
162 option (LUGARU_FORCE_INTERNAL_OPENGL "Force internal OpenGL headers, even if there's a system version" True)
163 if (LUGARU_FORCE_INTERNAL_OPENGL)
164 include_directories("${DEPDIR}/OpenGL")
165 endif (LUGARU_FORCE_INTERNAL_OPENGL)
169 include_directories("${DEPDIR}/OpenGL")
172 if(MSVC) # More Visual Studio annoyances
173 include_directories("${DEPDIR}/msinttypes")
176 option (LUGARU_FORCE_INTERNAL_OPENAL "Force internal libOpenAL, even if there's a system version" False)
177 if (NOT LUGARU_FORCE_INTERNAL_OPENAL)
178 find_package(OpenAL REQUIRED)
179 else(NOT LUGARU_FORCE_INTERNAL_OPENAL)
180 set(OPENAL_FOUND False)
181 endif (NOT LUGARU_FORCE_INTERNAL_OPENAL)
183 if (NOT OPENAL_FOUND OR LUGARU_FORCE_INTERNAL_OPENAL)
184 message(STATUS "Using internal copy of OpenAL")
185 set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} OpenAL")
186 set(OPENALDIR "${DEPDIR}/OpenAL")
187 set(OPENAL_INCLUDE_DIR "${OPENALDIR}/include/AL")
188 set(OPENAL_LIBRARY "")
191 set(LUGARU_HAS_INTERNAL_OPENAL True)
194 ${OPENALDIR}/lib/win32/msvc2008/OpenAL32.lib
199 ${OPENALDIR}/lib/win32/mingw/libOpenAL32.dll.a
204 if (NOT LUGARU_HAS_INTERNAL_OPENAL)
205 message(ERROR "We don't have a prebuilt OpenAL for this platform.")
206 endif (NOT LUGARU_HAS_INTERNAL_OPENAL)
207 endif (NOT OPENAL_FOUND OR LUGARU_FORCE_INTERNAL_OPENAL)
209 option (LUGARU_FORCE_INTERNAL_SDL "Force internal libSDL, even if there's a system version" False)
210 if (NOT LUGARU_FORCE_INTERNAL_SDL)
212 else(NOT LUGARU_FORCE_INTERNAL_SDL)
214 endif (NOT LUGARU_FORCE_INTERNAL_SDL)
217 message(STATUS "Using internal copy of SDL")
218 set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} SDL")
219 set(SDLDIR "${DEPDIR}/SDL12")
220 set(SDL_INCLUDE_DIR "${SDLDIR}/include")
223 set(LUGARU_HAS_INTERNAL_SDL True)
225 ${SDLDIR}/lib/macosx/libSDL-1.2.0.dylib
226 ${SDLDIR}/lib/macosx/libSDLmain-osx.a
231 set(LUGARU_HAS_INTERNAL_SDL True)
234 ${SDLDIR}/lib/win32/msvc2008/SDLmain.lib
235 ${SDLDIR}/lib/win32/msvc2008/SDL.lib
241 ${SDLDIR}/lib/win32/mingw/libSDLmain.a
242 ${SDLDIR}/lib/win32/mingw/libSDL.dll.a
248 if (NOT LUGARU_HAS_INTERNAL_SDL)
249 message(ERROR "We don't have a prebuilt SDL for this platform.")
250 endif (NOT LUGARU_HAS_INTERNAL_SDL)
251 endif (NOT SDL_FOUND)
253 option (LUGARU_FORCE_INTERNAL_PNG "Force internal libPNG, even if there's a system version" False)
254 if (NOT LUGARU_FORCE_INTERNAL_PNG)
256 else(NOT LUGARU_FORCE_INTERNAL_PNG)
258 endif (NOT LUGARU_FORCE_INTERNAL_PNG)
261 message(STATUS "Using internal copy of libpng")
262 set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} PNG")
263 set(PNGDIR "${DEPDIR}/libpng")
264 set(PNG_INCLUDE_DIR "${PNGDIR}")
284 endif (NOT PNG_FOUND)
286 option (LUGARU_FORCE_INTERNAL_JPEG "Force internal libJPEG, even if there's a system version" False)
287 if (NOT LUGARU_FORCE_INTERNAL_JPEG)
289 else(NOT LUGARU_FORCE_INTERNAL_JPEG)
290 set(JPEG_FOUND False)
291 endif (NOT LUGARU_FORCE_INTERNAL_JPEG)
294 message(STATUS "Using internal copy of libjpeg")
295 set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} JPEG")
296 set(JPEGDIR "${DEPDIR}/libjpeg")
297 set(JPEG_INCLUDE_DIR "${JPEGDIR}")
301 ${JPEGDIR}/jdapistd.c
302 ${JPEGDIR}/jdmaster.c
303 ${JPEGDIR}/jdapimin.c
304 ${JPEGDIR}/jcapimin.c
306 ${JPEGDIR}/jdatasrc.c
307 ${JPEGDIR}/jdatadst.c
308 ${JPEGDIR}/jdcoefct.c
310 ${JPEGDIR}/jddctmgr.c
313 ${JPEGDIR}/jdmainct.c
314 ${JPEGDIR}/jdmarker.c
315 ${JPEGDIR}/jdpostct.c
316 ${JPEGDIR}/jdsample.c
319 ${JPEGDIR}/jidctflt.c
320 ${JPEGDIR}/jidctfst.c
321 ${JPEGDIR}/jidctint.c
324 ${JPEGDIR}/jmemnobs.c
328 ${JPEGDIR}/jcmarker.c
329 ${JPEGDIR}/jcapistd.c
332 ${JPEGDIR}/jcdctmgr.c
333 ${JPEGDIR}/jccoefct.c
334 ${JPEGDIR}/jcmainct.c
335 ${JPEGDIR}/jfdctflt.c
336 ${JPEGDIR}/jfdctint.c
337 ${JPEGDIR}/jfdctfst.c
339 ${JPEGDIR}/jcsample.c
340 ${JPEGDIR}/jcmaster.c
342 ${JPEGDIR}/jcprepct.c
347 endif (NOT JPEG_FOUND)
349 option (LUGARU_FORCE_INTERNAL_ZLIB "Force internal zlib, even if there's a system version" False)
350 if (NOT LUGARU_FORCE_INTERNAL_ZLIB)
352 else(NOT LUGARU_FORCE_INTERNAL_ZLIB)
353 set(ZLIB_FOUND False)
354 endif (NOT LUGARU_FORCE_INTERNAL_ZLIB)
357 message(STATUS "Using internal copy of zlib")
358 set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} ZLIB")
359 set(ZLIBDIR "${DEPDIR}/zlib")
360 set(ZLIB_INCLUDE_DIR "${ZLIBDIR}")
361 set(ZLIB_LIBRARIES "")
365 ${ZLIBDIR}/compress.c
371 ${ZLIBDIR}/inftrees.c
376 endif (NOT ZLIB_FOUND)
378 option (LUGARU_FORCE_INTERNAL_GLU "Force internal libGLU, even if there's a system version" False)
379 if (LUGARU_FORCE_INTERNAL_GLU)
380 set(OPENGL_GLU_FOUND False)
381 endif (LUGARU_FORCE_INTERNAL_GLU)
383 if (NOT OPENGL_GLU_FOUND)
384 message(STATUS "Using internal copy of libGLU")
385 set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} GLU")
386 set(GLUDIR "${DEPDIR}/GLU")
387 set(GLU_INCLUDE_DIR "${GLUDIR}")
397 ${GLUDIR}/priorityq.c
404 endif (NOT OPENGL_GLU_FOUND)
406 option (LUGARU_FORCE_INTERNAL_VORBIS "Force internal Vorbis, even if there's a system version" False)
407 if (NOT LUGARU_FORCE_INTERNAL_VORBIS)
408 find_package(OggVorbis)
409 else(NOT LUGARU_FORCE_INTERNAL_VORBIS)
410 set(OGGVORBIS_FOUND False)
411 endif (NOT LUGARU_FORCE_INTERNAL_VORBIS)
413 if (NOT OGGVORBIS_FOUND)
414 message(STATUS "Using internal copy of Ogg Vorbis")
415 set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} OggVorbis")
416 set(OGGDIR "${DEPDIR}/libogg")
417 set(OGG_INCLUDE_DIR "${OGGDIR}/include")
419 set(VORBISDIR "${DEPDIR}/libvorbis")
420 set(VORBISFILE_INCLUDE_DIR "${VORBISDIR}/include")
421 set(VORBISFILE_LIBRARY "")
424 ${OGGDIR}/src/bitwise.c
425 ${OGGDIR}/src/framing.c
426 ${VORBISDIR}/lib/analysis.c
427 ${VORBISDIR}/lib/bitrate.c
428 ${VORBISDIR}/lib/block.c
429 ${VORBISDIR}/lib/codebook.c
430 ${VORBISDIR}/lib/envelope.c
431 ${VORBISDIR}/lib/floor0.c
432 ${VORBISDIR}/lib/floor1.c
433 ${VORBISDIR}/lib/info.c
434 ${VORBISDIR}/lib/lpc.c
435 ${VORBISDIR}/lib/lsp.c
436 ${VORBISDIR}/lib/mapping0.c
437 ${VORBISDIR}/lib/mdct.c
438 ${VORBISDIR}/lib/psy.c
439 ${VORBISDIR}/lib/registry.c
440 ${VORBISDIR}/lib/res0.c
441 ${VORBISDIR}/lib/sharedbook.c
442 ${VORBISDIR}/lib/smallft.c
443 ${VORBISDIR}/lib/synthesis.c
444 ${VORBISDIR}/lib/vorbisfile.c
445 ${VORBISDIR}/lib/window.c
447 endif (NOT OGGVORBIS_FOUND)
450 ${OPENAL_INCLUDE_DIR}
454 ${OPENGL_INCLUDE_DIR}
457 ${VORBISFILE_INCLUDE_DIR}
459 ${CMAKE_SOURCE_DIR}/Source
462 set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIES} ${SDL_LIBRARY} ${OPENGL_glu_LIBRARY} ${VORBISFILE_LIBRARY} ${OGG_LIBRARY} ${PLATFORM_LIBS})
465 add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H})
467 target_link_libraries(lugaru ${LUGARU_LIBS})
470 add_definitions(-DUSE_OPENAL=1 -DUSE_SDL=1 -DBinIO_STDINT_HEADER=<stdint.h>)
472 add_definitions(-DWIN32)
475 add_definitions(-DPLATFORM_LINUX=1 -DPLATFORM_UNIX=1 -DUSE_OPENAL=1 -DUSE_SDL=1 -DBinIO_STDINT_HEADER=<stdint.h>)
480 set(APPS_ROOT "${CMAKE_INSTALL_PREFIX}/Lugaru.app")
481 set(APPS_BIN "${APPS_ROOT}/Contents/MacOS")
482 set(APPS_DATA "${APPS_ROOT}/Contents/Resources")
486 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX})
488 install(FILES ${SDLDIR}/lib/win32/msvc2008/SDL.dll DESTINATION ${CMAKE_INSTALL_PREFIX})
489 install(FILES ${OPENALDIR}/lib/win32/msvc2008/OpenAL32.dll DESTINATION ${CMAKE_INSTALL_PREFIX})
492 install(FILES ${SDLDIR}/lib/win32/mingw/SDL.dll DESTINATION ${CMAKE_INSTALL_PREFIX})
493 install(FILES ${OPENALDIR}/lib/win32/mingw/OpenAL32.dll DESTINATION ${CMAKE_INSTALL_PREFIX})
497 set(CMAKE_INSTALL_PREFIX "${APPS_BIN}")
498 install(FILES ${SRCDIR}/mac-res/lugaru.icns DESTINATION ${APPS_DATA})
499 install(FILES ${SRCDIR}/mac-res/Info.plist DESTINATION ${APPS_ROOT}/Contents)
501 install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru DESTINATION ${CMAKE_INSTALL_PREFIX})
502 if(APPLE AND LUGARU_HAS_INTERNAL_SDL)
503 install(FILES ${SDLDIR}/lib/macosx/libSDL-1.2.0.dylib DESTINATION ${CMAKE_INSTALL_PREFIX})
504 endif(APPLE AND LUGARU_HAS_INTERNAL_SDL)
508 install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${CMAKE_INSTALL_PREFIX})
512 install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${APPS_ROOT})
515 if (LUGARU_MISSING_DEPS)
516 message(STATUS "Using our copy of these libs: ${LUGARU_MISSING_DEPS}")
517 endif (LUGARU_MISSING_DEPS)