Search the installation data directory (#693)

That allows the logic to work on non-FHS distros like NixOS
master
ilya-fedin 2022-05-14 00:55:17 +04:00 committed by GitHub
parent af8e756dcb
commit e0d26ba25a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -97,6 +97,11 @@ option(ALSOFT_UPDATE_BUILD_VERSION "Update git build version info" ON)
option(ALSOFT_EAX "Enable legacy EAX extensions" ${WIN32})
option(ALSOFT_SEARCH_INSTALL_DATADIR "Search the installation data directory" OFF)
if(ALSOFT_SEARCH_INSTALL_DATADIR)
set(ALSOFT_INSTALL_DATADIR ${CMAKE_INSTALL_FULL_DATADIR})
endif()
if(DEFINED SHARE_INSTALL_DIR)
message(WARNING "SHARE_INSTALL_DIR is deprecated. Use the variables provided by the GNUInstallDirs module instead")
set(CMAKE_INSTALL_DATADIR "${SHARE_INSTALL_DIR}")

View File

@ -114,3 +114,6 @@
/* Define if we have pthread_set_name_np() */
#cmakedefine HAVE_PTHREAD_SET_NAME_NP
/* Define the installation data directory */
#cmakedefine ALSOFT_INSTALL_DATADIR "@ALSOFT_INSTALL_DATADIR@"

View File

@ -408,6 +408,20 @@ al::vector<std::string> SearchDataFiles(const char *ext, const char *subdir)
DirectorySearch(path.c_str(), ext, &results);
}
#ifdef ALSOFT_INSTALL_DATADIR
// Search the installation data directory
{
std::string path{ALSOFT_INSTALL_DATADIR};
if(!path.empty())
{
if(path.back() != '/')
path += '/';
path += subdir;
DirectorySearch(path.c_str(), ext, &results);
}
}
#endif
return results;
}