title: Getting Error recompile with -fPIC although POSITION_INDEPENDENT_CODE flag is enabled
body: <p>I am trying to link afinit_state.a library with my C++ project through cmake. But I am getting bolow attached error. My cmake file is:</p>
  <pre><code>cmake_minimum_required(VERSION 3.12)
  
  project(java_telemetry_wrapper)
  
  set(CMAKE_CXX_STANDARD 14)
  
  find_package(JNI)
  set(JAVA_INCLUDE_PATH &quot;$ENV{JAVA_HOME}/include&quot;)
  find_path(JAVA_INCLUDE_PATH jni.h ${JAVA_AWT_INCLUDE_DIRECTORIES})
  
  set(JNI_LIBRARIES ${JAVA_AWT_LIBRARY} ${JAVA_JVM_LIBRARY})
  set(JNI_INCLUDE_DIRS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2} ${JAVA_AWT_INCLUDE_PATH})
  set(STATE_PATH &quot;/home/poc/src/state/&quot;)
  set(LOGGER_PATH &quot;../../logger&quot;)
  
  include_directories(${JNI_INCLUDE_DIRS} ${STATE_PATH} ${LOGGER_PATH} ${AFN_STATE_INC} ${AFN_LOGGER_INC})
  link_directories(/opt/lib/)
  
  add_library(${PROJECT_NAME} SHARED header/TelemetryWrapper.h src/TelemetryWrapper.cpp ../telemetry.h ../telemetry.cpp ../common.hpp)
  set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
  target_link_libraries(${PROJECT_NAME} &quot;-lpthread&quot; afinit_state &quot;-lz&quot;)
  </code></pre>
  <p>I have tried my options which I could find on internet before posting this question. Alot of people are saying use <strong>set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)</strong> which I did but error is still persisting. Please help me to narrow down the issue, what is causing this problem.</p>
  <pre><code>/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt//lib/libafinit_state.a(af_state_service.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
      /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt//lib/libafinit_state.a(StateSvcMsgQ.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
      /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt//lib/libafinit_state.a(StateSvcShmCtl2.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
      /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt//lib/libafinit_state.a(StateSvcShmCtl.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
      /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt//lib/libafinit_state.a(af_ss_agent_store.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
      /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt//lib/libafinit_state.a(af_ss_call_store.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
      /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt//lib/libafinit_state.a(af_ss_hashed_tbl.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
      /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt//lib/libafinit_state.a(af_ss_mega_store.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
      /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt//lib/libafinit_state.a(StateSvcMQ_Msgs.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
      /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: /opt//lib/libafinit_state.a(StateSvcObjDefs.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
      /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: final link failed: Nonrepresentable section on output
      collect2: error: ld returned 1 exit status
      make[2]: *** [CMakeFiles/java_telemetry_wrapper.dir/build.make:99: libjava_telemetry_wrapper.so] Error 1
      make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/java_telemetry_wrapper.dir/all] Error 2
      make: *** [Makefile:84: all] Error 2
  </code></pre>