Hi, in a Fortran project I need to place generated binary module files (.mod
) in a given directory modules
. I have used the command
set(CMAKE_Fortran_MODULE_DIRECTORY modules)
This configuration works using the gnu compiler gfortran since it adds the flag
-Jmodules
. But, when an Intel compiler is invoked ( by the command set(CMAKE_Fortran_COMPILER_ID "Intel")
the compilation fails since CMake uses always the GNU flag -Jmodules
instead of the right Intel one -module modules
. How could one fix this error? Thanks!
The compiler selection is not done using CMAKE_Fortran_COMPILER_ID
variable (this one is initialized by CMake, so should be read-only for the user).
To specify the compiler, you can use the FC environment variable or the CMAKE_Fortran_COMPILER variable.
1 Like