Consider calling initProp("Fortran_VISIBILITY_PRESET")


I noticed that the CMAKE_Fortran_VISIBILITY_PRESET behaves somewhat different than the same flag for other languages in that it cannot be specified from the cmake command line:

cmake . -DCMAKE_Fortran_VISIBILITY_PRESET=hidden
cmake --build . --verbose

warns about

Manually-specified variables were not used by the project:


and doesn’t result in -fvisibility=hidden being passed during compilation. This works as expected for C/CXX, but for fortran, it only works if the flag is set() in the CMakeLists.txt.

Looking at cmTarget.cxx, I suspect it is due to neither SETUP_COMMON_LANGUAGE_PROPERTIES(Fortran) nor initProp("Fortran_VISIBILITY_PRESET") being called.

sorry if this is not the correct category to post under.

Best, Thomas

This is an oversight. Please see CONTRIBUTING.rst and open a merge request to add the missing initProp("Fortran_VISIBILITY_PRESET") call. I don’t think we should use SETUP_COMMON_LANGUAGE_PROPERTIES because the other properties it initializes are not implemented for Fortran.

This was implemented in