<html><body>
<p><font size="2" face="sans-serif">I am attempting to build an application that uses cmake, but encountered an issue that is present in the most recent cmake versions.  The system is Linux, and the problem occurs with a FortranCInterface test, when the Fortran compiler is IBM XL Fortran (the problem does not arise with gfortran).  The project's CMakeLists.txt file contains :</font><br>
<br>
<font size="2" face="sans-serif">include(FortranCInterface)</font><br>
<font size="2" face="sans-serif">...</font><br>
<font size="2" face="sans-serif">FortranCInterface_VERIFY(CXX)</font><br>
<font size="2" face="sans-serif">...</font><br>
<br>
<font size="2" face="sans-serif">With the XL Fortran compiler, the command that fails is :</font><br>
<br>
<font size="2" face="sans-serif">/opt/ibmcmp/xlf/15.1.1/bin/xlf90_r CMakeFiles/FortranCInterface.dir/main.F.o CMakeFiles/FortranCInterface.dir/call_sub.f.o CMakeFiles/FortranCInterface.dir/call_mod.f90.o  -o FortranCInterface -rdynamic libsymbols.a libmyfort.a</font><br>
<font size="2" face="sans-serif">***/opt/ibm/xlf/15.1.1/bin/.orig/xlf90_r: 1501-210 (S) command option ynamic contains an incorrect subargument***</font><br>
<br>
<font size="2" face="sans-serif">The "-rdynamic" option is added by the cmake infrastructure via the file " Modules/Platform/Linux-GNU.cmake ", which contains :</font><br>
<br>
<font size="2" face="sans-serif">set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")</font><br>
<br>
<font size="2" face="sans-serif">I think it would be preferable to replace "-rdynamic" with "-Wl,-export-dynamic" as follows:</font><br>
<br>
<font size="2" face="sans-serif">set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-export-dynamic")</font><br>
<br>
<font size="2" face="sans-serif">in the Linux-GNU.cmake file that is provided by cmake.</font><br>
<br>
<font size="2" face="sans-serif">I should mention that the system is Linux and that GNU compilers are used for C and C++.  The problem is that the cmake infrastructure adds the "-rdynamic" option when the XL Fortran compiler script is used as the linker during the FortranCInterface test, but "-rdynamic" is an option that is specific to the GNU compiler set, and the "-r" conflicts with an XL Fortran compiler option, resulting in a linking failure.  However, "-rdynamic" is fully equivalent to "-Wl,-export-dynamic", which explicitly passes the correct option to the GNU ld command (this is Linux), avoiding any such conflicts.  </font><br>
<br>
<font size="2" face="sans-serif">I tried some other approaches including adding lines like these to the project's CMakeLists.txt file, without success :</font><br>
<br>
<font size="2" face="sans-serif">set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Wl,-export-dynamic")</font><br>
<font size="2" face="sans-serif">set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-export-dynamic")</font><br>
<font size="2" face="sans-serif">set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-Wl,-export-dynamic")</font><br>
<br>
<font size="2" face="sans-serif">The "-rdynamic" option listed in the Linux-GNU.cmake file still got into the linking script and caused linking to fail.  The only way that I found to work around the problem was to edit the Linux-GNU.cmake file in the cmake install path and replace "-rdynamic" with "-Wl.-export-dynamic", as indicated above.  I believe that replacing "-rdynamic" with "-Wl,-export-dynamic" is generally valid on Linux systems, and is clearly preferable.  If there are other ways to address this issue, I would like to learn about them.</font><br>
</body></html>