Alan W. Irwin wrote:
On 2006-09-26 17:06-0600 Abe Stephens wrote:
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.
Could you clarify your goal here?
Hopefully ;-)
Are you trying to link a static library build by CMake with a shared library
built by CMake?  I haven't tried that, but I assume it would work just as
well as the link of static library built by CMake to an external library.
I think this is closest to what I am trying to do.
In sum, I don't think there is any case where you have to explicitly specify
-fPIC. CMake takes care of that for you.
I understand that in general static libs don't need to be compiled with -fPIC since they're supposed to be linked with executables. In my case they will eventually linked when I build a certain shared library. It might make better sense to just package this code as a shared library, but for the moment if I could figure out how SET_TARGET_PROPERTIES I think I'd be in good shape.

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

Thanks--

Abe


_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to