@@ -656,22 +656,25 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
656656 // Add support for relative paths for (private-)link-libraries
657657 const auto fix_relative_paths = [&name, &path](ConditionVector &libraries, const char *key) {
658658 for (const auto &library_entries : libraries) {
659- for (auto &library_path : libraries[library_entries.first ]) {
659+ for (auto &library : libraries[library_entries.first ]) {
660660 // Skip processing paths with potential CMake macros in them (this check isn't perfect)
661661 // https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#variable-references
662- if ((library_path .find (" ${" ) != std::string::npos || library_path .find (" $ENV{" ) != std::string::npos ||
663- library_path .find (" $CACHE{" ) != std::string::npos) &&
664- library_path .find (' }' ) != std::string::npos) {
662+ if ((library .find (" ${" ) != std::string::npos || library .find (" $ENV{" ) != std::string::npos ||
663+ library .find (" $CACHE{" ) != std::string::npos) &&
664+ library .find (' }' ) != std::string::npos) {
665665 continue ;
666666 }
667667
668- if (fs::exists (fs::path (path) / library_path)) {
669- // If the file path is relative, prepend ${CMAKE_CURRENT_SOURCE_DIR}
670- library_path.insert (0 , " ${CMAKE_CURRENT_SOURCE_DIR}/" );
671- } else if (library_path.find_first_of (R"( \/)" ) != std::string::npos) {
668+ auto library_path = fs::path (path) / library;
669+ if (fs::exists (library_path)) {
670+ if (!fs::is_directory (library_path)) {
671+ // If the file path is relative (and not a directory), prepend ${CMAKE_CURRENT_SOURCE_DIR}
672+ library.insert (0 , " ${CMAKE_CURRENT_SOURCE_DIR}/" );
673+ }
674+ } else if (library.find_first_of (R"( \/)" ) != std::string::npos) {
672675 // Error if the path contains a directory separator and the file doesn't exist
673676 throw std::runtime_error (" Attempted to link against a library file that doesn't exist for target \" " + name + " \" in \" " +
674- key + " \" : " + library_path );
677+ key + " \" : " + library );
675678 } else {
676679 // NOTE: We cannot check if system libraries exist, so we leave them as-is
677680 }
0 commit comments