[cmake-commits] king committed cmLocalGenerator.cxx 1.251 1.252
cmLocalGenerator.h 1.95 1.96 cmLocalVisualStudio6Generator.cxx
1.135 1.136 cmMakefileTargetGenerator.cxx 1.84 1.85
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Jan 17 10:00:21 EST 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv2123/Source
Modified Files:
cmLocalGenerator.cxx cmLocalGenerator.h
cmLocalVisualStudio6Generator.cxx
cmMakefileTargetGenerator.cxx
Log Message:
ENH: Enable CMAKE_<lang>_DEFINE_FLAG for COMPILE_DEFINITIONS property implementation.
Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.251
retrieving revision 1.252
diff -u -d -r1.251 -r1.252
--- cmLocalGenerator.cxx 14 Jan 2008 14:20:57 -0000 1.251
+++ cmLocalGenerator.cxx 17 Jan 2008 15:00:19 -0000 1.252
@@ -1202,8 +1202,9 @@
void cmLocalGenerator::FixDefineFlags(std::string& flags,
const char* lang)
{
- std::string defineFlagVar = "CMAKE_DEFINE_FLAG_";
+ std::string defineFlagVar = "CMAKE_";
defineFlagVar += lang;
+ defineFlagVar += "_DEFINE_FLAG";
std::string defineFlag =
this->Makefile->GetSafeDefinition(defineFlagVar.c_str());
if(defineFlag.size() == 0)
@@ -2219,7 +2220,8 @@
//----------------------------------------------------------------------------
void cmLocalGenerator::AppendDefines(std::string& defines,
- const char* defines_list)
+ const char* defines_list,
+ const char* lang)
{
// Short-circuit if there are no definitions.
if(!defines_list)
@@ -2237,14 +2239,22 @@
return;
}
- // Separate from previous definitions with a space.
- if(!defines.empty())
+ // Lookup the define flag for the current language.
+ std::string dflag = "-D";
+ if(lang)
{
- defines += " ";
+ std::string defineFlagVar = "CMAKE_";
+ defineFlagVar += lang;
+ defineFlagVar += "_DEFINE_FLAG";
+ const char* df = this->Makefile->GetDefinition(defineFlagVar.c_str());
+ if(df && *df)
+ {
+ dflag = df;
+ }
}
// Add each definition to the command line with appropriate escapes.
- const char* dsep = "-D";
+ const char* dsep = defines.empty()? "" : " ";
for(std::vector<std::string>::const_iterator di = defines_vec.begin();
di != defines_vec.end(); ++di)
{
@@ -2254,10 +2264,12 @@
continue;
}
- // Append the -D
+ // Separate from previous definitions.
defines += dsep;
+ dsep = " ";
// Append the definition with proper escaping.
+ defines += dflag;
if(this->WatcomWMake)
{
// The Watcom compiler does its own command line parsing instead
@@ -2284,7 +2296,6 @@
// Make the definition appear properly on the command line.
defines += this->EscapeForShell(di->c_str(), true);
}
- dsep = " -D";
}
}
Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- cmLocalGenerator.h 14 Jan 2008 14:20:57 -0000 1.95
+++ cmLocalGenerator.h 17 Jan 2008 15:00:19 -0000 1.96
@@ -143,7 +143,8 @@
* Encode a list of preprocessor definitions for the compiler
* command line.
*/
- void AppendDefines(std::string& defines, const char* defines_list);
+ void AppendDefines(std::string& defines, const char* defines_list,
+ const char* lang);
/** Translate a dependency as given in CMake code to the name to
appear in a generated build file. If the given name is that of
Index: cmLocalVisualStudio6Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio6Generator.cxx,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- cmLocalVisualStudio6Generator.cxx 16 Jan 2008 02:02:00 -0000 1.135
+++ cmLocalVisualStudio6Generator.cxx 17 Jan 2008 15:00:19 -0000 1.136
@@ -413,42 +413,42 @@
compileFlags += cflags;
}
+ const char* lang = this->GetSourceFileLanguage(*(*sf));
+ if(lang)
+ {
+ if(strcmp(lang, "CXX") == 0)
+ {
+ // force a C++ file type
+ compileFlags += " /TP ";
+ }
+ else if(strcmp(lang, "C") == 0)
+ {
+ // force to c file type
+ compileFlags += " /TC ";
+ }
+ }
+
// Add per-source and per-configuration preprocessor definitions.
std::map<cmStdString, cmStdString> cdmap;
this->AppendDefines(compileFlags,
- (*sf)->GetProperty("COMPILE_DEFINITIONS"));
+ (*sf)->GetProperty("COMPILE_DEFINITIONS"), lang);
if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_DEBUG"))
{
- this->AppendDefines(cdmap["DEBUG"], cdefs);
+ this->AppendDefines(cdmap["DEBUG"], cdefs, lang);
}
if(const char* cdefs = (*sf)->GetProperty("COMPILE_DEFINITIONS_RELEASE"))
{
- this->AppendDefines(cdmap["RELEASE"], cdefs);
+ this->AppendDefines(cdmap["RELEASE"], cdefs, lang);
}
if(const char* cdefs =
(*sf)->GetProperty("COMPILE_DEFINITIONS_MINSIZEREL"))
{
- this->AppendDefines(cdmap["MINSIZEREL"], cdefs);
+ this->AppendDefines(cdmap["MINSIZEREL"], cdefs, lang);
}
if(const char* cdefs =
(*sf)->GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO"))
{
- this->AppendDefines(cdmap["RELWITHDEBINFO"], cdefs);
- }
-
- const char* lang = this->GetSourceFileLanguage(*(*sf));
- if(lang)
- {
- if(strcmp(lang, "CXX") == 0)
- {
- // force a C++ file type
- compileFlags += " /TP ";
- }
- else if(strcmp(lang, "C") == 0)
- {
- // force to c file type
- compileFlags += " /TC ";
- }
+ this->AppendDefines(cdmap["RELWITHDEBINFO"], cdefs, lang);
}
bool excludedFromBuild =
@@ -1503,17 +1503,17 @@
}
// Add per-target and per-configuration preprocessor definitions.
- this->AppendDefines(flags, target.GetProperty("COMPILE_DEFINITIONS"));
+ this->AppendDefines(flags, target.GetProperty("COMPILE_DEFINITIONS"), 0);
this->AppendDefines(flagsDebug,
- target.GetProperty("COMPILE_DEFINITIONS_DEBUG"));
+ target.GetProperty("COMPILE_DEFINITIONS_DEBUG"), 0);
this->AppendDefines(flagsRelease,
- target.GetProperty("COMPILE_DEFINITIONS_RELEASE"));
+ target.GetProperty("COMPILE_DEFINITIONS_RELEASE"), 0);
this->AppendDefines
(flagsMinSize,
- target.GetProperty("COMPILE_DEFINITIONS_MINSIZEREL"));
+ target.GetProperty("COMPILE_DEFINITIONS_MINSIZEREL"), 0);
this->AppendDefines
(flagsDebugRel,
- target.GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO"));
+ target.GetProperty("COMPILE_DEFINITIONS_RELWITHDEBINFO"), 0);
// The template files have CXX FLAGS in them, that need to be replaced.
// There are not separate CXX and C template files, so we use the same
Index: cmMakefileTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileTargetGenerator.cxx,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- cmMakefileTargetGenerator.cxx 16 Jan 2008 02:02:00 -0000 1.84
+++ cmMakefileTargetGenerator.cxx 17 Jan 2008 15:00:19 -0000 1.85
@@ -267,12 +267,12 @@
// Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AppendDefines
- (defines, this->Target->GetProperty("COMPILE_DEFINITIONS"));
+ (defines, this->Target->GetProperty("COMPILE_DEFINITIONS"), lang);
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName +=
cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
this->LocalGenerator->AppendDefines
- (defines, this->Target->GetProperty(defPropName.c_str()));
+ (defines, this->Target->GetProperty(defPropName.c_str()), lang);
// Add language-specific flags.
this->LocalGenerator
@@ -456,7 +456,7 @@
// Add source-sepcific preprocessor definitions.
if(const char* compile_defs = source.GetProperty("COMPILE_DEFINITIONS"))
{
- this->LocalGenerator->AppendDefines(defines, compile_defs);
+ this->LocalGenerator->AppendDefines(defines, compile_defs, lang);
*this->FlagFileStream << "# Custom defines: "
<< relativeObj << "_DEFINES = "
<< compile_defs << "\n"
@@ -469,7 +469,7 @@
if(const char* config_compile_defs =
source.GetProperty(defPropName.c_str()))
{
- this->LocalGenerator->AppendDefines(defines, config_compile_defs);
+ this->LocalGenerator->AppendDefines(defines, config_compile_defs, lang);
*this->FlagFileStream
<< "# Custom defines: "
<< relativeObj << "_DEFINES_" << configUpper
More information about the Cmake-commits
mailing list