CrayPrgEnv incorrectly sets CMAKE_SHARED_LIBRARY_LINK_<lang>_FLAGS to -dynamic
From Modules/Compiler/CrayPrgEnv.cmake:118-121
:
# Flags for the Cray wrappers
set(CMAKE_STATIC_LIBRARY_LINK_${lang}_FLAGS "-static")
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared")
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-dynamic")
The purpose of CMAKE_SHARED_LIBRARY_LINK_<lang>_FLAGS
is to create executables that export symbols, rather than to import symbols from a shared library. However, the -dynamic
flag on the Cray compiler wrapper does the latter. This can result in executables incorrectly linking against shared libraries when static libraries are desired, especially if CMP0065
is set to OLD
or WARN
.
As an aside, CMAKE_STATIC_LIBRARY_LINK_<lang>_FLAGS
does not appear anywhere else in CMake, and can probably be removed.