diff options
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | config.h.in | 3 | ||||
-rw-r--r-- | core/helpers.cpp | 14 |
3 files changed, 22 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d3945e95..ebfcc4e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}") diff --git a/config.h.in b/config.h.in index 416b87d4..477d8c77 100644 --- a/config.h.in +++ b/config.h.in @@ -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@" diff --git a/core/helpers.cpp b/core/helpers.cpp index c7e45a8b..6d0863ca 100644 --- a/core/helpers.cpp +++ b/core/helpers.cpp @@ -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; } |