radiant: rework the configuration of FHS and absolute FHS installation
authorThomas Debesse <dev@illwieckz.net>
Sat, 18 Jun 2022 21:23:52 +0000 (23:23 +0200)
committerThomas Debesse <dev@illwieckz.net>
Sat, 18 Jun 2022 21:23:52 +0000 (23:23 +0200)
CMakeLists.txt
radiant/environment.cpp

index 187accfe43f271ea43dde8bc7b09b7c1eb22dfe5..c2d795c846fde527ec8b323aef6d935047668b02 100644 (file)
@@ -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")
 
index f9c6c55debff2bab8530078bb901f2fc43e94a71..ab3dc398cd889bfb883be1cf7c247166cf5f0d2d 100644 (file)
@@ -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() ) {