-
Notifications
You must be signed in to change notification settings - Fork 477
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,10 @@ std::vector<std::string> findDataFolders() | |
PathAppendA(path, "OpenXcom\\"); | ||
list.push_back(path); | ||
} | ||
|
||
#ifdef DATADIR | ||
snprintf(path, MAX_PATH, "%s\\", DATADIR); | ||
list.push_back(path); | ||
#endif | ||
// Get binary directory | ||
if (GetModuleFileNameA(NULL, path, MAX_PATH) != 0) | ||
{ | ||
|
@@ -210,9 +213,12 @@ std::vector<std::string> findDataFolders() | |
#endif | ||
} | ||
list.push_back(path); | ||
|
||
#ifdef DATADIR | ||
snprintp(path, MAXPATHLEN, "%s/" DATADIR); | ||
list.push_back(path); | ||
#endif | ||
// Get global data folders | ||
if (char const *const xdg_data_dirs = getenv("XDG_DATA_DIRS")) | ||
if (char const *const xdg_data_dirs = getenv("XDG_DATA_DIRS") && *xdg_data_dirs) | ||
{ | ||
char xdg_data_dirs_copy[strlen(xdg_data_dirs)+1]; | ||
strcpy(xdg_data_dirs_copy, xdg_data_dirs); | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. It will only break use cases where all of the following apply:
/usr/(local/)share are supposed to be only a fallback, if XDG_DATA_DIRS isn't set:
(https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) |
||
#ifdef __APPLE__ | ||
list.push_back("/Users/Shared/OpenXcom/"); | ||
#else | ||
list.push_back("/usr/local/share/openxcom/"); | ||
list.push_back("/usr/share/openxcom/"); | ||
#ifdef DATADIR | ||
snprintf(path, MAXPATHLEN, "%s/", DATADIR); | ||
list.push_back(path); | ||
#endif | ||
|
||
#ifdef INSTALLDIR | ||
snprintf(path, MAXPATHLEN, "%s", INSTALLDIR); | ||
list.push_back(path); | ||
#endif | ||
// Get working directory | ||
list.push_back("./"); | ||
|
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.