Hello. I am compiling on linux host using clang-12 and CMAKE_SYSTEM_NAME Windows-Clang
in my toolchain file. I have studied the Modules/Platform/Windows-Clang.cmake which makes a decission on choosing msvc/gnu variant basing on CMAKE_C_SIMULATE_ID
and CMAKE_CXX_SIMULATE_ID
variables. Setting them to “MSVC” makes the static libs and executables build succefully EXCEPT for dlls, with error
clang-12: unsupported option '-fPIC' for target i386-pc-windows-msvc
But the thing is this flag is not being set anywhere… there even are comments in the Windows toolchains:
Windows-Clang.cmake:37: # No -fPIC on Windows
Windows-GNU.cmake:68: # No -fPIC on Windows
So where does this -fPIC come from??
For now it is enough to sed
after cmake project files generation to remove this flag from compile line and entire projects builds and runs.