[flang-dev] Unknown CMake command "add_flang_library" error

Peter Steinfeld via flang-dev flang-dev at lists.llvm.org
Wed Dec 22 08:04:12 PST 2021


Thanks, Diana.

But I'd be cautious about using the build bots.  I don't think we actually run any tests on the results of their builds.

Pete

From: Diana Picus <diana.picus at linaro.org>
Sent: Wednesday, December 22, 2021 12:49 AM
To: Peter Steinfeld <psteinfeld at nvidia.com>
Cc: a sk <sacodework at gmail.com>; flang-dev on LLVM <flang-dev at lists.llvm.org>
Subject: Re: [flang-dev] Unknown CMake command "add_flang_library" error

External email: Use caution opening links or attachments

You can also have a look at the commands that our out of tree buildbot is running:
https://lab.llvm.org/buildbot/#/builders/175<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flab.llvm.org%2Fbuildbot%2F%23%2Fbuilders%2F175&data=04%7C01%7Cpsteinfeld%40nvidia.com%7C37bd52d44d4748ba098f08d9c527e24f%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637757597353379877%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=kQPXYFG0T1T%2Fmi%2BjtAIr03XB6ovc%2F4MWJCGVTtyq%2Bmw%3D&reserved=0>

Just navigate to the latest green build and you should be able to see everything it does.

Cheers,
Diana

On Tue, 21 Dec 2021 at 22:44, Peter Steinfeld via flang-dev <flang-dev at lists.llvm.org<mailto:flang-dev at lists.llvm.org>> wrote:
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".

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.

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.

#!/bin/bash

checkStatus() {
  if [ $? -ne 0 ]
  then
    echo Exit $wd with error $?: $1
    exit 127
  fi
}

INSTALLDIR=`pwd`/install

rm -rf build
rm -rf install
mkdir -p build
checkStatus "mkdir -p build"

date
hostname

cd build

cmake \
  -G Ninja \
  ../llvm \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_LIT_ARGS=-v \
  -DFLANG_ENABLE_WERROR=On \
  -DCMAKE_CXX_STANDARD=17 \
  -DLLVM_ENABLE_PROJECTS="clang;mlir;flang;compiler-rt" \
  -DLLVM_BUILD_TOOLS=On \
  -DLLVM_INSTALL_UTILS=On \
  -DLLVM_TARGETS_TO_BUILD=host \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DCMAKE_CXX_LINK_FLAGS="-Wl,-rpath,$LD_LIBRARY_PATH" \
  -DCMAKE_INSTALL_PREFIX=$INSTALLDIR

checkStatus "cmake"

ninja
checkStatus "ninja"

ninja install
checkStatus "ninja install"

From: flang-dev <flang-dev-bounces at lists.llvm.org<mailto:flang-dev-bounces at lists.llvm.org>> On Behalf Of a sk via flang-dev
Sent: Tuesday, December 21, 2021 9:07 AM
To: flang-dev at lists.llvm.org<mailto:flang-dev at lists.llvm.org>
Subject: [flang-dev] Unknown CMake command "add_flang_library" error

External email: Use caution opening links or attachments


Hi Community,



I am building Flang out of tree but getting error related to add_flang_library i.e.

-------------------------------------------------------------------------------------------------------

Make Warning (dev) in CMakeLists.txt:

No project() command is present. The top-level CMakeLists.txt file must

contain a literal, direct call to the project() command. Add a line of

code such as

project(ProjectName)

near the top of the file, but after cmake_minimum_required().

CMake is pretending there is a "project(Project)" command on the first

line.

This warning is for project developers. Use -Wno-dev to suppress it.

CMake Error at Common/CMakeLists.txt:2 (add_flang_library):

Unknown CMake command "add_flang_library".

CMake Warning (dev) in CMakeLists.txt:

No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 3.16)

should be added at the top of the file. The version specified may be lower

if you wish to support older CMake versions for this project. For more

information run "cmake --help-policy CMP0000".

This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

-------------------------------------------------------------------------------------------------------



Command used for building Flang : 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

Clang, mlir and llvm were built in release mode before building Flang.

Please guide.

Thanks
_______________________________________________
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<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fflang-dev&data=04%7C01%7Cpsteinfeld%40nvidia.com%7C37bd52d44d4748ba098f08d9c527e24f%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637757597353536096%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=YUa6OxvlkI5QIEbbUUa%2FgxgbOOU5%2BLnbdB4eB8pAPv4%3D&reserved=0>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/flang-dev/attachments/20211222/c0d87e9c/attachment-0001.html>


More information about the flang-dev mailing list