CMake doesn't respect compiler flags for CrayLinuxEnvironment
On Cray Linux Environment you can specify whether to use dynamic linking libraries or not through the CRAYPE_LINK_TYPE
environment variable. Based on that variable CMake performs static/shared linking of the library target, which is completely fine. But when setting CRAYPE_LINK_TYPE=dynamic
, CMake doesn't add -fPIC
to compiler options, thus linker fails to create shared library:
/opt/cray/pe/cce/8.5.5/cray-binutils/x86_64-pc-linux-gnu/bin/ld: relocation R_X86_64_32S against .data can not be used when making a shared object; recompile with -fPIC
If I manually add -fPIC
flag through the CMAKE_C_FLAGS
variable it compiles fine.