@@ -656,22 +656,25 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
656
656
// Add support for relative paths for (private-)link-libraries
657
657
const auto fix_relative_paths = [&name, &path](ConditionVector &libraries, const char *key) {
658
658
for (const auto &library_entries : libraries) {
659
- for (auto &library_path : libraries[library_entries.first ]) {
659
+ for (auto &library : libraries[library_entries.first ]) {
660
660
// Skip processing paths with potential CMake macros in them (this check isn't perfect)
661
661
// 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) {
665
665
continue ;
666
666
}
667
667
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) {
672
675
// Error if the path contains a directory separator and the file doesn't exist
673
676
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 );
675
678
} else {
676
679
// NOTE: We cannot check if system libraries exist, so we leave them as-is
677
680
}
0 commit comments