[CMake] Querying targets for Fortran module files & module file installation advice

Brad King brad.king at kitware.com
Wed Apr 3 09:35:59 EDT 2019


On 3/31/19 5:10 PM, Zaak Beekman wrote:
> What's the best approach for handling cross-platform (i.e., MSVS, Mac,
>  Linux) installation of Fortran module files associated with
> libraries?

The `install(DIRECTORY)` approach is the current recommendation.

> problems and drawbacks remain:
> 
> 1. With IDEs like MSVS, I always seem to end up getting an additional
> directory installed under ${CMAKE_INSTALL_INCLUDE_DIR} with the name
> of the build configuration (e.g., `debug`)

Do those directories contain the `.mod` files or are they extra?
In the latter case, use `install(DIRECTORY)`'s options for excluding
content by pattern or regex.

> 2. Utility/test modules may have generic names (e.g. assertions.mod)
> that probably should not get installed and will very likely lead to
> name  clashes with consuming projects

Set the per-target Fortran_MODULE_DIRECTORY property to keep private
modules out of the installed directory.

> 3. Lack of standard definition of module file format and Fortran ABI
> makes portability dicey, at least until ISO_Fortran_BINDING is widely
> available and adopted

That seems orthogonal.  It's a reason to not install them at all.

> It would be great if there were a target property that could be
> queried for associated module and submodule files.

We don't have that information at CMake time.  The set of files is
not discovered until the build, and there is no one place that has
the full set.

-Brad


More information about the CMake mailing list