4

I have a C++ project in CMake (32-bit shared library) and gcc compiler. I set POSITION_INDEPENDENT_CODE property to OFF for my project, so it removes -fPIC only for source compiling, but not for link stage too. How can I disable it for link?

I know there is a way with -fno-PIC in LINK_FLAGS. And also also I can set CMAKE_SHARED_LIBRARY_CXX_FLAGS to "". But these ways looks dirty.

Artem
  • 91
  • 8
  • Linker itself has no option controlling "pic": all such options are passed to it from the compiler. So, if your compiler flags do not contain `-fPIC`, linker flags shouldn't contain this option too... Unless someone specified `-fPIC` **directly** for linker, which is wrong approach. Could you provide an example demonstating your problem (as a [mcve])? – Tsyvarev Jul 24 '17 at 07:31
  • @Tsyvarev [CMakeLists.txt](https://gist.github.com/WPMGPRoSToTeMa/241ef49b9c868f2d21bd6a88ab3c8c56) – Artem Jul 24 '17 at 10:44

0 Answers0