Files
CMake/Tests/RunCMake/BuildDepends/FortranInclude.cmake
T
Brad King 1f1894af1f Ninja: Fix Fortran INCLUDE directive dependencies when not preprocessing
Since commit b0a6161190 (Fortran: Add Fortran_PREPROCESS property,
2020-04-24, v3.18.0-rc1~116^2~3), if `Fortran_PREPROCESS` is `OFF`, the
Ninja generator does not properly detect dependencies on sources loaded
via the Fortran INCLUDE directive.  Fix this and add a test.
2023-05-09 09:56:42 -04:00

21 lines
964 B
CMake

enable_language(Fortran)
set(check_pairs "")
add_executable(preprocess FortranIncludePreprocess.F)
set_property(TARGET preprocess PROPERTY Fortran_PREPROCESS ON)
target_include_directories(preprocess PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND check_pairs "$<TARGET_FILE:preprocess>|${CMAKE_CURRENT_BINARY_DIR}/preprocess.inc")
# LCC < 1.24 has no way to disable Fortran preprocessor
if(NOT CMAKE_Fortran_COMPILER_ID STREQUAL "LCC" OR CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "1.24.00")
add_executable(no_preprocess FortranIncludeNoPreprocess.f)
set_property(TARGET no_preprocess PROPERTY Fortran_PREPROCESS OFF)
target_include_directories(no_preprocess PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND check_pairs "$<TARGET_FILE:no_preprocess>|${CMAKE_CURRENT_BINARY_DIR}/no_preprocess.inc")
endif()
file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake CONTENT "
set(check_pairs \"${check_pairs}\")
")