[cfe-dev] Building clang outside of LLVM (with CMake)
llvm at chrispick.com
Mon Feb 21 00:21:21 PST 2011
On Wed, Feb 2, 2011 at 9:58 AM, Óscar Fuentes <ofv at wanadoo.es> wrote:
> The feature is working here(*), so you can stop speculation about what's
> needed and what's not.
> I'm interested on *why* people want the feature, not on *how* to
> implement it.
I'm interested in building clang outside of LLVM for a different
reason. I'm excited by the new, official git mirrors of LLVM and
clang; my project has used unofficial git mirrors up until this point.
It has a git clone of the clang repo as a submodule in tools/clang
within a git clone of the LLVM repo which is a submodule in my
In other words, each of the following is a git repository that's a
submodule in the git repo above it:
This has worked quite well so far, someone can clone my project's git
repo, run a `git submodule --recursive --init` and have working,
compatible versions of all three projects. Now I'd like to use the
official git mirrors so I will be able to easily push/pull from the
rest of the LLVM/clang ecosystem in the future without having to rely
on any third party repositories.
The trouble comes from the fact that unlike the LLVM git repo I was
using previously, the official LLVM git repo does not have clang as a
submodule. Git does not allow submodules to overlap, that is myproj
cannot just directly add clang as a submodule inside its own llvm
submodule, the LLVM repo owns the llvm directory.
Since myproj uses CMake as its build system, I've been trying to work
around this by building clang outside of LLVM. I've had some success
1. Adding the oficial LLVM and clang git repos as submodules at
myproj/llvm and myproj/clang
2. Applying the attached patch to myproj/clang
3. Adding the following to myproj/CMakeLists.txt:
CACHE INTERNAL "Build clang as standalone."
CACHE INTERNAL "Path to LLVM source code."
CACHE INTERNAL "Path to the LLVM build directory."
I'd appreciate any feedback, especially any thoughts on whether this
sound safe and valid. If my approach makes sense, hopefully something
similar to my patch could be applied to the clang repo (something
better than commenting out the build directory check would probably be
required, but I didn't come up with anything while I was trying to get
this to work).
In the future I'd like to find or create some
FindLLVM.cmake/FindClang.cmake CMake modules that would look for
installed, system standard copies of these projects before resorting
to building them as submodules. However that would be a ways down the
road; it's nice to have ToT for development.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1645 bytes
Desc: not available
More information about the cfe-dev