Hello,
I need to set a flag (“Mfree”) for my Fortran compiler. However, using the -DCMAKE_Fortran_FLAGS is not making any difference. I have compared both Makefiles (with and without) and they are the same (except for the parent directory). The full command to invoke the compilation is:
Hi @scivision,
Unfortunately including FFLAGS="-Mfree" doesn’t help either. I also tried $sudo /usr/local/bin/cmake --build /opt/NCEPLIBS/build --target clean to clean up as much as possible but same result. Unless the issue is caused by running cmake as a superuser, I’m out of ideas. Thanks.
The build directory probably needs to be wiped out e.g. rm -r /opt/NCEPLIBS/build otherwise CMake will have already initialized CMAKE_Fortran_FLAGS and ignores FFLAGS.
I wiped out everything and tried to build from a different directory as a user (rather than as sudo) but the result is still the same, it doesn’t take the flag and fails with the Label field of continuation line is not blank error message while trying to compile.
Hi @scivision,
Trying to compile as a user rather than sudo didn’t make the trick for me. At the end, I had to fork (from the developer) and add the CMAKE_Fortran_FLAGS to the options included in CmakeLists.txt. It seems that it has finally taken the flag although it’s generating a long list of errors caused by other parts of the code. Thanks.
Can you check wether exporting the environment variable FFLAGS prior to your cmake call does solve the issue? I suppose it has to do with the usage of ExternalProject_Add in the CMakeLists.txt file. The setting for CMAKE_Fortran_FLAGS is not propagated to the invocation of the ExternalProject_Add configure/build command. Setting the FFLAGS=-Mfree variable prior to the invocation of cmake does influence only the cmake command’s shell but not the subsequently started ones for ExternalProject_Add commands. And try to build that as a restricted user without using sudo.
OK. If using ExternalProject, as Volker notes sudo may be making more complexities with the environment variables propagating through.
I would also strongly encourage in general using build systems including CMake without sudo. Perhaps only use sudo on the cmake --install build step if needed.