diff options
author | Brad King <brad.king@kitware.com> | 2021-07-20 15:47:57 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-07-20 15:48:17 (GMT) |
commit | c9d440fcaa878f7dac81e97c3edcdf8b4e14e833 (patch) | |
tree | 739cf160372537bde6a215cab553112846f6413f /Source | |
parent | 4ce0a924796ca7d8ec43f4d254271906e5c661f3 (diff) | |
parent | aa3ab3eb925a601e3acd2d9f569fc3183fab2f8b (diff) | |
download | CMake-c9d440fcaa878f7dac81e97c3edcdf8b4e14e833.zip CMake-c9d440fcaa878f7dac81e97c3edcdf8b4e14e833.tar.gz CMake-c9d440fcaa878f7dac81e97c3edcdf8b4e14e833.tar.bz2 |
Merge topic 'find_library_usable_from_script_mode'
aa3ab3eb92 find_library: Infer library prefix and suffix when in script mode
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6338
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFindLibraryCommand.cxx | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 0cbe637..ef960d1 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -259,6 +259,34 @@ struct cmFindLibraryHelper }; }; +namespace { + +std::string const& get_prefixes(cmMakefile* mf) +{ +#ifdef _WIN32 + static std::string defaultPrefix = ";lib"; +#else + static std::string defaultPrefix = "lib"; +#endif + cmProp prefixProp = mf->GetDefinition("CMAKE_FIND_LIBRARY_PREFIXES"); + return (prefixProp) ? *prefixProp : defaultPrefix; +} + +std::string const& get_suffixes(cmMakefile* mf) +{ +#ifdef _WIN32 + static std::string defaultSuffix = ".lib;.dll.a;.a"; +#elif defined(__APPLE__) + static std::string defaultSuffix = ".tbd;.dylib;.so;.a"; +#elif defined(__hpux) + static std::string defaultSuffix = ".sl;.so;.a"; +#else + static std::string defaultSuffix = ".so;.a"; +#endif + cmProp suffixProp = mf->GetDefinition("CMAKE_FIND_LIBRARY_SUFFIXES"); + return (suffixProp) ? *suffixProp : defaultSuffix; +} +} cmFindLibraryHelper::cmFindLibraryHelper(std::string debugName, cmMakefile* mf, cmFindBase const* base) : Makefile(mf) @@ -268,10 +296,9 @@ cmFindLibraryHelper::cmFindLibraryHelper(std::string debugName, cmMakefile* mf, this->GG = this->Makefile->GetGlobalGenerator(); // Collect the list of library name prefixes/suffixes to try. - std::string const& prefixes_list = - this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_PREFIXES"); - std::string const& suffixes_list = - this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_SUFFIXES"); + std::string const& prefixes_list = get_prefixes(this->Makefile); + std::string const& suffixes_list = get_suffixes(this->Makefile); + cmExpandList(prefixes_list, this->Prefixes, true); cmExpandList(suffixes_list, this->Suffixes, true); this->RegexFromList(this->PrefixRegexStr, this->Prefixes); |