[CMake] How to specify -fpic ?

Michael Hertling mhertling at online.de
Wed Sep 29 21:53:41 EDT 2010


On 09/29/2010 06:25 PM, David Aldrich wrote:
> Hi
> 
> My C++ code consists of an executable and several shared libraries.
> 
> With my CMake build files, I find that the executable fails to load the shared libraries ( the dlopen() call results in error 'undefined symbol...' ).
> 
> The software works fine under our production build system that uses manually coded makefiles.
> 
> I notice that the production system linker command invokes -fpic, while CMake uses -fPIC. I am wondering if that is the reason.
> 
> I set the compile flags with:
> 
> set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -Wall -m64" )
> 
> How can I replace -fPIC with -fpic in CMake please?

STRING(REGEX REPLACE "-fPIC" "-fpic" CMAKE_SHARED_LIBRARY_CXX_FLAGS
${CMAKE_SHARED_LIBRARY_CXX_FLAGS})

Is this option the only difference of the link commands? Do the compile
commands differ, too? Are there any options in the compile commands
which should also be present in the link commands but are missing?

Regards,

Michael


More information about the CMake mailing list