[flang-dev] Flang + CMake
Romero, Nichols A. via flang-dev
flang-dev at lists.llvm.org
Wed Jun 30 10:55:29 PDT 2021
Andrzej,
Thanks for raising awareness of the program.
I think someone will need to add support for Flang in CMake. I don’t have a good sense of who big of a project that will be. This is what Intel had to do for the new LLVM-based compiler:
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5594
I am not sure if there is a quick hack for it, the merged request above for the Intel LLVM-based compiler was a good chunk of CMake code.
From: flang-dev <flang-dev-bounces at lists.llvm.org> on behalf of Andrzej Warzynski via flang-dev <flang-dev at lists.llvm.org>
Reply-To: Andrzej Warzynski <andrzej.warzynski at arm.com>
Date: Wednesday, June 30, 2021 at 11:36 AM
To: "flang-dev at lists.llvm.org" <flang-dev at lists.llvm.org>
Subject: [flang-dev] Flang + CMake
[Flang = llvm-project/flang]
Hello,
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*
```CMakeLists.txt
project(hello_fortran Fortran)
add_executable(hello hello.f90)
```
*How to test*
```bash
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`:
```bash
CMake Error: Error required internal CMake variable not set, cmake may
not be built correctly.
Missing variable is:
CMAKE_Fortran_PREPROCESS_SOURCE
```
If I understand correctly, CMake fails to identify Flang because the
driver does not define the following preprocessor variables currently
expected by CMake [1]:
* __FLANG
* __FLANG_MAJOR__
* __FLANG_MINOR__
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,
-Andrzej
[1]
https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/CMakeFortranCompilerId.F.in#L143-147
[2] https://reviews.llvm.org/D84334
[3] https://reviews.llvm.org/D94422
_______________________________________________
flang-dev mailing list
flang-dev at lists.llvm.org<mailto:flang-dev at lists.llvm.org>
https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/flang-dev/attachments/20210630/f8161e70/attachment-0001.html>
More information about the flang-dev
mailing list