David Farler
2014-Sep-09 05:18 UTC
[LLVMdev] Can't build against LLVM-3.5 with CMake: CMakeExports.cmake broken?
Hi all, I can't seem to get the simplest CMakeLists.txt file working from http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project. Do any of the LLVM projects use `find_package(LLVM REQUIRED CONFIG)`? Should I just be using `llvm-config` directly? http://llvm.org/bugs/show_bug.cgi?id=20884 David
Dan Liew
2014-Sep-09 07:04 UTC
[LLVMdev] Can't build against LLVM-3.5 with CMake: CMakeExports.cmake broken?
On 9 Sep 2014 06:49, "David Farler" <accumulator at icloud.com> wrote:> > Hi all, > > I can't seem to get the simplest CMakeLists.txt file working fromhttp://llvm.org/docs/CMake.html#embedding-llvm-in-your-project. Do any of the LLVM projects use `find_package(LLVM REQUIRED CONFIG)`? This should work. Are you building LLVM with CMake or Autoconf/Makefile build system? If you build with CMake you can build your application using the LLVM build or install directory. If you built LLVM with Autoconf/Makefiles then you can only build your application using the LLVM install directory. Should I just be using `llvm-config` directly? No. If you are using CMake this is the right way to do it. When I'm at a real computer rather than my phone I'll take a proper look. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140909/67a291af/attachment.html>
Dan Liew
2014-Sep-09 11:09 UTC
[LLVMdev] Can't build against LLVM-3.5 with CMake: CMakeExports.cmake broken?
Hi, I can't reproduce your issue on the LLVM 3.5 release branch or trunk it. Looking at your bug report I think your install is messed up ``` CMake Error at /usr/local/Cellar/llvm/HEAD/share/llvm/cmake/LLVMExports.cmake:6 (set_property): set_property could not find TARGET LLVMSupport. Perhaps it has not yet been created. Call Stack (most recent call first): /usr/local/share/llvm/cmake/LLVMConfig.cmake:50 (include) CMakeLists.txt:4 (find_package) ``` /usr/local/share/llvm/cmake/LLVMConfig.cmake seems to calling /usr/local/Cellar/llvm/HEAD/share/llvm/cmake/LLVMExports.cmake which doesn't make sense. I would try cleaning up your install and start again. If you intend to working with different versions of LLVM I don't think it's a good idea to install it anyway. You can just build your project against the LLVM build directory and add the LLVM tools to your PATH when you need to. I have a simple example project that uses ``find_package(LLVM)``. Here are the steps I followed to build (I build against the LLVM build directory and don't bother installing it) $ mkdir tutorial/ # Build LLVM $ mkdir llvm/ $ cd llvm/ $ svn co http://llvm.org/svn/llvm-project/llvm/branches/release_35 src $ mkdir build $ cd build $ cmake -G Ninja ../src $ ninja # This is just for convenience when setting LLVM_DIR later on. $ LLVM_BUILD_ROOT="$(pwd)" # Build simple tutorial project $ cd ../ $ mkdir srg-llvm-pass-tutorial $ git clone https://github.com/delcypher/srg-llvm-pass-tutorial.git src $ mkdir build $ cd build/ # I'm assuming your shell will example ${LLVM_BUILD_ROOT} before invoking cmake $ cmake -DLLVM_DIR:PATH=${LLVM_BUILD_ROOT}/share/llvm/cmake/ -G Ninja ../src $ ninja Hope that helps Dan.
Apparently Analagous Threads
- [LLVMdev] Can't build against LLVM-3.5 with CMake: CMakeExports.cmake broken?
- [LLVMdev] Can't build against LLVM-3.5 with CMake: CMakeExports.cmake broken?
- [LLVMdev] Can't build against LLVM-3.5 with CMake: CMakeExports.cmake broken?
- [LLVMdev] [CMake] Generated LLVMConfig.cmake and LLVMExports.cmake broken under Visual Studio 2015
- Status of the official LLVM APT repositories