New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix DATADIR compile option #1392
base: master
Are you sure you want to change the base?
Conversation
CMakeLists.txt
Outdated
@@ -19,7 +19,7 @@ option ( ENABLE_CLANG_ANALYSIS "When building with clang, enable the static anal | |||
option ( CHECK_CCACHE "Check if ccache is installed and use it" OFF ) | |||
set ( MSVC_WARNING_LEVEL 3 CACHE STRING "Visual Studio warning levels" ) | |||
option ( FORCE_INSTALL_DATA_TO_BIN "Force installation of data to binary directory" OFF ) | |||
set ( DATADIR "" CACHE STRING "Where to place datafiles" ) | |||
set ( DATADIR "" CACHE STRING "Where to search for datafiles" /) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The slash? Yes, sorry. I fixed it.
if ( UNIX AND NOT APPLE ) | ||
set ( data_install_dir "${CMAKE_INSTALL_FULL_DATADIR}/openxcom" ) | ||
add_definitions( -DDATADIR="${data_install_dir}/" ) | ||
add_definitions( -DINSTALLDIR="${data_install_dir}/" ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the separate define?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the executable knows where its data files were installed. Currently passing DATADIR to cmake does nothing and instead CMAKE_INSTALL_FULL_DATADIR is used to pass -DDATADIR to the preprocessor. Instead of removing the DATADIR cmake option I repurposed it to add an entry to the directory list. A possible application is wanting to install the game files to /usr/share but searching for data files in /opt/ as well (e.g. from a commercial copy of xcom)
As for changing the name of the define, I thought it would be confusing if DATADIR (the C #define) would be set by CMAKE_INSTALL_FULL_DATADIR (the cmake variable) while DATADIR (the cmake variable) was used to set a different c define. This way DATADIR sets DATADIR.
@@ -224,16 +230,17 @@ std::vector<std::string> findDataFolders() | |||
dir = strtok(0, ":"); | |||
} | |||
} | |||
else | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this break use cases where data is spread among multiple folders?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will only break use cases where all of the following apply:
- The data in /usr/(local/)share
- /usr/(local/)share isn't in $XDG_DATA_DIRS
- The game wasn't installed to /usr/(local/)share
- DATADIR was not set to /usr/(local/)share
/usr/(local/)share are supposed to be only a fallback, if XDG_DATA_DIRS isn't set:
$XDG_DATA_DIRS defines the preference-ordered set of base directories to search for data files in addition to the $XDG_DATA_HOME base directory. The directories in $XDG_DATA_DIRS should be seperated with a colon ':'.
If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.
(https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
-DDATADIR used to have no effect. Now it adds a directory to the data search path. Also changes the system-wide data directories (/usr/share, /usr/local/share, /Users/Shared/OpenXcom) to only be searched if XDG_DATA_DIRS is unset or empty.
-DDATADIR used to have no effect. Now it adds a directory to the data search path.
Also changes the system-wide data directories (/usr/share, /usr/local/share, /Users/Shared/OpenXcom) to only be searched if XDG_DATA_DIRS is unset or empty.
fixes #1391