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

Brad King brad.king at kitware.com
Wed May 30 11:23:38 EDT 2012


On Wed, May 30, 2012 at 6:20 AM, Stephen Kelly <steveire at gmail.com> wrote:
> RISCos.cmake and ULTRIX.cmake contains '-G 0' and HP-UX-HP.cmake contains
> +Z. I don't know what they are really for.

HP's "+Z" option is for PIC:

 http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/Online_Help/libs.htm#shlibcomp

so this can be subsumed into CMAKE_C_COMPILE_OPTIONS_PIC.

The RISCos and ULTRIX "-G <n>" option sets the small data/bss
cut-off for MIPS Gp-Relative Addressing:

 http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html#index-G-1738

I'm not familiar enough with that platform to know why "-G 0" is
needed for shared libraries.  I don't know if anyone actually uses
CMake on that platform though so we could just drop the flag when
the policy is set to NEW and wait for a contributor to address it.

In updating the documentation of the policy I think you misread
my "unspecified means to select" phrase.  I meant "a method that
is not specified" rather than "if the policy is not specified".
See below for new wording.

Commit 098cb871 adds trailing whitespace in "cmLocalGenerator.h".

In Windows-Embarcadero and Windows-wcl386 you misspelled the new
variable.  Use s/SHARED_LIBRARY/COMPILE_OPTIONS/ to fix it.

My comment about Fortran in CMakeCXXInformation meant that you
should update CMakeFortranInformation with the equivalent change
that you already made in CMakeCXXInformation.

The new AddSharedDllFlags can be replaced by a call to the
AppendFeatureOptions method with "DLL" as the last argument.
Also the call to it in the cmMakefileTargetGenerator does not
compile because "language" is not a variable in scope.

Thanks,
-Brad


CMake 2.8.8 and lower compiled sources in SHARED and MODULE libraries
using the value of the undocumented CMAKE_SHARED_LIBRARY_<Lang>_FLAGS
platform variable.  The variable contained platform-specific flags
needed to compile objects for shared libraries.  Typically it included
a flag such as -fPIC for position independent code but also included
other flags needed on certain platforms.  CMake 2.8.9 and higher
prefer instead to use the POSITION_INDEPENDENT_CODE target property to
determine what targets should be position independent, and new
undocumented platform variables to select flags while ignoring
CMAKE_SHARED_LIBRARY_<Lang>_FLAGS completely.

The default for either approach...



More information about the cmake-developers mailing list