From: Thomas Debesse Date: Sat, 18 Jun 2022 21:23:52 +0000 (+0200) Subject: radiant: rework the configuration of FHS and absolute FHS installation X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=feb71a7a0cdf7c2a1d8f64935b8fb110cbd48d02;p=xonotic%2Fnetradiant.git radiant: rework the configuration of FHS and absolute FHS installation --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 187accfe..c2d795c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,7 @@ option(BUILD_DAEMONMAP "Build daemonmap navigation mesh generator" ${DEFAULT_BUI option(DOWNLOAD_GAMEPACKS "Download game packs" ON) option(USE_WERROR "Build with -Werror -pedantic-errors" OFF) option(FHS_INSTALL "Install according to Filesystem Hierarchy Standard" OFF) +option(FHS_INSTALL_ABSOLUTE "Install using absolute paths (requires FHS_INSTALL)" OFF) set(BUILD_BINARIES OFF CACHE INTERNAL "...") if (BUILD_RADIANT OR BUILD_TOOLS) @@ -77,7 +78,8 @@ if (BUILD_RADIANT OR BUILD_TOOLS) endif () if (BUILD_BINARIES) - if (WIN32 OR APPLE + if (WIN32 + OR APPLE OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR "${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD" ) set(BUNDLING_SUPPORTED ON) @@ -94,7 +96,11 @@ if (BUILD_BINARIES) endif () if (BUNDLE_LIBRARIES AND BUNDLING_SUPPORTED) - set(FHS_INSTALL OFF CACHE PATH "Disabled because of BUNDLE_LIBRARIES" FORCE) + set(FHS_INSTALL OFF CACHE PATH "Disabled because of BUNDLE_LIBRARIES is enabled" FORCE) + endif () + + if (NOT FHS_INSTALL AND FHS_INSTALL_ABSOLUTE) + set(FHS_INSTALL_ABSOLUTE OFF CACHE PATH "Disabled because of FHS_INSTALL is disabled" FORCE) endif () endif () @@ -119,21 +125,29 @@ set(RADIANT_BASENAME "netradiant" CACHE INTERNAL "...") add_definitions(-DRADIANT_BASENAME="${RADIANT_BASENAME}") set(RADIANT_BIN_DIR ${FINAL_INSTALL_PREFIX} CACHE INTERNAL "...") -set(RADIANT_LIB_DIR ${FINAL_INSTALL_PREFIX}/lib/${CMAKE_LIBRARY_ARCHITECTURE} CACHE INTERNAL "...") +set(RADIANT_LIB_DIR ${FINAL_INSTALL_PREFIX}/lib CACHE INTERNAL "...") set(RADIANT_ADDONS_DIR ${FINAL_INSTALL_PREFIX} CACHE INTERNAL "...") set(RADIANT_SHARE_DIR ${FINAL_INSTALL_PREFIX}/share CACHE INTERNAL "...") set(RADIANT_DATA_DIR ${FINAL_INSTALL_PREFIX} CACHE INTERNAL "...") -if (FHS_INSTALL AND NOT BUNDLE_LIBRARIES) +if (FHS_INSTALL) + add_definitions(-DRADIANT_FHS_INSTALL='ON') + set(RADIANT_BIN_DIR ${FINAL_INSTALL_PREFIX}/bin) set(RADIANT_LIB_DIR ${FINAL_INSTALL_PREFIX}/lib/${CMAKE_LIBRARY_ARCHITECTURE}) set(RADIANT_ADDONS_DIR ${RADIANT_LIB_DIR}/${RADIANT_BASENAME}) set(RADIANT_SHARE_DIR ${FINAL_INSTALL_PREFIX}/share) set(RADIANT_DATA_DIR ${RADIANT_SHARE_DIR}/${RADIANT_BASENAME}) + set(RADIANT_LIB_DIR ${FINAL_INSTALL_PREFIX}/lib/${CMAKE_LIBRARY_ARCHITECTURE}) + + if (FHS_INSTALL_ABSOLUTE) + add_definitions(-DRADIANT_ADDONS_DIR="${RADIANT_ADDONS_DIR}") + add_definitions(-DRADIANT_DATA_DIR="${RADIANT_DATA_DIR}") + else () + add_definitions(-DRADIANT_LIB_ARCH="${CMAKE_LIBRARY_ARCHITECTURE}") + endif () endif () -add_definitions(-DRADIANT_ADDONS_DIR="${RADIANT_ADDONS_DIR}") -add_definitions(-DRADIANT_DATA_DIR="${RADIANT_DATA_DIR}") set(GAMEPACKS_DOWNLOAD_DIR ${PROJECT_BINARY_DIR}/download CACHE PATH "Where to store downloaded game packs") diff --git a/radiant/environment.cpp b/radiant/environment.cpp index f9c6c55d..ab3dc398 100644 --- a/radiant/environment.cpp +++ b/radiant/environment.cpp @@ -280,33 +280,34 @@ void environment_init( int argc, char const* argv[] ){ } { +#if defined(RADIANT_FHS_INSTALL) StringOutputStream buffer; -#ifdef RADIANT_ADDONS_DIR + #if defined(RADIANT_ADDONS_DIR) buffer << RADIANT_ADDONS_DIR << "/"; + #else + buffer << app_path.c_str() << "../lib/"; + buffer << RADIANT_LIB_ARCH << "/"; + buffer << RADIANT_BASENAME << "/"; + #endif + lib_path = buffer.c_str(); #else - buffer << app_path.c_str() << "../lib/" << RADIANT_BASENAME << "/"; + lib_path = app_path.c_str(); #endif - if ( file_is_directory( buffer.c_str() ) ) { - lib_path = buffer.c_str(); - } - else { - lib_path = app_path.c_str(); - } } { +#if defined(RADIANT_FHS_INSTALL) StringOutputStream buffer; -#ifdef RADIANT_DATA_DIR + #if defined(RADIANT_DATA_DIR) buffer << RADIANT_DATA_DIR << "/"; + #else + buffer << app_path.c_str() << "../share/"; + buffer << RADIANT_BASENAME << "/"; + #endif + data_path = buffer.c_str(); #else - buffer << app_path.c_str() << "../share/" << RADIANT_BASENAME << "/"; + data_path = app_path.c_str(); #endif - if ( file_is_directory( buffer.c_str() ) ) { - data_path = buffer.c_str(); - } - else { - data_path = app_path.c_str(); - } } if ( !portable_app_setup() ) {