Shared library in CMake

The -l flags are also linker options.

For an IMPORTED target, it’s something like:

add_library(custom STATIC IMPORTED)
set_target_properties(custom PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "/abs/path/to/custom/includes/dir"
  IMPORTED_LOCATION "/opt/custom/lib/libcustom.a"
  INTERFACE_LINK_LIBRARIES "gfortran;m"
  )

You then use it by target_link_libraries(main PRIVATE custom).

1 Like