I am new to CMake, and have a (legacy) package with a C main program that links (interdependent) C and Fortran libraries. The main program source is in the top-level directory, the C library source is in a sub-directory of the top-level directory, and the Fortran library source is in another (peer) sub-directory. Oversimplified, it looks like:
+-- main.c
+-- mmf
| +-- (C source)
+-- prms
+-- (Fortran source)
I have one CMakeLists.txt
file in each directory, for a total of three. They are here, here, and here.
Everything appears to work well until the final linking stage, when:
[100%] Linking C executable PRMS
/usr/bin/ld: prms/libprms.a(ccsolrad.f90.o): in function `ccsolrad_':
ccsolrad.f90:(.text+0xbe0): undefined reference to `declvar_'
/usr/bin/ld: ccsolrad.f90:(.text+0xc4b): undefined reference to `declvar_'
/usr/bin/ld: ccsolrad.f90:(.text+0xe1d): undefined reference to `declvar_'
/usr/bin/ld: ccsolrad.f90:(.text+0xe88): undefined reference to `declvar_'
which is some Fortran code in the Fortran library attempting to link with a Fortran-to-C adapter function in the C library.
Would anyone have ideas on how to do this correctly?
Thanks very much!