summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-01-17 15:00:19 (GMT)
committerBrad King <brad.king@kitware.com>2008-01-17 15:00:19 (GMT)
commit18b9e7db6c84bfe3936d33e7c7ca86a544f3e818 (patch)
treea24be738857d8de87efdba3ebae30a7795d54016
parent81af53e3c0b00005d2cf81a4a5482474573dd4b1 (diff)
downloadCMake-18b9e7db6c84bfe3936d33e7c7ca86a544f3e818.zip
CMake-18b9e7db6c84bfe3936d33e7c7ca86a544f3e818.tar.gz
CMake-18b9e7db6c84bfe3936d33e7c7ca86a544f3e818.tar.bz2
ENH: Enable CMAKE_<lang>_DEFINE_FLAG for COMPILE_DEFINITIONS property implementation.
-rw-r--r--Modules/Platform/xlf.cmake2
-rw-r--r--Source/cmLocalGenerator.cxx27
-rw-r--r--Source/cmLocalGenerator.h3
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx50
-rw-r--r--Source/cmMakefileTargetGenerator.cxx8
5 files changed, 51 insertions, 39 deletions
diff --git a/Modules/Platform/xlf.cmake b/Modules/Platform/xlf.cmake
index 4939e6c..adf146f 100644
--- a/Modules/Platform/xlf.cmake
+++ b/Modules/Platform/xlf.cmake
@@ -1 +1 @@
-set(CMAKE_DEFINE_FLAG_Fortran "-WF,-D")
+set(CMAKE_Fortran_DEFINE_FLAG "-WF,-D")
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 636ee8d..c788842 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1202,8 +1202,9 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang)
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::AppendFlags(std::string& flags,
//----------------------------------------------------------------------------
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 @@ void cmLocalGenerator::AppendDefines(std::string& defines,
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 @@ void cmLocalGenerator::AppendDefines(std::string& defines,
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 @@ void cmLocalGenerator::AppendDefines(std::string& defines,
// Make the definition appear properly on the command line.
defines += this->EscapeForShell(di->c_str(), true);
}
- dsep = " -D";
}
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 23458c9..ce0d0d6 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -143,7 +143,8 @@ public:
* 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
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 9465275..a79f8a7 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -413,42 +413,42 @@ void cmLocalVisualStudio6Generator
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 @@ void cmLocalVisualStudio6Generator
}
// 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
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index e529ef7..ce1442f 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -267,12 +267,12 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
// 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 @@ cmMakefileTargetGenerator
// 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 @@ cmMakefileTargetGenerator
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