CMake: position independent code on Windows?
Currently the flag -fPIC is being set like this:
if(UNIX OR APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
endif()
CMake has a property for this: POSITION_INDEPENDENT_CODE which can be set globally like this:
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
However, this begs the question: is there a reason Windows does not need PIC enabled?
On Windows position independent code is not used, i.e. compilers do not generate position independent code.
DLL: dynamic linking lib: means upon first load of the DLL, the actual memory addresses are computed and resolved by the "dynamic" linker. The actual "positions" are then "patched in" the code...
I think on Win set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) is simply NOP for CMake...
See e.g. this old thread.
On Windows position independent code is not used, i.e. compilers do not generate position independent code. DLL: dynamic linking lib: means upon first load of the DLL, the actual memory addresses are computed and resolved by the "dynamic" linker. The actual "positions" are then "patched in" the code... I think on Win
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)is simply NOP for CMake...See e.g. this old thread.
This is false.