MCPcopy Create free account
hub / github.com/Kitware/CMake / JoinDefines

Method JoinDefines

Source/cmLocalGenerator.cxx:3918–3966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3916}
3917
3918void cmLocalGenerator::JoinDefines(std::set<std::string> const& defines,
3919 std::string& definesString,
3920 std::string const& lang)
3921{
3922 // Lookup the define flag for the current language.
3923 std::string dflag = "-D";
3924 if (!lang.empty()) {
3925 cmValue df =
3926 this->Makefile->GetDefinition(cmStrCat("CMAKE_", lang, "_DEFINE_FLAG"));
3927 if (cmNonempty(df)) {
3928 dflag = *df;
3929 }
3930 }
3931 char const* itemSeparator = definesString.empty() ? "" : " ";
3932 for (std::string const& define : defines) {
3933 // Append the definition with proper escaping.
3934 std::string def = dflag;
3935 if (this->GetState()->UseWatcomWMake()) {
3936 // The Watcom compiler does its own command line parsing instead
3937 // of using the windows shell rules. Definitions are one of
3938 // -DNAME
3939 // -DNAME=<cpp-token>
3940 // -DNAME="c-string with spaces and other characters(?@#$)"
3941 //
3942 // Watcom will properly parse each of these cases from the
3943 // command line without any escapes. However we still have to
3944 // get the '$' and '#' characters through WMake as '$$' and
3945 // '$#'.
3946 for (char c : define) {
3947 if (c == '$' || c == '#') {
3948 def += '$';
3949 }
3950 def += c;
3951 }
3952 } else {
3953 // Make the definition appear properly on the command line. Use
3954 // -DNAME="value" instead of -D"NAME=value" for historical reasons.
3955 std::string::size_type eq = define.find('=');
3956 def += define.substr(0, eq);
3957 if (eq != std::string::npos) {
3958 def += "=";
3959 def += this->EscapeForShell(define.substr(eq + 1), true);
3960 }
3961 }
3962 definesString += itemSeparator;
3963 itemSeparator = " ";
3964 definesString += def;
3965 }
3966}
3967
3968void cmLocalGenerator::AppendFeatureOptions(std::string& flags,
3969 std::string const& lang,

Callers 8

CreateBuildSettingsMethod · 0.80
WriteObjectRuleFilesMethod · 0.80
ComputeDefinesMethod · 0.80
ComputeDefinesMethod · 0.80
GetDefinesMethod · 0.80
GetDefinesMethod · 0.80
ComputeDefinesMethod · 0.80

Calls 9

GetStateMethod · 0.95
cmNonemptyFunction · 0.85
UseWatcomWMakeMethod · 0.80
EscapeForShellMethod · 0.80
cmStrCatFunction · 0.70
emptyMethod · 0.45
GetDefinitionMethod · 0.45
findMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected