[CMake] -fPIC flag on object build for static lib targets?

Abe Stephens abe at sci.utah.edu
Tue Sep 26 19:06:01 EDT 2006


When I build object files for shared library targets cmake includes the 
position independent code flag (-fPIC). However when I build objects for 
static library targets the flag is omitted. I try to link the static lib 
to other objects in a shared library the linker chokes.

How can I explicitly add the -fPIC flag to this static library target? 
I've tried:

ADD_LIBRARY(MyStatic STATIC ... )
SET_TARGET_PROPERTIES( MyStatic PROPERTIES COMPILE_FLAGS -fPIC)

(There's a chance that this flag is being modified in another part of 
the project configuration, it's a big project, but I can't find it.)

Software versions:
CMake 2.2.2 and 2.4.3.
Intel Compiler 9.1.38 (64 bit)
Suse 10.0 on AMD.

Thanks--

Abe


More information about the CMake mailing list