[cmake-developers] Adding logic to CMake for -fPIE and -fPIC

Brad King brad.king at kitware.com
Thu May 31 08:37:50 EDT 2012


On 05/31/2012 05:30 AM, Stephen Kelly wrote:
> I see cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand gave me the wrong 
> idea I think.

I never noticed that one, thanks.

>> and similarly in Ninja.  The "} else {" construct is not consistent
>> with style in the rest of our code.
> 
> Both fixed.

See the patch below for what I meant.

> Another change in my newest push is that I've moved the storage of the 
> shared library flags from inside the 
> 
>  } // end if in try compile
> 
> to inside the 
> 
>  } // end for each language
> 
> I noticed when running the unit tests that I was getting the policy warning 
> otherwise because the flags were not actually being stored.

Good catch.

Thanks,
-Brad


diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index a071a2a..451283b 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -265,7 +265,9 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l)
     if (this->LocalGenerator->GetShouldUseOldFlags(shared, l))
       {
       this->LocalGenerator->AddSharedFlags(flags, lang, shared);
-    } else {
+      }
+    else
+      {
       // Add position independendent flags, if needed.
       if (this->Target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE"))
         {
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index edd17f7..2191422 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -149,7 +149,9 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
   if (this->LocalGenerator->GetShouldUseOldFlags(shared, language))
     {
     this->LocalGenerator->AddSharedFlags(flags, language.c_str(), shared);
-  } else {
+    }
+  else
+    {
     if (this->Target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE"))
       {
       // Add position independendent flags, if needed.





More information about the cmake-developers mailing list