I have an odd situation that I’m struggling with the CMake for. I work on a big Fortran source code that now has a need to build a shared object library and include file where they are created by Python and not by Fortran. We have a “main” library (made by Fortran) here which works just fine, called libFVdycoreCubed_GridComp.a
(or .so, I suppose, but static for now). It’s this “extra” library that’s getting me.
Now, I can build the library at the moment with some horribly ugly CMake that creates an INTERFACE
library (not sure if that’s what I should do?) and all seems to build. The library is made, all the executables that need it are satisifed, etc.
Now, at the end of my install
step, I see the library in the build
directory (aka CMAKE_CURRENT_BINARY_DIR
for this file):
$ ls -l src/Components/@GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSsuperdyn_GridComp/@FVdycoreCubed_GridComp/
total 610
drwxr-xr-x 4 mathomp4 g0620 512 Jan 24 13:53 @fvdycore/
drwxr-xr-x 10 mathomp4 g0620 8192 Jan 24 13:53 CMakeFiles/
-rw-r--r-- 1 mathomp4 g0620 581 Jan 24 12:26 CTestTestfile.cmake
-rw-r--r-- 1 mathomp4 g0620 70632 Jan 24 13:53 Makefile
-rw-r--r-- 1 mathomp4 g0620 13425 Jan 24 13:53 cmake_install.cmake
-rw-r--r-- 1 mathomp4 g0620 72548 Jan 24 13:54 fv_dynamics_interface_py.c
-rw-r--r-- 1 mathomp4 g0620 2236 Jan 24 13:53 fv_dynamics_interface_py.h
-rw-r--r-- 1 mathomp4 g0620 60104 Jan 24 13:54 fv_dynamics_interface_py.o
-rwxr-xr-x 1 mathomp4 g0620 54096 Jan 24 13:54 libfv_dynamics_interface_py.so*
drwxr-xr-x 3 mathomp4 g0620 512 Jan 24 13:53 scripts/
But I have one last thing I can’t figure out. I want/need this libfv_dynamics_interface_py.so
file to end up in install/lib
and I can’t seem to get it there. For example, I’ve tried:
install(TARGETS fv_dynamics_interface_py
EXPORT ${PROJECT_NAME}-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)
but I’m guessing install
doesn’t really see it as an “actual” library. Okay, I also tried adding an explicit:
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/libfv_dynamics_interface_py.so
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)
But, nope, not there at make install
.
Maybe this is all due to the fact I sort of “hijacked” the add_library(INTERFACE)
to try and get this to work?
I’m sure I’m missing something obvious…but it’s evading me!