X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=CMakeLists.txt;h=62a62f29e501b6a47b3e01396aef79676467094a;hb=b84825978803615f45a9f128232e62431042aec0;hp=9bad38c599d952a5189a116286e62ee9eeac8741;hpb=ff29f47f799d99cec7c2a6aa2cf818da2b931fc5;p=lugaru.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bad38c..62a62f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,19 +4,26 @@ cmake_minimum_required(VERSION 3.5) cmake_policy(SET CMP0004 OLD) include(FindPkgConfig) +include(GNUInstallDirs) + + +### Helpers set(SRCDIR "${CMAKE_CURRENT_SOURCE_DIR}/Source") +if(UNIX AND NOT APPLE) + set(LINUX TRUE) +endif() + ### CMake config -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(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE RelWithDebInfo) +endif(NOT CMAKE_BUILD_TYPE) +message("CMake build type: ${CMAKE_BUILD_TYPE}") -if(NOT CMAKE_INSTALL_PREFIX AND WIN32) - set(CMAKE_INSTALL_PREFIX "C:/Lugaru") -endif(NOT CMAKE_INSTALL_PREFIX AND WIN32) +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") @@ -26,6 +33,10 @@ if(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/") @@ -33,72 +44,85 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") set(LUGARU_SRCS ${SRCDIR}/main.cpp - ${SRCDIR}/Frustum.cpp - ${SRCDIR}/Account.cpp - ${SRCDIR}/ConsoleCmds.cpp + ${SRCDIR}/Animation/Animation.cpp + ${SRCDIR}/Animation/Joint.cpp + ${SRCDIR}/Animation/Muscle.cpp + ${SRCDIR}/Animation/Skeleton.cpp + ${SRCDIR}/Audio/openal_wrapper.cpp + ${SRCDIR}/Audio/Sounds.cpp + ${SRCDIR}/Devtools/ConsoleCmds.cpp + ${SRCDIR}/Environment/Lights.cpp + ${SRCDIR}/Environment/Skybox.cpp + ${SRCDIR}/Environment/Terrain.cpp + ${SRCDIR}/Graphic/Models.cpp + ${SRCDIR}/Graphic/Sprite.cpp + ${SRCDIR}/Graphic/Stereo.cpp + ${SRCDIR}/Graphic/Text.cpp + ${SRCDIR}/Graphic/Texture.cpp + ${SRCDIR}/Level/Awards.cpp + ${SRCDIR}/Level/Campaign.cpp + ${SRCDIR}/Level/Dialog.cpp + ${SRCDIR}/Level/Hotspot.cpp + ${SRCDIR}/Math/Frustum.cpp + ${SRCDIR}/Math/Quaternions.cpp + ${SRCDIR}/Menu/Menu.cpp + ${SRCDIR}/Objects/Objects.cpp + ${SRCDIR}/Objects/Person.cpp + ${SRCDIR}/Objects/Weapons.cpp + ${SRCDIR}/User/Account.cpp + ${SRCDIR}/User/Settings.cpp + ${SRCDIR}/Utils/Folders.cpp + ${SRCDIR}/Utils/ImageIO.cpp + ${SRCDIR}/Utils/Input.cpp + ${SRCDIR}/Utils/pack.c + ${SRCDIR}/Utils/private.c + ${SRCDIR}/Utils/unpack.c ${SRCDIR}/Game.cpp ${SRCDIR}/GameDraw.cpp ${SRCDIR}/GameInitDispose.cpp ${SRCDIR}/GameTick.cpp ${SRCDIR}/Globals.cpp - ${SRCDIR}/Lights.cpp - ${SRCDIR}/Menu.cpp - ${SRCDIR}/Models.cpp - ${SRCDIR}/Objects.cpp - ${SRCDIR}/pack.c - ${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}/ImageIO.cpp - ${SRCDIR}/unpack.c - ${SRCDIR}/Weapons.cpp - ${SRCDIR}/openal_wrapper.cpp - ${SRCDIR}/Input.cpp - ${SRCDIR}/Settings.cpp - ${SRCDIR}/Stereo.cpp - ${SRCDIR}/Animation.cpp - ${SRCDIR}/Sounds.cpp - ${SRCDIR}/Awards.cpp + ) set(LUGARU_H - ${SRCDIR}/Frustum.h - ${SRCDIR}/Account.h - ${SRCDIR}/ConsoleCmds.h + ${SRCDIR}/Animation/Animation.h + ${SRCDIR}/Animation/Joint.h + ${SRCDIR}/Animation/Muscle.h + ${SRCDIR}/Animation/Skeleton.h + ${SRCDIR}/Audio/openal_wrapper.h + ${SRCDIR}/Audio/Sounds.h + ${SRCDIR}/Devtools/ConsoleCmds.h + ${SRCDIR}/Environment/Lights.h + ${SRCDIR}/Environment/Skybox.h + ${SRCDIR}/Environment/Terrain.h + ${SRCDIR}/Graphic/gamegl.h + ${SRCDIR}/Graphic/Models.h + ${SRCDIR}/Graphic/Sprite.h + ${SRCDIR}/Graphic/Stereo.h + ${SRCDIR}/Graphic/Text.h + ${SRCDIR}/Graphic/Texture.h + ${SRCDIR}/Level/Campaign.h + ${SRCDIR}/Level/Dialog.h + ${SRCDIR}/Level/Hotspot.h + ${SRCDIR}/Math/Frustum.h + ${SRCDIR}/Math/PhysicsMath.h + ${SRCDIR}/Math/Quaternions.h + ${SRCDIR}/Math/Random.h + ${SRCDIR}/Menu/Menu.h + ${SRCDIR}/Objects/Objects.h + ${SRCDIR}/Objects/Person.h + ${SRCDIR}/Objects/Weapons.h + ${SRCDIR}/Thirdparty/optionparser.h + ${SRCDIR}/User/Account.h + ${SRCDIR}/User/Settings.h + ${SRCDIR}/Utils/binio.h + ${SRCDIR}/Utils/Folders.h + ${SRCDIR}/Utils/ImageIO.h + ${SRCDIR}/Utils/Input.h + ${SRCDIR}/Utils/private.h ${SRCDIR}/Game.h - ${SRCDIR}/Lights.h - ${SRCDIR}/Menu.h - ${SRCDIR}/Models.h - ${SRCDIR}/Objects.h - ${SRCDIR}/Person.h - ${SRCDIR}/PhysicsMath.h - ${SRCDIR}/Quaternions.h - ${SRCDIR}/Random.h - ${SRCDIR}/Skeleton.h - ${SRCDIR}/Skybox.h - ${SRCDIR}/Sprite.h - ${SRCDIR}/ImageIO.h - ${SRCDIR}/Terrain.h - ${SRCDIR}/Texture.h - ${SRCDIR}/Text.h - ${SRCDIR}/Weapons.h - ${SRCDIR}/Input.h - ${SRCDIR}/binio.h - ${SRCDIR}/openal_wrapper.h - ${SRCDIR}/optionparser.h - ${SRCDIR}/gamegl.h - ${SRCDIR}/glstubs.h - ${SRCDIR}/private.h - ${SRCDIR}/Settings.h - ${SRCDIR}/Stereo.h - ${SRCDIR}/Animation.h - ${SRCDIR}/Sounds.h + ) if(UNIX) @@ -193,14 +217,27 @@ endif(WIN32) ### 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) - 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) +# Actual installation instructions + if(WIN32) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX}) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${CMAKE_INSTALL_PREFIX}) if(MINGW) # Based off Mageia/Fedora MinGW toolchain, might not work on other distros or Windows set(LIBGCC_S libgcc_s_sjlj-1.dll) @@ -222,23 +259,38 @@ if(WIN32) ${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) -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("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}) + install(DIRECTORY ${CMAKE_SOURCE_DIR}/Data DESTINATION ${CMAKE_INSTALL_PREFIX}) + endif(SYSTEM_INSTALL) +endif(LINUX) 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) + +# Documentation + +install(FILES ${CMAKE_SOURCE_DIR}/AUTHORS + ${CMAKE_SOURCE_DIR}/CONTENT-LICENSE.txt + ${CMAKE_SOURCE_DIR}/COPYING.txt + ${CMAKE_SOURCE_DIR}/DEVTOOLS.txt + ${CMAKE_SOURCE_DIR}/README.md + DESTINATION ${LUGARU_DOCDIR})