We are catching errors in our CMake makefiles due to lack of -fPIC
. Her's one from a ci20 MIPS dev-board:
...
[ 92%] Built target cryptopp-object
Scanning dependencies of target cryptopp-shared
Scanning dependencies of target cryptopp-static
Linking CXX static library libcryptopp.a
Linking CXX shared library libcryptopp.so
/usr/bin/ld: CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o: relocation R_MIPS_HI16 against
`a local symbol' can not be used when making a shared object; recompile with -fPIC
CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
The project's policy is to us PIC everywhere except 32-bit x86 due to register pressures. That means x86_64, ARM-32, Aarch32, Aarch64, MIPS, MIPS64, UltraSparc, etc get PIC.
I believe the target processor is provided in CMAKE_SYSTEM_PROCESSOR
. The problem I am having is the docs don't tell me the values, so I can't figure out how to craft a "not 32-bit x86" test.
How do I detect 32-bit x86 processor in CMakeList.txt?
Even better, I would like to see a comprehensive list of processors that CMake sets CMAKE_SYSTEM_PROCESSOR
to. If anyone has the list, then it would be great to provide it.
CMAKE_POSITION_INDEPENDENT_CODE
. I'll get it added. – Janycejanyte