From f418b9530c9a1d3723d599147d6e12c630cebb51 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Fri, 2 Feb 2018 14:13:24 +0100 Upstream: submitted, https://github.com/ja2-stracciatella/ja2-stracciatella/pull/703 Subject: [PATCH] BUILD: fix install paths by utilizing GNUInstallDirs --- CMakeLists.txt | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f354370..9ad99f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,11 @@ set(JA2_BINARY "ja2") set(LAUNCHER_BINARY "ja2-launcher") set(CMAKE_CXX_STANDARD 98) +## includes +if (UNIX AND NOT MINGW AND NOT APPLE) + include(GNUInstallDirs) +endif() + ## Versioning set(ja2-stracciatella_VERSION_MAJOR "0") @@ -36,8 +41,16 @@ if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: Debug RelWithDebInfo." FORCE) endif() set(VERSION_TAG "" CACHE STRING "Build date for nightly versioning") -set(EXTRA_DATA_DIR "" CACHE STRING "Directory for externalized data") -set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") +if (UNIX AND NOT MINGW AND NOT APPLE) + set(EXTRA_DATA_DIR "${CMAKE_INSTALL_FULL_DATADIR}/ja2" CACHE STRING "Directory for externalized data (usually just set CMAKE_INSTALL_DATADIR instead)") +else() + set(EXTRA_DATA_DIR "" CACHE STRING "Directory for externalized data") +endif() +if (UNIX AND NOT MINGW AND NOT APPLE) + set(INSTALL_LIB_DIR ${CMAKE_INSTALL_FULL_LIBDIR}) +else() + set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") +endif() set(LOCAL_SDL_LIB "" CACHE STRING "Use local SDL library from this directory") set(LIBSTRACCIATELLA_TARGET "" CACHE STRING "Rust target architecture for libstracciatella") option(LOCAL_FLTK_LIB "Build with fltk lib" OFF) @@ -316,22 +329,18 @@ set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}_${CPACK_PACKAGE_VERSION}_${PACKAGE_ include(CPack) if (UNIX AND NOT MINGW AND NOT APPLE) - install(TARGETS ${JA2_BINARY} RUNTIME DESTINATION bin) + install(TARGETS ${JA2_BINARY} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) if(BUILD_LAUNCHER) - install(TARGETS ${LAUNCHER_BINARY} RUNTIME DESTINATION bin) + install(TARGETS ${LAUNCHER_BINARY} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() - install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets/externalized assets/mods assets/unittests DESTINATION share/ja2) - install(FILES ${STRACCIATELLA_SHARED_LIB} DESTINATION ${INSTALL_LIB_DIR}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/distr-files-linux/ja2-stracciatella.desktop DESTINATION share/applications) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets/externalized assets/mods assets/unittests DESTINATION ${CMAKE_INSTALL_DATADIR}/ja2) + install(FILES ${STRACCIATELLA_SHARED_LIB} DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/distr-files-linux/ja2-stracciatella.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications) install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/logo.svg RENAME ja2-stracciatella.svg - DESTINATION share/icons/hicolor/scalable/apps) - if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD|DragonFly|OpenBSD") - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/distr-files-linux/ja2_manpage DESTINATION man/man6 RENAME ja2.6) - else() - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/distr-files-linux/ja2_manpage DESTINATION share/man/man6 RENAME ja2.6) - endif() + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/assets/distr-files-linux/ja2_manpage DESTINATION ${CMAKE_INSTALL_MANDIR}/man6 RENAME ja2.6) else() install(TARGETS ${JA2_BINARY} RUNTIME DESTINATION .) if(BUILD_LAUNCHER) -- 2.16.1