CMAKE fortran mod directories search paths awkwardness

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

CMAKE fortran mod directories search paths awkwardness

CMake mailing list
I have had a boggle involving cmake that took several days to resolve. I had originally testing Fortran code with modules (and submodules) using gfortran exclusively. This used a directory structure roughly of the form


Where mod_dir was intended to be there depository for the *.mod and *.smod files. I then decided  to also test with the fort compiler and went to the directory structure


 where …/source/gfortran_test/mod_dir/ and …/source/ifort_test/mod_dir/ were intended to be the repositories for the *.mod and *.smod files when the source code in …/source is compiled using gfortran and ifort, respectively. Note that I failed to delete …/source/mod_dir and its files in going to this structure.

This structure initially worked with no problems. I was able to compile and execute code with both gfortran and ifort. Then working in ifort I added an overloaded function in one of my modules. When I went to testing with gfortran in …/source/gfortran_test/, however, compilation would stop claiming that the new overloaded function did not have an explicit interface. I was finally able to fix the problem by eliminating the …/source/mod_dir and its associated files. As near as I can tell the Makefile generated by make in the …/source/gfortran_test/ directory was telling gfortran to write its *.mod and *.smod files to …/source/gfortran_test/mod_dir/ and applying clean to that directory, but having …/source/mod_dir/ as one of the directories on its search path (and apparently the default directory searched for *.mod files) and NOT applying make clean to that directory. As a result gfortran was finding older *.mod and *.smod files in …/source/mod_dir/ that did not define the new overloaded function, and assumed that those files were the proper files to use for the explicit interfaces. I don’t know if ifort was also searching that directory, but not using the *.mod and *.smod files as they did not have the expected ifort structure.


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: