[flang-dev] Flang + CMake

Andrzej Warzynski via flang-dev flang-dev at lists.llvm.org
Wed Jun 30 09:36:02 PDT 2021

[Flang = llvm-project/flang]


I have been trying to use Flang with CMake and this integration seems to 
be dysfunctional right now. Has anyone been using/testing it?

*Minimal reproducer*
project(hello_fortran Fortran)
add_executable(hello hello.f90)

*How to test*

mkdir build && cd build
cmake -G Ninja -DCMAKE_Fortran_COMPILER=<path-to-flang-or-gfortran> ../

*The error*
My minimal reproducer works fine with `gfortran`, but it fails with `flang`:
CMake Error: Error required internal CMake variable not set, cmake may 
not be built correctly.
Missing variable is:

If I understand correctly, CMake fails to identify Flang because the 
driver does not define the following preprocessor variables currently 
expected by CMake [1]:
These macros were first discussed and added in [2], but then deleted in 
[3] in order to keep Flang consistent with the rest of LLVM.

This seems to have been broken for a while, so I suspect that this has 
not been required by anyone recently?

Thank you,

[2] https://reviews.llvm.org/D84334
[3] https://reviews.llvm.org/D94422

More information about the flang-dev mailing list