<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Andrzej,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks for raising awareness of the program.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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:<o:p></o:p></p>
<p class="MsoNormal"><a href="https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5594">https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5594</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">flang-dev <flang-dev-bounces@lists.llvm.org> on behalf of Andrzej Warzynski via flang-dev <flang-dev@lists.llvm.org><br>
<b>Reply-To: </b>Andrzej Warzynski <andrzej.warzynski@arm.com><br>
<b>Date: </b>Wednesday, June 30, 2021 at 11:36 AM<br>
<b>To: </b>"flang-dev@lists.llvm.org" <flang-dev@lists.llvm.org><br>
<b>Subject: </b>[flang-dev] Flang + CMake<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">[Flang = llvm-project/flang]<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Hello,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">I have been trying to use Flang with CMake and this integration seems to
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">be dysfunctional right now. Has anyone been using/testing it?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">*Minimal reproducer*<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">```CMakeLists.txt<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">project(hello_fortran Fortran)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">add_executable(hello hello.f90)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">```<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">*How to test*<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">```bash<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">mkdir build && cd build<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">cmake -G Ninja -DCMAKE_Fortran_COMPILER=<path-to-flang-or-gfortran> ../<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">```<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">*The error*<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">My minimal reproducer works fine with `gfortran`, but it fails with `flang`:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">```bash<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">CMake Error: Error required internal CMake variable not set, cmake may
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">not be built correctly.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Missing variable is:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">CMAKE_Fortran_PREPROCESS_SOURCE<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">```<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">If I understand correctly, CMake fails to identify Flang because the
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">driver does not define the following preprocessor variables currently
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">expected by CMake [1]:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">* __FLANG<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">* __FLANG_MAJOR__<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">* __FLANG_MINOR__<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">These macros were first discussed and added in [2], but then deleted in
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">[3] in order to keep Flang consistent with the rest of LLVM.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">This seems to have been broken for a while, so I suspect that this has
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">not been required by anyone recently?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Thank you,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">-Andrzej<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">[1] <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><a href="https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/CMakeFortranCompilerId.F.in#L143-147">https://gitlab.kitware.com/cmake/cmake/-/blob/master/Modules/CMakeFortranCompilerId.F.in#L143-147</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">[2] <a href="https://reviews.llvm.org/D84334">
https://reviews.llvm.org/D84334</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">[3] <a href="https://reviews.llvm.org/D94422">
https://reviews.llvm.org/D94422</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">_______________________________________________<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">flang-dev mailing list<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><a href="mailto:flang-dev@lists.llvm.org">flang-dev@lists.llvm.org</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
</div>
</body>
</html>