]> git.jsancho.org Git - lugaru.git/blobdiff - CMakeLists.txt
Friends fight with true enemies, before they attacked player but hurting enemies
[lugaru.git] / CMakeLists.txt
index ef94e17f7757eea7a9b8fcc3dc807b67a76fca5d..f65500d8c1ce7f86488d5f787aef7a70dd31aeb4 100644 (file)
@@ -21,9 +21,9 @@ endif()
 if(NOT CMAKE_BUILD_TYPE)
     set(CMAKE_BUILD_TYPE RelWithDebInfo)
 endif(NOT CMAKE_BUILD_TYPE)
-message("CMake build type: ${CMAKE_BUILD_TYPE}")
+message(STATUS "CMake build type: ${CMAKE_BUILD_TYPE}")
 
-set(CMAKE_CXX_FLAGS "-Wall -Wno-parentheses -pedantic --std=gnu++11 ${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-parentheses -pedantic --std=gnu++11 ${CMAKE_CXX_FLAGS}")
 
 if(APPLE)
     set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for OSX")
@@ -37,7 +37,54 @@ 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/")
+
+### Version
+
+# Version for the current (stable) or next (development) release
+set(LUGARU_VERSION_MAJOR 1)
+set(LUGARU_VERSION_MINOR 3)
+set(LUGARU_VERSION_PATCH 0)
+
+# MAJOR.MINOR, or MAJOR.MINOR.PATCH if PATCH != 0
+set(LUGARU_VERSION_NUMBER "${LUGARU_VERSION_MAJOR}.${LUGARU_VERSION_MINOR}")
+if(LUGARU_VERSION_PATCH)
+    set(LUGARU_VERSION_NUMBER "${LUGARU_VERSION_NUMBER}.${LUGARU_VERSION_PATCH}")
+endif()
+
+# Set to "" for stable (tagged) builds, "-dev" for dev builds
+set(LUGARU_VERSION_SUFFIX "-dev")  # development
+#set(LUGARU_VERSION_SUFFIX "")  # stable
+
+# Set to 7-char git commit hash if available, otherwise "".
+# On stable (tagged) builds, this is ignored.
+set(LUGARU_VERSION_HASH "")
+if(LUGARU_VERSION_SUFFIX STREQUAL "-dev" AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
+    find_package(Git)
+    if(GIT_FOUND)
+        execute_process(
+            COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
+            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+            OUTPUT_VARIABLE "LUGARU_VERSION_HASH"
+            ERROR_QUIET
+            OUTPUT_STRIP_TRAILING_WHITESPACE)
+        message(STATUS "Git commit hash: ${LUGARU_VERSION_HASH}")
+    endif()
+endif()
+
+set(LUGARU_VERSION_RELEASE "" CACHE STRING "Optional release string, e.g. for distro packages release number")
+
+# Final string built from the above constants, following the scheme:
+# MAJOR.MINOR[.PATCH][-dev] [(git HASH)] [[RELEASE]]
+set(LUGARU_VERSION_STRING "${LUGARU_VERSION_NUMBER}${LUGARU_VERSION_SUFFIX}")
+if(NOT LUGARU_VERSION_HASH STREQUAL "")
+    set(LUGARU_VERSION_STRING "${LUGARU_VERSION_STRING} (git ${LUGARU_VERSION_HASH})")
+endif()
+if(NOT LUGARU_VERSION_RELEASE STREQUAL "")
+    set(LUGARU_VERSION_STRING "${LUGARU_VERSION_STRING} [${LUGARU_VERSION_RELEASE}]")
+endif()
+
+message(STATUS "Version string: ${LUGARU_VERSION_STRING}")
+configure_file(${SRCDIR}/Version.hpp.in ${SRCDIR}/Version.hpp ESCAPE_QUOTES @ONLY)
 
 
 ### Sources
@@ -54,6 +101,7 @@ set(LUGARU_SRCS
     ${SRCDIR}/Environment/Lights.cpp
     ${SRCDIR}/Environment/Skybox.cpp
     ${SRCDIR}/Environment/Terrain.cpp
+    ${SRCDIR}/Graphic/Decal.cpp
     ${SRCDIR}/Graphic/Models.cpp
     ${SRCDIR}/Graphic/Sprite.cpp
     ${SRCDIR}/Graphic/Stereo.cpp
@@ -64,11 +112,14 @@ set(LUGARU_SRCS
     ${SRCDIR}/Level/Dialog.cpp
     ${SRCDIR}/Level/Hotspot.cpp
     ${SRCDIR}/Math/Frustum.cpp
-    ${SRCDIR}/Math/Quaternions.cpp
+    ${SRCDIR}/Math/XYZ.cpp
     ${SRCDIR}/Menu/Menu.cpp
     ${SRCDIR}/Objects/Object.cpp
     ${SRCDIR}/Objects/Person.cpp
+    ${SRCDIR}/Objects/PersonType.cpp
     ${SRCDIR}/Objects/Weapons.cpp
+    ${SRCDIR}/Platform/PlatformUnix.cpp
+    ${SRCDIR}/Platform/PlatformWindows.cpp
     ${SRCDIR}/User/Account.cpp
     ${SRCDIR}/User/Settings.cpp
     ${SRCDIR}/Utils/Folders.cpp
@@ -97,6 +148,7 @@ set(LUGARU_H
     ${SRCDIR}/Environment/Lights.hpp
     ${SRCDIR}/Environment/Skybox.hpp
     ${SRCDIR}/Environment/Terrain.hpp
+    ${SRCDIR}/Graphic/Decal.hpp
     ${SRCDIR}/Graphic/gamegl.hpp
     ${SRCDIR}/Graphic/Models.hpp
     ${SRCDIR}/Graphic/Sprite.hpp
@@ -107,13 +159,14 @@ set(LUGARU_H
     ${SRCDIR}/Level/Dialog.hpp
     ${SRCDIR}/Level/Hotspot.hpp
     ${SRCDIR}/Math/Frustum.hpp
-    ${SRCDIR}/Math/PhysicsMath.hpp
-    ${SRCDIR}/Math/Quaternions.hpp
+    ${SRCDIR}/Math/XYZ.hpp
     ${SRCDIR}/Math/Random.hpp
     ${SRCDIR}/Menu/Menu.hpp
     ${SRCDIR}/Objects/Object.hpp
     ${SRCDIR}/Objects/Person.hpp
+    ${SRCDIR}/Objects/PersonType.hpp
     ${SRCDIR}/Objects/Weapons.hpp
+    ${SRCDIR}/Platform/Platform.hpp
     ${SRCDIR}/Thirdparty/optionparser.h
     ${SRCDIR}/User/Account.hpp
     ${SRCDIR}/User/Settings.hpp
@@ -127,35 +180,15 @@ set(LUGARU_H
 
 )
 
-if(UNIX)
-    set(LUGARU_SRCS
-        ${LUGARU_SRCS}
-        ${SRCDIR}/MacCompatibility.cpp
-    )
-    set(LUGARU_H
-        ${LUGARU_H}
-        ${SRCDIR}/MacCompatibility.hpp
-    )
-endif(UNIX)
-
+set(LUGARU_OBJS "")
 if(WIN32)
-    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
+    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Lugaru.res
                        COMMAND ${CMAKE_RC_COMPILER}
-                       -I${SRCDIR}/win-res
-                       -o ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
-                       -i${SRCDIR}/win-res/Lugaru.rc
-                       DEPENDS ${SRCDIR}/win-res/Lugaru.rc
+                       -o ${CMAKE_CURRENT_BINARY_DIR}/Lugaru.res
+                       -i${SRCDIR}/Lugaru.rc
+                       DEPENDS ${SRCDIR}/Lugaru.rc
     )
-
-    # FIXME: get rid of this.
-    set(LUGARU_SRCS
-        ${LUGARU_SRCS}
-        ${SRCDIR}/WinDefs.cpp)
-
-    set(LUGARU_H
-        ${LUGARU_H}
-        ${SRCDIR}/WinDefs.hpp
-        ${SRCDIR}/win-res/resource.hpp)
+    set(LUGARU_OBJS "Lugaru.res")
 endif(WIN32)
 
 if(APPLE)
@@ -184,32 +217,25 @@ endif(APPLE)
 
 find_package(PNG REQUIRED)
 find_package(JPEG REQUIRED)
-find_package(ZLIB REQUIRED)
-find_package(OggVorbis REQUIRED)
+
+pkg_check_modules(VORBISFILE vorbisfile REQUIRED)
 
 include_directories(
     ${OPENAL_INCLUDE_DIR}
     ${JPEG_INCLUDE_DIR}
     ${PNG_INCLUDE_DIR}
-    ${ZLIB_INCLUDE_DIR}
     ${OPENGL_INCLUDE_DIR}
     ${SDL2_INCLUDE_DIRS}
     ${VORBISFILE_INCLUDE_DIR}
-    ${OGG_INCLUDE_DIR}
     ${CMAKE_SOURCE_DIR}/Source
 )
 
-set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIES} ${SDL2_LIBRARIES} ${OPENGL_LIBRARIES} ${VORBISFILE_LIBRARY} ${OGG_LIBRARY} ${PLATFORM_LIBS})
+set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${SDL2_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${VORBISFILE_LIBRARIES} ${PLATFORM_LIBS})
 
 
 ### Definitions
 
-if(WIN32)
-    add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H} lugaru_resource.obj)
-else(WIN32)
-    add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H})
-endif(WIN32)
-
+add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H} ${LUGARU_OBJS})
 target_link_libraries(lugaru ${LUGARU_LIBS})
 
 if(WIN32)
@@ -276,10 +302,10 @@ if(LINUX)
         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)
+        install(FILES ${CMAKE_SOURCE_DIR}/Dist/Linux/lugaru.appdata.xml DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/appdata)
+        install(FILES ${CMAKE_SOURCE_DIR}/Dist/Linux/lugaru.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
+        install(FILES ${CMAKE_SOURCE_DIR}/Dist/Linux/lugaru.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps)
+        install(FILES ${CMAKE_SOURCE_DIR}/Dist/Linux/lugaru.6 DESTINATION ${CMAKE_INSTALL_MANDIR}/man6)
     else(SYSTEM_INSTALL)
         message("You are building 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})