[cmake-commits] king committed cmDependsFortran.cxx 1.44 1.45
cmLocalGenerator.cxx 1.254 1.255 cmLocalGenerator.h 1.97 1.98
cmLocalUnixMakefileGenerator3.cxx 1.232 1.233
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Jan 17 19:58:03 EST 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv4852/Source
Modified Files:
cmDependsFortran.cxx cmLocalGenerator.cxx cmLocalGenerator.h
cmLocalUnixMakefileGenerator3.cxx
Log Message:
ENH: Enable use of COMPILE_DEFINITIONS property for Fortran sources.
Index: cmDependsFortran.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDependsFortran.cxx,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- cmDependsFortran.cxx 10 Jan 2008 14:46:04 -0000 1.44
+++ cmDependsFortran.cxx 18 Jan 2008 00:58:01 -0000 1.45
@@ -142,27 +142,18 @@
IncludePath(&includes),
Internal(new cmDependsFortranInternals)
{
- // translate i.e. -DFOO=BAR to FOO and add it to the list of defined
+ // translate i.e. FOO=BAR to FOO and add it to the list of defined
// preprocessor symbols
- std::string def;
for(std::vector<std::string>::const_iterator
it = definitions.begin(); it != definitions.end(); ++it)
{
- std::string::size_type match = it->find("-D");
- if(match != std::string::npos)
+ std::string def = *it;
+ std::string::size_type assignment = def.find("=");
+ if(assignment != std::string::npos)
{
- std::string::size_type assignment = it->find("=");
- if(assignment != std::string::npos)
- {
- std::string::size_type length = assignment - (match+2);
- def = it->substr(match+2, length);
- }
- else
- {
- def = it->substr(match+2);
- }
- this->PPDefinitions.push_back(def);
+ def = it->substr(0, assignment);
}
+ this->PPDefinitions.push_back(def);
}
}
Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.254
retrieving revision 1.255
diff -u -d -r1.254 -r1.255
--- cmLocalGenerator.cxx 18 Jan 2008 00:29:43 -0000 1.254
+++ cmLocalGenerator.cxx 18 Jan 2008 00:58:01 -0000 1.255
@@ -2948,6 +2948,38 @@
}
//----------------------------------------------------------------------------
+std::string cmLocalGenerator::EscapeForCMake(const char* str)
+{
+ // Always double-quote the argument to take care of most escapes.
+ std::string result = "\"";
+ for(const char* c = str; *c; ++c)
+ {
+ if(*c == '"')
+ {
+ // Escape the double quote to avoid ending the argument.
+ result += "\\\"";
+ }
+ else if(*c == '$')
+ {
+ // Escape the dollar to avoid expanding variables.
+ result += "\\$";
+ }
+ else if(*c == '\\')
+ {
+ // Escape the backslash to avoid other escapes.
+ result += "\\\\";
+ }
+ else
+ {
+ // Other characters will be parsed correctly.
+ result += *c;
+ }
+ }
+ result += "\"";
+ return result;
+}
+
+//----------------------------------------------------------------------------
std::string
cmLocalGenerator::GetTargetDirectory(cmTarget const&) const
{
Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- cmLocalGenerator.h 18 Jan 2008 00:29:43 -0000 1.97
+++ cmLocalGenerator.h 18 Jan 2008 00:58:01 -0000 1.98
@@ -227,7 +227,10 @@
/** Backwards-compatibility version of EscapeForShell. */
std::string EscapeForShellOldStyle(const char* str);
-
+
+ /** Escape the given string as an argument in a CMake script. */
+ std::string EscapeForCMake(const char* str);
+
/** Return the directories into which object files will be put.
* There maybe more than one for fat binary systems like OSX.
*/
Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.232
retrieving revision 1.233
diff -u -d -r1.232 -r1.233
--- cmLocalUnixMakefileGenerator3.cxx 14 Jan 2008 14:20:57 -0000 1.232
+++ cmLocalUnixMakefileGenerator3.cxx 18 Jan 2008 00:58:01 -0000 1.233
@@ -1478,7 +1478,8 @@
else if(lang == "Fortran")
{
std::vector<std::string> defines;
- if(const char* c_defines = mf->GetDefinition("CMAKE_DEFINITIONS"))
+ if(const char* c_defines =
+ mf->GetDefinition("CMAKE_TARGET_DEFINITIONS"))
{
cmSystemTools::ExpandListArgument(c_defines, defines);
}
@@ -1844,13 +1845,43 @@
}
}
- cmakefileStream
- << "\n"
- << "# Preprocessor definitions for this directory.\n"
- << "SET(CMAKE_DEFINITIONS\n"
- << " " << this->Makefile->GetDefineFlags() << "\n"
- << " )\n";
-
+ // Build a list of preprocessor definitions for the target.
+ std::vector<std::string> defines;
+ {
+ std::string defPropName = "COMPILE_DEFINITIONS_";
+ defPropName += this->ConfigurationName;
+ if(const char* ddefs = this->Makefile->GetProperty("COMPILE_DEFINITIONS"))
+ {
+ cmSystemTools::ExpandListArgument(ddefs, defines);
+ }
+ if(const char* cdefs = target.GetProperty("COMPILE_DEFINITIONS"))
+ {
+ cmSystemTools::ExpandListArgument(cdefs, defines);
+ }
+ if(const char* dcdefs = this->Makefile->GetProperty(defPropName.c_str()))
+ {
+ cmSystemTools::ExpandListArgument(dcdefs, defines);
+ }
+ if(const char* ccdefs = target.GetProperty(defPropName.c_str()))
+ {
+ cmSystemTools::ExpandListArgument(ccdefs, defines);
+ }
+ }
+ if(!defines.empty())
+ {
+ cmakefileStream
+ << "\n"
+ << "# Preprocessor definitions for this target.\n"
+ << "SET(CMAKE_TARGET_DEFINITIONS\n";
+ for(std::vector<std::string>::const_iterator di = defines.begin();
+ di != defines.end(); ++di)
+ {
+ cmakefileStream
+ << " " << this->EscapeForCMake(di->c_str()) << "\n";
+ }
+ cmakefileStream
+ << " )\n";
+ }
}
//----------------------------------------------------------------------------
More information about the Cmake-commits
mailing list