The CMAKE_SHARED_LIBRARY_LINK_<LANG>_FLAGS setting has always been meant
for flags needed to export symbols from executables for use by shared
library plugins. Since commit v3.4.0-rc1~58^2~1 (CMP0065: Restrict the
use of CMAKE_SHARED_LIBRARY_LINK_<LANG>_FLAGS, 2015-08-24) this is made
explicit by using the flags only for executables with ENABLE_EXPORTS,
guarded by CMP0065 for compatibility.
On some platforms we were accidentally using this setting to pass other
flags to the linker:
* AIX: -bnoipath, -brtl
* HP-UX: +s, +nodefaultrpath
These flags are incorrectly dropped when CMP0065 is set to NEW. Fix
this by moving the flags to more appropriate places for linking
executables.
Store in new platform variables
CMAKE_${lang}_COMPILE_OPTIONS_PIC
CMAKE_${lang}_COMPILE_OPTIONS_PIE
flags for position independent code generation.
In almost all cases, this means duplication of the
CMAKE_SHARED_LIBRARY_${lang}_FLAGS for the _PIC case and using the
assumed pie equivalent for the _PIE case. Note that the GNU compiler
has supported -fPIE since 3.4 and that there is no -fPIC on GNU for
Windows or Cygwin.
There is a possibility that the _PIE variables are not correct.
However, as there is no backwards compatibility to be concerned about
(as the POSITION_INDEPENDENT_CODE property is not used anywhere yet),
the current state suffices.
Previously we linked C, Fortran, and ASM shared libraries compiled with
the HP compiler using a direct invocation of the linker (ld). This
behavior was left historically from support for an ancient HP C compiler
that did not know how to create shared libraries. Fortran shared
libraries need to be linked with the compiler to get the language
runtime library dependencies as is already done for C++.
Update the HP-UX-HP* platform information to use the compiler front end
when linking shared libraries. This works on modern HP tools and
produces correct behavior. If there is a need to support older tools
again we can add a special case for them.
Move HP flags out of Platform/HP-UX.cmake into platform-specific
compiler information files "Platform/HP-UX-HP-<lang>.cmake". Factor
common values into "Platform/HP-UX-HP.cmake" and load it from the
per-language files.