]> git.jsancho.org Git - lugaru.git/blobdiff - CMakeLists.txt
Moved Skeleton and Animation to their own folder.
[lugaru.git] / CMakeLists.txt
index c55c50a12538a451e459a0cd8caa246c50f69575..ddcbd7004c5c6c3f88ea2c4ac47df3c8778d395b 100644 (file)
@@ -4,19 +4,21 @@ cmake_minimum_required(VERSION 3.5)
 cmake_policy(SET CMP0004 OLD)
 
 include(FindPkgConfig)
 cmake_policy(SET CMP0004 OLD)
 
 include(FindPkgConfig)
+include(GNUInstallDirs)
 
 set(SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/Source")
 
 
 
 set(SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/Source")
 
 
-### CMake config
+### Helper
 
 
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 --std=c++11")
-set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-parentheses -g -pg --std=c++11")
-set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wno-parentheses -O2 -std=c++11")
+if(UNIX AND NOT APPLE)
+    set(LINUX TRUE)
+endif()
 
 
-if(NOT CMAKE_INSTALL_PREFIX AND WIN32)
-    set(CMAKE_INSTALL_PREFIX "C:/Lugaru")
-endif(NOT CMAKE_INSTALL_PREFIX AND WIN32)
+
+### CMake config
+
+set(CMAKE_CXX_FLAGS "-Wall -Wno-parentheses -pedantic --std=c++11 ${CMAKE_CXX_FLAGS}")
 
 if(APPLE)
     set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX")
 
 if(APPLE)
     set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX")
@@ -26,15 +28,23 @@ if(APPLE)
         "The product will be built against the headers and libraries located inside the indicated SDK.")
 endif(APPLE)
 
         "The product will be built against the headers and libraries located inside the indicated SDK.")
 endif(APPLE)
 
+if(LINUX)
+    option(SYSTEM_INSTALL "Enable system-wide installation, with hardcoded data directory defined with CMAKE_INSTALL_DATADIR" OFF)
+endif(LINUX)
+
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
 
 
 ### Sources
 
 set(LUGARU_SRCS
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
 
 
 ### Sources
 
 set(LUGARU_SRCS
+    ${SRCDIR}/main.cpp
+    ${SRCDIR}/Animation/Animation.cpp
+    ${SRCDIR}/Animation/Skeleton.cpp
     ${SRCDIR}/Frustum.cpp
     ${SRCDIR}/Account.cpp
     ${SRCDIR}/ConsoleCmds.cpp
     ${SRCDIR}/Frustum.cpp
     ${SRCDIR}/Account.cpp
     ${SRCDIR}/ConsoleCmds.cpp
+    ${SRCDIR}/Dialog.cpp
     ${SRCDIR}/Game.cpp
     ${SRCDIR}/GameDraw.cpp
     ${SRCDIR}/GameInitDispose.cpp
     ${SRCDIR}/Game.cpp
     ${SRCDIR}/GameDraw.cpp
     ${SRCDIR}/GameInitDispose.cpp
@@ -48,29 +58,30 @@ set(LUGARU_SRCS
     ${SRCDIR}/Person.cpp
     ${SRCDIR}/private.c
     ${SRCDIR}/Quaternions.cpp
     ${SRCDIR}/Person.cpp
     ${SRCDIR}/private.c
     ${SRCDIR}/Quaternions.cpp
-    ${SRCDIR}/Skeleton.cpp
     ${SRCDIR}/Skybox.cpp
     ${SRCDIR}/Sprite.cpp
     ${SRCDIR}/Terrain.cpp
     ${SRCDIR}/Texture.cpp
     ${SRCDIR}/Text.cpp
     ${SRCDIR}/Skybox.cpp
     ${SRCDIR}/Sprite.cpp
     ${SRCDIR}/Terrain.cpp
     ${SRCDIR}/Texture.cpp
     ${SRCDIR}/Text.cpp
-    ${SRCDIR}/TGALoader.cpp
+    ${SRCDIR}/ImageIO.cpp
     ${SRCDIR}/unpack.c
     ${SRCDIR}/Weapons.cpp
     ${SRCDIR}/unpack.c
     ${SRCDIR}/Weapons.cpp
-    ${SRCDIR}/OpenGL_Windows.cpp
     ${SRCDIR}/openal_wrapper.cpp
     ${SRCDIR}/Input.cpp
     ${SRCDIR}/Settings.cpp
     ${SRCDIR}/Stereo.cpp
     ${SRCDIR}/openal_wrapper.cpp
     ${SRCDIR}/Input.cpp
     ${SRCDIR}/Settings.cpp
     ${SRCDIR}/Stereo.cpp
-    ${SRCDIR}/Animation.cpp
     ${SRCDIR}/Sounds.cpp
     ${SRCDIR}/Awards.cpp
     ${SRCDIR}/Sounds.cpp
     ${SRCDIR}/Awards.cpp
+    ${SRCDIR}/Utils/Folders.cpp
 )
 
 set(LUGARU_H
 )
 
 set(LUGARU_H
+    ${SRCDIR}/Animation/Animation.h
+    ${SRCDIR}/Animation/Skeleton.h
     ${SRCDIR}/Frustum.h
     ${SRCDIR}/Account.h
     ${SRCDIR}/ConsoleCmds.h
     ${SRCDIR}/Frustum.h
     ${SRCDIR}/Account.h
     ${SRCDIR}/ConsoleCmds.h
+    ${SRCDIR}/Dialog.h
     ${SRCDIR}/Game.h
     ${SRCDIR}/Lights.h
     ${SRCDIR}/Menu.h
     ${SRCDIR}/Game.h
     ${SRCDIR}/Lights.h
     ${SRCDIR}/Menu.h
@@ -80,10 +91,9 @@ set(LUGARU_H
     ${SRCDIR}/PhysicsMath.h
     ${SRCDIR}/Quaternions.h
     ${SRCDIR}/Random.h
     ${SRCDIR}/PhysicsMath.h
     ${SRCDIR}/Quaternions.h
     ${SRCDIR}/Random.h
-    ${SRCDIR}/Skeleton.h
     ${SRCDIR}/Skybox.h
     ${SRCDIR}/Sprite.h
     ${SRCDIR}/Skybox.h
     ${SRCDIR}/Sprite.h
-    ${SRCDIR}/TGALoader.h
+    ${SRCDIR}/ImageIO.h
     ${SRCDIR}/Terrain.h
     ${SRCDIR}/Texture.h
     ${SRCDIR}/Text.h
     ${SRCDIR}/Terrain.h
     ${SRCDIR}/Texture.h
     ${SRCDIR}/Text.h
@@ -91,13 +101,13 @@ set(LUGARU_H
     ${SRCDIR}/Input.h
     ${SRCDIR}/binio.h
     ${SRCDIR}/openal_wrapper.h
     ${SRCDIR}/Input.h
     ${SRCDIR}/binio.h
     ${SRCDIR}/openal_wrapper.h
+    ${SRCDIR}/optionparser.h
     ${SRCDIR}/gamegl.h
     ${SRCDIR}/gamegl.h
-    ${SRCDIR}/glstubs.h
     ${SRCDIR}/private.h
     ${SRCDIR}/Settings.h
     ${SRCDIR}/Stereo.h
     ${SRCDIR}/private.h
     ${SRCDIR}/Settings.h
     ${SRCDIR}/Stereo.h
-    ${SRCDIR}/Animation.h
     ${SRCDIR}/Sounds.h
     ${SRCDIR}/Sounds.h
+    ${SRCDIR}/Utils/Folders.h
 )
 
 if(UNIX)
 )
 
 if(UNIX)
@@ -192,12 +202,24 @@ endif(WIN32)
 
 ### Installation
 
 
 ### Installation
 
+if(NOT CMAKE_INSTALL_PREFIX AND WIN32)
+    set(CMAKE_INSTALL_PREFIX "C:/Lugaru")
+endif(NOT CMAKE_INSTALL_PREFIX AND WIN32)
+
+# OS-specific installation paths
+
+set(LUGARU_DOCDIR ${CMAKE_INSTALL_PREFIX})
+if(LINUX)
+endif(LINUX)
+
 if(APPLE)
 if(APPLE)
-    set(APPS_ROOT "${CMAKE_INSTALL_PREFIX}/Lugaru.app")
-    set(APPS_BIN "${APPS_ROOT}/Contents/MacOS")
-    set(APPS_DATA "${APPS_ROOT}/Contents/Resources")
+    set(LUGARU_APP_ROOT ${CMAKE_INSTALL_PREFIX}/Lugaru.app)
+    set(LUGARU_BINDIR ${LUGARU_APP_ROOT}/Contents/MacOS)
+    set(LUGARU_RESDIR ${LUGARU_APP_ROOT}/Resources)
 endif(APPLE)
 
 endif(APPLE)
 
+# Actual installation instructions
+
 if(WIN32)
     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX})
     if(MINGW)
 if(WIN32)
     install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX})
     if(MINGW)
@@ -221,23 +243,38 @@ if(WIN32)
                       ${DLL_ROOT}/zlib1.dll
                 DESTINATION ${CMAKE_INSTALL_PREFIX})
     endif(MINGW)
                       ${DLL_ROOT}/zlib1.dll
                 DESTINATION ${CMAKE_INSTALL_PREFIX})
     endif(MINGW)
-else(WIN32)
-    if(APPLE)
-        set(CMAKE_INSTALL_PREFIX "${APPS_BIN}")
-        install(FILES ${SRCDIR}/mac-res/lugaru.icns DESTINATION ${APPS_DATA})
-        install(FILES ${SRCDIR}/mac-res/Info.plist DESTINATION ${APPS_ROOT}/Contents)
-    endif(APPLE)
-    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru DESTINATION ${CMAKE_INSTALL_PREFIX})
 endif(WIN32)
 
 endif(WIN32)
 
-if(NOT APPLE)
-    install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${CMAKE_INSTALL_PREFIX})
-    install(FILES ${CMAKE_SOURCE_DIR}/README.md
-                  ${CMAKE_SOURCE_DIR}/COPYING.txt
-                  ${CMAKE_SOURCE_DIR}/CONTENT-LICENSE.txt
-            DESTINATION ${CMAKE_INSTALL_PREFIX})
-endif(NOT APPLE)
+if(LINUX)
+    if(SYSTEM_INSTALL)
+        add_definitions(-DDATA_DIR="${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}")
+        set(LUGARU_DOCDIR ${CMAKE_INSTALL_DOCDIR})
+        install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru DESTINATION ${CMAKE_INSTALL_BINDIR})
+        # Trailing '/' is significant, it installs and _renames_ Data/ as the destination folder
+        install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data/ DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
+        install(FILES ${CMAKE_SOURCE_DIR}/Dist/lugaru.appdata.xml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/appdata)
+        install(FILES ${CMAKE_SOURCE_DIR}/Dist/lugaru.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
+        install(FILES ${CMAKE_SOURCE_DIR}/Dist/lugaru.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps)
+        install(FILES ${CMAKE_SOURCE_DIR}/Dist/lugaru.6 DESTINATION ${CMAKE_INSTALL_MANDIR}/man6)
+    else(SYSTEM_INSTALL)
+        message(WARNING "You are installing Lugaru without having enabled the SYSTEM_INSTALL option. It will default to looking for the data in the 'Data' directory next to the binary.")
+        install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru DESTINATION ${CMAKE_INSTALL_PREFIX})
+        install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${CMAKE_INSTALL_PREFIX})
+    endif(SYSTEM_INSTALL)
+endif(LINUX)
 
 if(APPLE)
 
 if(APPLE)
-    install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${APPS_ROOT})
+    install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru DESTINATION ${LUGARU_BINDIR})
+    install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${LUGARU_APP_ROOT})
+    install(FILES ${CMAKE_SOURCE_DIR}/Dist/OSX/lugaru.icns DESTINATION ${LUGARU_RESDIR})
+    install(FILES ${CMAKE_SOURCE_DIR}/Dist/OSX/Info.plist DESTINATION ${LUGARU_APP_ROOT}/Contents)
 endif(APPLE)
 endif(APPLE)
+
+# Documentation
+
+install(FILES ${CMAKE_SOURCE_DIR}/AUTHORS
+              ${CMAKE_SOURCE_DIR}/CONTENT-LICENSE.txt
+              ${CMAKE_SOURCE_DIR}/COPYING.txt
+              ${CMAKE_SOURCE_DIR}/DEBUG-OPTIONS.txt
+              ${CMAKE_SOURCE_DIR}/README.md
+        DESTINATION ${LUGARU_DOCDIR})