Browse Source

BUG: Add target-level COMPILE_FLAGS to the target not the individual source files. This simplifies the generated files and puts flags in a more logical order (VS6 works, VS7 needs more translation to work).

Brad King 20 years ago
parent
commit
7bdec94154

+ 12 - 9
Source/cmLocalVisualStudio6Generator.cxx

@@ -432,15 +432,11 @@ void cmLocalVisualStudio6Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
       (*sf)->GetCustomCommand();
       (*sf)->GetCustomCommand();
     std::string compileFlags;
     std::string compileFlags;
     std::vector<std::string> depends;
     std::vector<std::string> depends;
-    const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS");
-    if(cflags)
-      {
-      compileFlags = cflags;
-      }
-    if(target.GetProperty("COMPILE_FLAGS"))
+
+    // Add per-source file flags.
+    if(const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS"))
       {
       {
-      compileFlags += " ";
-      compileFlags += target.GetProperty("COMPILE_FLAGS");
+      compileFlags += cflags;
       }
       }
 
 
     const char* lang = 
     const char* lang = 
@@ -1246,7 +1242,14 @@ void cmLocalVisualStudio6Generator
       {
       {
       flags += " /D \"_MBCS\"";
       flags += " /D \"_MBCS\"";
       }
       }
-    
+
+    // Add per-target flags.
+    if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
+      {
+      flags += " ";
+      flags += targetFlags;
+      }
+
     // The template files have CXX FLAGS in them, that need to be replaced.
     // 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
     // There are not separate CXX and C template files, so we use the same
     // variable names.   The previous code sets up flags* variables to contain
     // variable names.   The previous code sets up flags* variables to contain

+ 8 - 6
Source/cmLocalVisualStudio7Generator.cxx

@@ -520,6 +520,13 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
     programDatabase += "\"";
     programDatabase += "\"";
     }
     }
 
 
+  // Add the target-specific flags.
+  if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
+    {
+    flags += " ";
+    flags += targetFlags;
+    }
+
   // The intermediate directory name consists of a directory for the
   // The intermediate directory name consists of a directory for the
   // target and a subdirectory for the configuration name.
   // target and a subdirectory for the configuration name.
   std::string intermediateDir = this->GetTargetDirectory(target);
   std::string intermediateDir = this->GetTargetDirectory(target);
@@ -1084,12 +1091,7 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
     std::string compileFlags;
     std::string compileFlags;
     std::string additionalDeps;
     std::string additionalDeps;
 
 
-    // Check for extra compiler flags.
-    if(target.GetProperty("COMPILE_FLAGS"))
-      {
-      compileFlags += " ";
-      compileFlags += target.GetProperty("COMPILE_FLAGS");
-      }
+    // Add per-source flags.
     const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS");
     const char* cflags = (*sf)->GetProperty("COMPILE_FLAGS");
     if(cflags)
     if(cflags)
       {
       {