Skip to content

Commit 435bf53

Browse files
committed
Merge pull request OpenXcom#474 from winterheart/default-data-dir
Compile-time definition of place datadir
2 parents 6024bed + 73ce52e commit 435bf53

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ option ( ENABLE_WARNING "Always show warnings (even for release builds)" OFF )
99
option ( FATAL_WARNING "Treat warnings as errors" OFF )
1010
set ( MSVC_WARNING_LEVEL 3 CACHE STRING "Visual Studio warning levels" )
1111
option ( FORCE_INSTALL_DATA_TO_BIN "Force installation of data to binary directory" OFF )
12+
set ( DATADIR "" CACHE STRING "Where to place datafiles" )
1213

1314
if ( WIN32 )
1415
set ( default_deps_dir "${CMAKE_SOURCE_DIR}/deps" )

src/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,12 @@ set ( install_dest RUNTIME )
591591
set ( set_exec_path ON )
592592
set ( install_dest_dir bin )
593593
if ( UNIX AND NOT APPLE )
594-
set ( data_install_dir ${CMAKE_INSTALL_PREFIX}/share/openxcom )
594+
if ( DEFINED DATADIR )
595+
set ( data_install_dir ${DATADIR} )
596+
add_definitions( -DDATADIR="${data_install_dir}/" )
597+
else()
598+
set ( data_install_dir "share/openxcom" )
599+
endif()
595600
endif ()
596601
if ( APPLE )
597602
set ( openxcom_src ${openxcom_src} ${MACOS_SDLMAIN_M_PATH} )
@@ -603,7 +608,12 @@ if ( APPLE )
603608
set ( install_dest_dir "" )
604609
set ( data_install_dir bin )
605610
else ()
606-
set ( data_install_dir ${CMAKE_INSTALL_PREFIX}/share/openxcom )
611+
if ( DEFINED DATADIR )
612+
set ( data_install_dir ${DATADIR} )
613+
add_definitions( -DDATADIR="${data_install_dir}/" )
614+
else()
615+
set ( data_install_dir "share/openxcom" )
616+
endif()
607617
endif ()
608618
endif ()
609619
if ( set_exec_path )

src/Engine/CrossPlatform.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,18 @@ std::vector<std::string> findDataFolders()
153153
dir = strtok(0, ":");
154154
}
155155
}
156-
else
157-
{
158156
#ifdef __APPLE__
159-
snprintf(path, MAXPATHLEN, "%s/Users/Shared/OpenXcom/data/", home);
160-
list.push_back(path);
157+
snprintf(path, MAXPATHLEN, "%s/Users/Shared/OpenXcom/data/", home);
158+
list.push_back(path);
161159
#else
162-
list.push_back("/usr/local/share/openxcom/data/");
163-
list.push_back("/usr/share/openxcom/data/");
160+
list.push_back("/usr/local/share/openxcom/data/");
161+
list.push_back("/usr/share/openxcom/data/");
162+
#ifdef DATADIR
163+
snprintf(path, MAXPATHLEN, "%s/data/", DATADIR);
164+
list.push_back(path);
165+
#endif
166+
164167
#endif
165-
}
166168

167169
// Get working directory
168170
list.push_back("./data/");

0 commit comments

Comments
 (0)