From 0033826544c8905883283e5193cb5cdaed9c80c8 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sat, 12 Nov 2022 11:26:05 +1100 Subject: [PATCH] - Allow proper setting of `progdir` for SDL targets. --- CMakeLists.txt | 2 +- source/CMakeLists.txt | 6 ++++++ source/common/platform/posix/sdl/i_main.cpp | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 910a7b94e..3bc1daa03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,7 +99,7 @@ function( add_pk3 PK3_NAME PK3_DIR ) if( WIN32 ) set( INSTALL_PK3_PATH . CACHE STRING "Directory where engine data will be placed during install." ) else() - set( INSTALL_PK3_PATH share/games/raze CACHE STRING "Directory where engine data will be placed during install." ) + set( INSTALL_PK3_PATH ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME} CACHE STRING "Directory where engine data will be placed during install." ) endif() install(FILES "${PROJECT_BINARY_DIR}/${PK3_NAME}" DESTINATION ${INSTALL_PK3_PATH} diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 040a7c92b..8e39ae861 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -503,9 +503,15 @@ elseif( APPLE ) set_source_files_properties( platform/posix/osx/${PROJECT_NAME}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) set_source_files_properties( common/platform/posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions ) else() + option (SYSTEMINSTALL "Set global progdir based on CMake Install Dir" OFF) + set( SYSTEM_SOURCES_DIR common/platform/posix common/platform/posix/sdl ) set( SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES} ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ) + + if ( SYSTEMINSTALL ) + add_definitions( -DPROGDIR="${CMAKE_INSTALL_PREFIX}/${INSTALL_PK3_PATH}" ) + endif() endif() if( HAVE_MMX ) diff --git a/source/common/platform/posix/sdl/i_main.cpp b/source/common/platform/posix/sdl/i_main.cpp index a28b90f01..196504b54 100644 --- a/source/common/platform/posix/sdl/i_main.cpp +++ b/source/common/platform/posix/sdl/i_main.cpp @@ -174,7 +174,9 @@ int main (int argc, char **argv) Args = new FArgs(argc, argv); - // Should we even be doing anything with progdir on Unix systems? +#ifdef PROGDIR + progdir = PROGDIR; +#else char program[PATH_MAX]; if (realpath (argv[0], program) == NULL) strcpy (program, argv[0]); @@ -188,6 +190,7 @@ int main (int argc, char **argv) { progdir = "./"; } +#endif I_StartupJoysticks();