diff options
Diffstat (limited to 'LanguageSettings.cpp')
-rw-r--r-- | LanguageSettings.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/LanguageSettings.cpp b/LanguageSettings.cpp index 5eae731..5bec072 100644 --- a/LanguageSettings.cpp +++ b/LanguageSettings.cpp @@ -72,7 +72,7 @@ std::string LanguageSettings::getCompileCommand(const std::filesystem::path& tar std::string LanguageSettings::getLinkCommand(const std::filesystem::path& target, const std::vector<std::filesystem::path> &inputs, - const std::vector<std::string>& link_libs) const + const std::vector<std::filesystem::path>& link_libs) const { std::string input_string{std::accumulate(inputs.begin(), inputs.end(), std::string{}, [](const std::string& sum, const fs::path& p){ return sum + " " + p.string(); })}; @@ -88,8 +88,16 @@ std::string LanguageSettings::getLinkCommand(const std::filesystem::path& target std::string LDFLAGS_add{is_dynamic_lib(target) ? fmt::format(" -shared -Wl,-soname,{}", soname_shorter(target.string()).string()) : ""s}; - std::string link_libs_string{std::accumulate(link_libs.begin(), link_libs.end(), std::string(), - [](const std::string& sum, const std::string& i){ return sum + " -l" + i; })}; + std::string link_libs_string; + for (const auto& i: link_libs) { + if (is_static_lib(i.string())) { + input_string += " " + i.string(); + } else if (is_dynamic_lib(i.string()) || is_dynamic_lib_link(i.string())) { + input_string += " -L" + i.parent_path().string() + " -l" + dynamic_lib_name(i); + } else { // link external dynamic lib, e.g. "fmt" + link_libs_string += " -l" + i.string(); + } + } // link: $(CXX) $(LDFLAGS) $^ $(LDLIBS) $(LIBS) -o $@ return fmt::format("{}{}{}{}{}{}{} -o {}", |