[CMake] Accepted way to add "-fPIC" onto CMAKE_CXX_FLAGS?
Stephen Kelly
steveire at gmail.com
Tue Jun 19 03:10:23 EDT 2012
Michael Jackson wrote:
> Linux really wants to have -fPIC for some of my code and I am trying to
> detect linux and then add this flag for my project but I am having no
> luck.
>
> if (LINUX)
> set(CMAKE_CXX_FLAGS ${CMAKE_CSS_FLAGS} "-fPIC")
> endif()
>
> Is this NOT the way I should be doing this? It doesn't really "fell"
> correct but nothing else (including this) seems to work.
>
> Help?
In (upcoming) CMake 2.8.9 you can set the POSITION_INDEPENDENT_CODE property
on a target, or you can set the global variable
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
to make all following targets position independent.
Thanks,
Steve.
More information about the CMake
mailing list