<div dir="ltr">You can also have a look at the commands that our out of tree buildbot is running:<div><a href="https://lab.llvm.org/buildbot/#/builders/175">https://lab.llvm.org/buildbot/#/builders/175</a><br></div><div><br></div><div>Just navigate to the latest green build and you should be able to see everything it does.</div><div><br></div><div>Cheers,</div><div>Diana</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 21 Dec 2021 at 22:44, Peter Steinfeld via flang-dev <<a href="mailto:flang-dev@lists.llvm.org">flang-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="gmail-m_-4170432943566549867WordSection1">
<p class="MsoNormal">I'm not sure what's causing your specific error message, but I notice that you're not doing an out-of-tree build the same way that I do.  After doing the full, in-tree build, I also create an install area using the command "make install"
 (actually, for me, "ninja install") to create the mlir and clang libraries and include files on which the out-of-tree build depends.  I first "cd" to the build directory that contains the full, in-tree build, and then execute "make install".  This creates
 and populates a directory called "install" parallel to the directory called "build".<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Wackily, in order to pick up the Google test related files, the out-of-tree build depends on the build area for the llvm files. 
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">After creating the build and install areas for my full, in-tree build (called "base" below), I create a source directory that contains all of the flang (and llvm, clang, and mlir) source.  I then "cd" to the directory above the "flang"
 directory and execute a script that looks like the commands below.  Note that the directories for mlir and clang come from the install area and the directories from llvm come from the build area.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">#!/bin/bash<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">checkStatus() {<u></u><u></u></p>
<p class="MsoNormal">  if [ $? -ne 0 ]<u></u><u></u></p>
<p class="MsoNormal">  then<u></u><u></u></p>
<p class="MsoNormal">    echo Exit $wd with error $?: $1<u></u><u></u></p>
<p class="MsoNormal">    exit 127<u></u><u></u></p>
<p class="MsoNormal">  fi<u></u><u></u></p>
<p class="MsoNormal">}<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">INSTALLDIR=`pwd`/install<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">rm -rf build<u></u><u></u></p>
<p class="MsoNormal">rm -rf install<u></u><u></u></p>
<p class="MsoNormal">mkdir -p build<u></u><u></u></p>
<p class="MsoNormal">checkStatus "mkdir -p build"<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">date<u></u><u></u></p>
<p class="MsoNormal">hostname<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">cd build<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">cmake \<u></u><u></u></p>
<p class="MsoNormal">  -G Ninja \<u></u><u></u></p>
<p class="MsoNormal">  ../llvm \<u></u><u></u></p>
<p class="MsoNormal">  -DCMAKE_BUILD_TYPE=Release \<u></u><u></u></p>
<p class="MsoNormal">  -DLLVM_LIT_ARGS=-v \<u></u><u></u></p>
<p class="MsoNormal">  -DFLANG_ENABLE_WERROR=On \<u></u><u></u></p>
<p class="MsoNormal">  -DCMAKE_CXX_STANDARD=17 \<u></u><u></u></p>
<p class="MsoNormal">  -DLLVM_ENABLE_PROJECTS="clang;mlir;flang;compiler-rt" \<u></u><u></u></p>
<p class="MsoNormal">  -DLLVM_BUILD_TOOLS=On \<u></u><u></u></p>
<p class="MsoNormal">  -DLLVM_INSTALL_UTILS=On \<u></u><u></u></p>
<p class="MsoNormal">  -DLLVM_TARGETS_TO_BUILD=host \<u></u><u></u></p>
<p class="MsoNormal">  -DLLVM_ENABLE_ASSERTIONS=ON \<u></u><u></u></p>
<p class="MsoNormal">  -DCMAKE_CXX_LINK_FLAGS="-Wl,-rpath,$LD_LIBRARY_PATH" \<u></u><u></u></p>
<p class="MsoNormal">  -DCMAKE_INSTALL_PREFIX=$INSTALLDIR<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">checkStatus "cmake"<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">ninja<u></u><u></u></p>
<p class="MsoNormal">checkStatus "ninja"<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">ninja install<u></u><u></u></p>
<p class="MsoNormal">checkStatus "ninja install"<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><b>From:</b> flang-dev <<a href="mailto:flang-dev-bounces@lists.llvm.org" target="_blank">flang-dev-bounces@lists.llvm.org</a>> <b>
On Behalf Of </b>a sk via flang-dev<br>
<b>Sent:</b> Tuesday, December 21, 2021 9:07 AM<br>
<b>To:</b> <a href="mailto:flang-dev@lists.llvm.org" target="_blank">flang-dev@lists.llvm.org</a><br>
<b>Subject:</b> [flang-dev] Unknown CMake command "add_flang_library" error<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<table border="1" cellpadding="0" style="background:rgb(255,235,156)">
<tbody>
<tr>
<td style="padding:0.75pt">
<p class="MsoNormal"><b><span style="font-size:7.5pt;font-family:Verdana,sans-serif;color:black">External email: Use caution opening links or attachments</span></b><span style="font-size:7.5pt;font-family:Verdana,sans-serif;color:black">
</span><u></u><u></u></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">Hi Community,</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<u></u> <u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">I am building Flang out of tree but getting error related to add_flang_library i.e.
</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">-------------------------------------------------------------------------------------------------------</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">Make Warning (dev) in CMakeLists.txt:</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">No project() command is present. The top-level CMakeLists.txt file must</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">contain a literal, direct call to the project() command. Add a line of</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">code such as</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">project(ProjectName)</span> <u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">near the top of the file, but after cmake_minimum_required().</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">CMake is pretending there is a "project(Project)" command on the first</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">line.</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">This warning is for project developers. Use -Wno-dev to suppress it.</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<b><span style="font-family:Arial,sans-serif">CMake Error at Common/CMakeLists.txt:2 (add_flang_library):</span></b><u></u><u></u></p>
<p style="margin-bottom:0in">
<b><span style="font-family:Arial,sans-serif">Unknown CMake command "add_flang_library".</span></b><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">CMake Warning (dev) in CMakeLists.txt:</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">No cmake_minimum_required command is present. A line of code such as</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">cmake_minimum_required(VERSION 3.16)</span>
<u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">should be added at the top of the file. The version specified may be lower</span>
<u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">if you wish to support older CMake versions for this project. For more</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">information run "cmake --help-policy CMP0000".</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">This warning is for project developers. Use -Wno-dev to suppress it.</span><u></u><u></u></p>
<p style="margin-bottom:0in">
<span style="font-family:Arial,sans-serif">-- Configuring incomplete, errors occurred!</span><u></u><u></u></p>
<p style="margin-bottom:0in">
-------------------------------------------------------------------------------------------------------<u></u><u></u></p>
<p style="margin-bottom:0in">
<u></u> <u></u></p>
<p style="margin-bottom:0in">
<b><span style="font-family:Arial,sans-serif">Command used for building Flang :
</span></b><code><span style="font-size:10pt;font-family:Arial,sans-serif">cmake -DLLVM_DIR=llvm-project/build/lib/cmake/llvm -DCLANG_DIR=llvm-project/build/lib/cmake/clang -DMLIR_DIR=llvm-project/build/lib/cmake/mlir -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=llvm-project/flang/build
 ../lib</span></code><u></u><u></u></p>
<p style="margin-bottom:0in">
<code><span style="font-size:10pt;font-family:Arial,sans-serif">Clang, mlir and llvm were built in release mode before building Flang.</span></code><u></u><u></u></p>
<p style="margin-bottom:0in">
<code><span style="font-size:10pt;font-family:Arial,sans-serif">Please guide.</span></code>
<u></u><u></u></p>
<p style="margin-bottom:0in">
<code><span style="font-size:10pt;font-family:Arial,sans-serif">Thanks</span></code><u></u><u></u></p>
</div>
</div>
</div>
</div>

_______________________________________________<br>
flang-dev mailing list<br>
<a href="mailto:flang-dev@lists.llvm.org" target="_blank">flang-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev</a><br>
</blockquote></div>