Open bartlettroscoe opened 7 years ago
The hard part for this will be writing portable automated tests. The most portable test might be to just build and install the TribitsExampleProject package MixedLang
and then create a downstream TriBITS project/pacakge with Fortran that reads in MixedLangConfig.cmake
and then uses some Fortran modules. Just a simple test package that duplicates the MixedLang tests might do the trick.
Description
Currently, a TriBITS package will not install Fortran generated
*.mod
module files when it installs the Fortran libraries that have modules. This makes Fortran packages that use modules basically broken when installed.This Issue is to see about updating TriBITS to automatically install the Fortran-generated "*.mod" module files.
Possible implementations:
One approach for doing that is explained in:
that is advocated by a Kitware CMake expert (Brad King). Basically, the approach is to run the commands:
For TriBITS, it might make sense to set the
CMAKE_Fortran_MODULE_DIRECTORY
variable independently for each TriBITS package. The problem is where to put the module files? Also, I think that we would need to make sure and add an INCLUDE_DIRECTORIES() command for that directory. It would be nice to setCMAKE_Fortran_MODULE_DIRECTORY
to the same directory where all of the object files are generated. To make this explicit, it might be good for each TriBITS package and subpackage to have to call a command like:somewhere in each TriBITS package. That would run three commands:
Another approach is to just add that above
INSTALL()
command toTRIBITS_ADD_LIBRARY()
. It seems that CMake runs the Fortran compiler in the sameCMAKE_CURRENT_BINARY_DIR
whereTRIBITS_ADD_LIBRARY()
is called, so if Fortran is enabled, that function might just call:but only if header files are requested to be installed. That would be seamless and should do the right thing.