Not sure how you're setting the LDFLAGS, but if you append -fPIE -pie to this variable, it should be used only for executables.<br><br><a href="http://cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_EXE_LINKER_FLAGS">http://cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_EXE_LINKER_FLAGS</a><br>
<br>There is an undocumented peer to this variable, something like CMAKE_LIBRARY_LINKER_FLAGS, (search the mailing list archives - someone replied to a message from me within the last month and named that variable) which you may consider modifying through a search/replace to remove -fPIE and -pie.<br>
<br>Ryan<br><br><div class="gmail_quote">On Thu, Sep 9, 2010 at 6:58 AM, Emil Langrock <span dir="ltr"><<a href="mailto:emil.langrock@gmx.de">emil.langrock@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
<br>
I have a project which builds shared objects and executables on linux. The<br>
goal is to have the library as PIC and the executable as PIE. PIC seems not a<br>
problem as cmake already does it.<br>
<br>
There exist a blacklist for architectures which doesn't support PIE well yet<br>
(hppa, m68k, mips, mipsel, avr32). This list is managed by the distribution<br>
and thus the distribution gives the pie information via C(XX|PP)FLAGS to<br>
cmake.<br>
<br>
In case of a platform with pie support, we would have following flags set:<br>
<br>
CFLAGS := -fPIE<br>
LDFLAGS := -fPIE -pie<br>
<br>
<br>
The problem is now that the library cannot have the LDFLAGS -fPIE -pie and<br>
CFLAGS -fPIE set as it is a PIC and not a PIE.<br>
<br>
As result cmake does something like (a little bit simplified):<br>
$ echo 'void test(void) {} void bla(void) { test(); }' > test.c<br>
$ gcc -fPIE -pie -fPIC test.c -shared -o test.so<br>
/usr/bin/ld.bfd.real: /tmp/cc7oYMnf.o: relocation R_X86_64_PC32 against symbol<br>
`test' can not be used when making a shared object; recompile with -fPIC<br>
/usr/bin/ld.bfd.real: final link failed: Bad value<br>
collect2: ld returned 1 exit status<br>
<br>
My first tests with libtool (via autotools project) worked fine. The reason<br>
seems to be that libtool is intelligent enough detect that pie is not for<br>
shared objects and strips it for the compilation and linking process for them.<br>
<br>
So my question: How is a similar functionality with cmake possible?<br>
<br>
Example project is amarok.<br>
--<br>
Emil Langrock<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Ryan Pavlik<br>HCI Graduate Student<br>Virtual Reality Applications Center<br>Iowa State University<br><br><a href="mailto:rpavlik@iastate.edu">rpavlik@iastate.edu</a><br>
<a href="http://academic.cleardefinition.com">http://academic.cleardefinition.com</a><br>Internal VRAC/HCI Site: <a href="http://tinyurl.com/rpavlik">http://tinyurl.com/rpavlik</a><br>