@@ -849,31 +849,31 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
849
849
{
850
850
// Get possible library name prefixes.
851
851
cmMakefile* mf = this ->Makefile ;
852
- this ->AddLinkPrefix (mf->GetDefinition (" CMAKE_STATIC_LIBRARY_PREFIX" ));
853
- this ->AddLinkPrefix (mf->GetDefinition (" CMAKE_SHARED_LIBRARY_PREFIX" ));
852
+ this ->AddLinkPrefix (mf->GetSafeDefinition (" CMAKE_STATIC_LIBRARY_PREFIX" ));
853
+ this ->AddLinkPrefix (mf->GetSafeDefinition (" CMAKE_SHARED_LIBRARY_PREFIX" ));
854
854
855
855
// Import library names should be matched and treated as shared
856
856
// libraries for the purposes of linking.
857
- this ->AddLinkExtension (mf->GetDefinition (" CMAKE_IMPORT_LIBRARY_SUFFIX" ),
857
+ this ->AddLinkExtension (mf->GetSafeDefinition (" CMAKE_IMPORT_LIBRARY_SUFFIX" ),
858
858
LinkShared);
859
- this ->AddLinkExtension (mf->GetDefinition (" CMAKE_STATIC_LIBRARY_SUFFIX" ),
859
+ this ->AddLinkExtension (mf->GetSafeDefinition (" CMAKE_STATIC_LIBRARY_SUFFIX" ),
860
860
LinkStatic);
861
- this ->AddLinkExtension (mf->GetDefinition (" CMAKE_SHARED_LIBRARY_SUFFIX" ),
861
+ this ->AddLinkExtension (mf->GetSafeDefinition (" CMAKE_SHARED_LIBRARY_SUFFIX" ),
862
862
LinkShared);
863
- this ->AddLinkExtension (mf->GetDefinition (" CMAKE_LINK_LIBRARY_SUFFIX" ),
863
+ this ->AddLinkExtension (mf->GetSafeDefinition (" CMAKE_LINK_LIBRARY_SUFFIX" ),
864
864
LinkUnknown);
865
865
if (const char * linkSuffixes =
866
866
mf->GetDefinition (" CMAKE_EXTRA_LINK_EXTENSIONS" )) {
867
867
std::vector<std::string> linkSuffixVec = cmExpandedList (linkSuffixes);
868
868
for (std::string const & i : linkSuffixVec) {
869
- this ->AddLinkExtension (i. c_str () , LinkUnknown);
869
+ this ->AddLinkExtension (i, LinkUnknown);
870
870
}
871
871
}
872
872
if (const char * sharedSuffixes =
873
873
mf->GetDefinition (" CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES" )) {
874
874
std::vector<std::string> sharedSuffixVec = cmExpandedList (sharedSuffixes);
875
875
for (std::string const & i : sharedSuffixVec) {
876
- this ->AddLinkExtension (i. c_str () , LinkShared);
876
+ this ->AddLinkExtension (i, LinkShared);
877
877
}
878
878
}
879
879
@@ -903,7 +903,7 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
903
903
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
904
904
fprintf (stderr, " any regex [%s]\n " , reg_any.c_str ());
905
905
#endif
906
- this ->ExtractAnyLibraryName .compile (reg_any. c_str () );
906
+ this ->ExtractAnyLibraryName .compile (reg_any);
907
907
908
908
// Create a regex to match static library names.
909
909
if (!this ->StaticLinkExtensions .empty ()) {
@@ -912,7 +912,7 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
912
912
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
913
913
fprintf (stderr, " static regex [%s]\n " , reg_static.c_str ());
914
914
#endif
915
- this ->ExtractStaticLibraryName .compile (reg_static. c_str () );
915
+ this ->ExtractStaticLibraryName .compile (reg_static);
916
916
}
917
917
918
918
// Create a regex to match shared library names.
@@ -924,20 +924,21 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
924
924
#ifdef CM_COMPUTE_LINK_INFO_DEBUG
925
925
fprintf (stderr, " shared regex [%s]\n " , reg_shared.c_str ());
926
926
#endif
927
- this ->ExtractSharedLibraryName .compile (reg_shared. c_str () );
927
+ this ->ExtractSharedLibraryName .compile (reg_shared);
928
928
}
929
929
}
930
930
931
- void cmComputeLinkInformation::AddLinkPrefix (const char * p)
931
+ void cmComputeLinkInformation::AddLinkPrefix (std::string const & p)
932
932
{
933
- if (p && *p ) {
933
+ if (!p. empty () ) {
934
934
this ->LinkPrefixes .insert (p);
935
935
}
936
936
}
937
937
938
- void cmComputeLinkInformation::AddLinkExtension (const char * e, LinkType type)
938
+ void cmComputeLinkInformation::AddLinkExtension (std::string const & e,
939
+ LinkType type)
939
940
{
940
- if (e && *e ) {
941
+ if (!e. empty () ) {
941
942
if (type == LinkStatic) {
942
943
this ->StaticLinkExtensions .emplace_back (e);
943
944
}
@@ -962,7 +963,7 @@ std::string cmComputeLinkInformation::CreateExtensionRegex(
962
963
// Store this extension choice with the "." escaped.
963
964
libext += " \\ " ;
964
965
#if defined(_WIN32) && !defined(__CYGWIN__)
965
- libext += this ->NoCaseExpression (i. c_str () );
966
+ libext += this ->NoCaseExpression (i);
966
967
#else
967
968
libext += i;
968
969
#endif
@@ -980,21 +981,19 @@ std::string cmComputeLinkInformation::CreateExtensionRegex(
980
981
return libext;
981
982
}
982
983
983
- std::string cmComputeLinkInformation::NoCaseExpression (const char * str)
984
+ std::string cmComputeLinkInformation::NoCaseExpression (std::string const & str)
984
985
{
985
986
std::string ret;
986
- ret.reserve (strlen (str) * 4 );
987
- const char * s = str;
988
- while (*s) {
989
- if (*s == ' .' ) {
990
- ret += *s;
987
+ ret.reserve (str.size () * 4 );
988
+ for (char c : str) {
989
+ if (c == ' .' ) {
990
+ ret += c;
991
991
} else {
992
992
ret += ' [' ;
993
- ret += static_cast <char >(tolower (*s ));
994
- ret += static_cast <char >(toupper (*s ));
993
+ ret += static_cast <char >(tolower (c ));
994
+ ret += static_cast <char >(toupper (c ));
995
995
ret += ' ]' ;
996
996
}
997
- s++;
998
997
}
999
998
return ret;
1000
999
}
@@ -1688,7 +1687,7 @@ void cmComputeLinkInformation::AddLibraryRuntimeInfo(
1688
1687
}
1689
1688
}
1690
1689
1691
- static void cmCLI_ExpandListUnique (const char * str,
1690
+ static void cmCLI_ExpandListUnique (std::string const & str,
1692
1691
std::vector<std::string>& out,
1693
1692
std::set<std::string>& emitted)
1694
1693
{
@@ -1735,15 +1734,15 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
1735
1734
if (use_install_rpath) {
1736
1735
std::string install_rpath;
1737
1736
this ->Target ->GetInstallRPATH (this ->Config , install_rpath);
1738
- cmCLI_ExpandListUnique (install_rpath. c_str () , runtimeDirs, emitted);
1737
+ cmCLI_ExpandListUnique (install_rpath, runtimeDirs, emitted);
1739
1738
}
1740
1739
if (use_build_rpath) {
1741
1740
// Add directories explicitly specified by user
1742
1741
std::string build_rpath;
1743
1742
if (this ->Target ->GetBuildRPATH (this ->Config , build_rpath)) {
1744
1743
// This will not resolve entries to use $ORIGIN, the user is expected to
1745
1744
// do that if necessary.
1746
- cmCLI_ExpandListUnique (build_rpath. c_str () , runtimeDirs, emitted);
1745
+ cmCLI_ExpandListUnique (build_rpath, runtimeDirs, emitted);
1747
1746
}
1748
1747
}
1749
1748
if (use_build_rpath || use_link_rpath) {
@@ -1823,16 +1822,16 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
1823
1822
" CMAKE_" + li + " _USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH" ;
1824
1823
if (this ->Makefile ->IsOn (useVar)) {
1825
1824
std::string dirVar = " CMAKE_" + li + " _IMPLICIT_LINK_DIRECTORIES" ;
1826
- if (const char * dirs = this ->Makefile ->GetDefinition (dirVar)) {
1827
- cmCLI_ExpandListUnique (dirs, runtimeDirs, emitted);
1825
+ if (cmProp dirs = this ->Makefile ->GetDef (dirVar)) {
1826
+ cmCLI_ExpandListUnique (* dirs, runtimeDirs, emitted);
1828
1827
}
1829
1828
}
1830
1829
}
1831
1830
}
1832
1831
1833
1832
// Add runtime paths required by the platform to always be
1834
1833
// present. This is done even when skipping rpath support.
1835
- cmCLI_ExpandListUnique (this ->RuntimeAlways . c_str () , runtimeDirs, emitted);
1834
+ cmCLI_ExpandListUnique (this ->RuntimeAlways , runtimeDirs, emitted);
1836
1835
}
1837
1836
1838
1837
std::string cmComputeLinkInformation::GetRPathString (bool for_install) const
0 commit comments