[LLVMbugs] [Bug 21121] New: Hardcoded paths in cmake files

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 1 12:58:54 PDT 2014


            Bug ID: 21121
           Summary: Hardcoded paths in cmake files
           Product: Build scripts
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: cmake
          Assignee: unassignedbugs at nondot.org
          Reporter: stephen.warner.thomas at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I asked this question on Stack Overflow; the consensus is that this is a bug.
I'll copy and paste the text from the SO question here:

I'm using LLVM/Clang in my C++ project. I can build and run everything fine
with a Makefile.

I'm now trying to move to Cmake and I can't get things to work. Let me explain
what I've done.

I'm following this tutorial:


A relevant snippet from that webpage is:

> From LLVM 3.5 onwards both the CMake and autoconf/Makefile build
> systems export LLVM libraries as importable CMake targets.

Great! I'll go download LLVM 3.5 and I should be good to go. I went to the
download page:


and downloaded the pre-built binaries for Clang for Ubuntu 14.04 Linux. 

Then, I added the following to my `CMakeLists.txt` file:

    find_path (LLVM_DIR LLVM-Config.cmake
    message(STATUS "LLVM_DIR = ${LLVM_DIR}")
    find_package(LLVM REQUIRED CONFIG)

(This is the same as the tutorial, except I set `LLVM_DIR` since it is
currently in a non-standard location.)

When I run `cmake`, I get the following error:

    [dev at beauty:/path/to/project/build (develop)] $ cmake ..
    -- LLVM_DIR =
    CMake Error at
      include could not find load file:

    Call Stack (most recent call first):
      CMakeLists.txt:14 (find_package)

    CMake Error at
      include could not find load file:

    Call Stack (most recent call first):
      CMakeLists.txt:14 (find_package)

So Cmake seems to be finding LLVM's Cmake file, but Cmake is complaining about
some path starting with `/home/ben/`.

Indeed, it appears that LLVM's `LLVMConfig.cmake` file has some absolute paths
in it that are not relevant for my machine. For example:

    [dev at beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu ] $ head
    # This file provides information and services to the final user.




Who's `ben` and what's he doing in this file? He shows up in a few more places:

    [dev at beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu ] $ grep ben

Needless to say, those paths do not exist on my machine. I'm confused as to why
these files have these paths in them? Am I supposed to run a tool or something
to change these paths for my machine? Or do I need to change them all manually?

**EDIT**: Out of curiosity, I manually changed all those paths to point to
paths on my machine:

    [dev at beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake
] $ sed -i

After that, Cmake no longer complained and my build proceeded.

I'd still like to know why I needed to do that.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141001/e7e6f2e9/attachment.html>

More information about the llvm-bugs mailing list