On 5/5/2012 4:27 PM, Stephen Kelly wrote:
Ok. Then factoring out how it is set is the first step. Looking at the
output of 'git grep -i " \?pic\b"' and 'git grep -wi +Z', there are many
different ways of telling the compiler that we want this property. Most of
them are ancient unix which I can't test. Should I change those at all?

This issue is the subject of a TODO comment in my wip branch on this topic.

They all set the CMAKE_SHARED_LIBRARY_${lang}_FLAGS one way or
another.  AFAIK CMake platform files use that variable exclusively
for -fPIC or equivalent flag.  It is possible that projects set
the value to add their own flags though.  I also know there are
projects that *read* the variable to get the flag so it can be
used in a static library (working around the lack of the feature
you're adding).

I think the most compatible way to do this is:

(1) Define a new platform variable named specifically to hold this
flag, like CMAKE_${lang}_PIC_FLAG or something.

(2) Document the property as using that flag *and* suppressing
use of CMAKE_SHARED_LIBRARY_${lang}_FLAGS altogether.

(3) Leave the property undefined even for shared libs and let
the project set the property to get new behavior.

I'd love to add a policy to get new behavior by default in a
future version of CMake.  However, I don't know if we can add it
without creating a warning on every shared library in every project.
Perhaps instead it could switch off the minimum required version.
That's pretty subtle though.

https://gitorious.org/~steveire/cmake/steveires-cmake/commits/position-independent-targets

Good start.  I'd like to amend my suggested property name to be
"POSITION_INDEPENDENT_CODE".

How should this interact with OBJECT library support?  If I compile
a set of objects meant for use in an executable shouldn't they use
-fPIE instead of -fPIC?  CMake cannot know where $<TARGET_OBJECTS:...>
will be used when it compiles an object library.

-Brad
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to