[LLVMbugs] [Bug 17837] New: Building clang with CMake outside LLVM tree without specifying CLANG_PATH_TO_LLVM_SOURCE

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Nov 7 01:00:15 PST 2013


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

            Bug ID: 17837
           Summary: Building clang with CMake outside LLVM tree without
                    specifying CLANG_PATH_TO_LLVM_SOURCE
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jesper.eskilson at iar.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I'm trying to build Clang using CMake, and I want to keep the Clang and LLVM
source trees separate. Looking at the Clang top-level CMakeLists.txt it should
be possible, but when I try to build with 

cmake ... -DCLANG_PATH_TO_LLVM_BUILD=/my/llvm ...

the build fails with 

FAILED: cd
/home/jesperes/dev/wtd-analyzer/build/clang-prefix/src/clang-build/include/clang/Driver
&& /home/jesperes/dev/wtd-analyzer/build/llvm-prefix/bin/llvm-tblgen
-gen-opt-parser-defs -I
/home/jesperes/dev/wtd-analyzer/build/clang-prefix/src/clang/include/clang/Driver
-I /lib/Target -I /include
/home/jesperes/dev/wtd-analyzer/build/clang-prefix/src/clang/include/clang/Driver/Options.td
-o
/home/jesperes/dev/wtd-analyzer/build/clang-prefix/src/clang-build/include/clang/Driver/Options.inc.tmp
/home/jesperes/dev/wtd-analyzer/build/clang-prefix/src/clang/include/clang/Driver/Options.td:15:9:
error: Could not find include file 'llvm/Option/OptParser.td'
include "llvm/Option/OptParser.td"
        ^

I noted the "-I /lib/Target", which got me suspicious and started poking around
in the CMakeLists.txt file, and discovered this line:

set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include")

but LLVM_MAIN_SRC_DIR is only set if CLANG_PATH_TO_LLVM_SOURCE is set. However,
the documentation of CLANG_PATH_TO_LLVM_SOURCE claims that it is not necessary
to set if building against an installed LLVM.

It looks like the proper solution is to set LLVM_MAIN_INCLUDE_DIR properly
using output from "llvm-config --includedir` if CLANG_PATH_TO_LLVM_SOURCE is
not set.

-- 
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/20131107/44a01ad6/attachment.html>


More information about the llvm-bugs mailing list