[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


http://llvm.org/bugs/show_bug.cgi?id=21121

            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:

http://llvm.org/docs/CMake.html#embedding

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:

http://llvm.org/releases/download.html

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
         /home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/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 =
/home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake
    CMake Error at
/home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake/LLVMConfig.cmake:50
(include):
      include could not find load file:

       
/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake/LLVMExports.cmake
    Call Stack (most recent call first):
      CMakeLists.txt:14 (find_package)


    CMake Error at
/home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake/LLVMConfig.cmake:53
(include):
      include could not find load file:

       
/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake/LLVM-Config.cmake
    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
./share/llvm/cmake/LLVMConfig.cmake
    # This file provides information and services to the final user.

    set(LLVM_INSTALL_PREFIX
"/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install")

    set(LLVM_VERSION_MAJOR 3)
    set(LLVM_VERSION_MINOR 5)
    set(LLVM_VERSION_PATCH 0)
    set(LLVM_PACKAGE_VERSION 3.5.0)

    set(LLVM_COMMON_DEPENDS )

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
./share/llvm/cmake/LLVMConfig.cmake
    set(LLVM_INSTALL_PREFIX
"/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install")
    set(LLVM_INCLUDE_DIRS
"/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/include")
    set(LLVM_LIBRARY_DIRS
"/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/lib")
    set(LLVM_CMAKE_DIR
"/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake")
    set(LLVM_TOOLS_BINARY_DIR
"/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/bin")

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
-e's/.home.ben.development.llvm.3.5.final.Phase3.Release.llvmCore-3.5.0-final.install/\/home\/dev\/Downloads\/clang+llvm-3.5.0-x86_64-linux-gnu/g'
*

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