DOC: CMAKE_REQUIRED_INCLUDES for check_fortran_source-*() position
It took me a while to figure out that my check_fortran_source_compiles()
and check_fortran_source_runs()
were failing when they depended on directories from CMAKE_REQUIRED_INCLUDES
because find_package()
can seem to overwrite or blank the value of CMAKE_REQUIRED_INCLUDES.
Whether or not that should be happening, the "correct" way or at least a workaround is to set CMAKE_REQUIRED_INCLUDES
after any find_package() statements. I suppose the surprising thing to be was that find_package() acted like a macro in that it seems to overwrite the value of variables set previously. In this case, the find_program() call set CMAKE_REQUIRED_INCLUDES to something else (it's a user-created Find*.cmake) and I didn't realize this would affect the parent scope calling find_program()