[llvm-dev] Embedding llvm as a git submodule in Project
Timo Janssen via llvm-dev
llvm-dev at lists.llvm.org
Mon Oct 10 01:33:06 PDT 2016
Hi Don,
thanks, but that isn't completely what I want.
THe way you explain it, I have to first build llvm an install and then
seperately my project.
But that isn't what I want. I want to build it together as one thing. In
the Rust Compiler they have llvm as a submodule in src folder. I don't
know how they do it but they don't use CMake so it won't really help to
look it up. And I want to only build those llvm libraries I will need
for my project.
Am 10.10.2016 um 02:10 schrieb don hinton:
> Hi Timo:
>
> You need to find LLVMConfig.cmake in the binary or install directory
> tree, not the source tree.
>
> Although I don't embed clang/llvm, my config might help you figure it
> -- clang/llvm installed under (could have used build directory) ~/usr :
>
> $ cd /Users/dhinton/projects/cover/build/ && rm -rf * &&
> CC=~/usr/bin/clang CXX=~/usr/bin/clang++ LLVM_DIR=~/usr/lib/cmake/llvm
> cmake ../CVRFI/ -GNinja
>
> $ cat ../CVRFI/CMakeLists.txt
> cmake_minimum_required(VERSION 2.8)
>
> set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
>
> set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
> set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
> set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
>
> # Make Debug the default, pass -DCMAKE_BUILD_TYPE=Release to change this.
> if (NOT CMAKE_BUILD_TYPE)
> message ("Setting CMAKE_BUILD_TYPE = Debug")
> set(CMAKE_BUILD_TYPE Debug)
> endif()
>
> if(APPLE)
> set(CMAKE_MACOSX_RPATH ON)
> set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}
> -undefined dynamic_lookup")
> set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}
> -undefined dynamic_lookup")
> endif()
>
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
>
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra
> -Wno-unused-parameter")
>
> # While just setting LLVM_DIR will make find_package work, you need to
> # add it to CMAKE_MODULE_PATH if you want to include AddLLVM, e.g., if
> # you want to use add_llvm_loadable_module.
> set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{LLVM_DIR}")
> find_package(LLVM REQUIRED CONFIG)
> include(AddLLVM)
> add_definitions(${LLVM_DEFINITIONS})
> include_directories(${LLVM_INCLUDE_DIRS})
> link_directories(${LLVM_LIBRARY_DIRS})
>
>
>
> On Sun, Oct 9, 2016 at 2:03 PM, Timo Janssen via llvm-dev
> <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
>
> Hi,
>
>
> I am sorry but I really am not good with cmake yet.
>
> I made one mistake I used MODULE instead of CONFIG in find_package.
>
> But even with CONFIG I doesn't work for me.
>
>
> Here my CMakeLists.txt:
>
>
> cmake_minimum_required(VERSION 3.5.1)
> project(SimpleProject)
>
> find_package(LLVM REQUIRED CONFIG PATHS
> "${CMAKE_CURRENT_SOURCE_DIR}/llvm/cmake$
>
> message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
> message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
>
> include_directories(${LLVM_INCLUDE_DIRS})
> add_definitions(${LLVM_DEFINITIONS})
>
> add_executable(simple-tool main.cpp)
>
> llvm_map_components_to_libnames(llvm_libs support)
>
> target_link_libraries(simple-tool ${llvm_libs})
>
>
> Here part of the cmake output in terminal:
>
> CMake Error at CMakeLists.txt:4 (find_package):
> Could not find a package configuration file provided by "LLVM"
> with any of
> the following names:
>
> LLVMConfig.cmake
> llvm-config.cmake
>
> Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
> "LLVM_DIR" to a directory containing one of the above files. If
> "LLVM"
> provides a separate development package or SDK, be sure it has been
> installed.
>
>
> -- Configuring incomplete, errors occurred!
> See also "/home/timoo/Schreibtisch/build/CMakeFiles/CMakeOutput.log"
>
>
> I added the PATHS to find_package becouse the command must find
> the files.
>
> In the llvm/cmake/modules dircotry are:
>
> LLVM-Config.cmake (instead of lower case) and
>
> LLVMConfig.cmake.in <http://LLVMConfig.cmake.in> (.in added at end)
>
>
> So what must I do?
>
>
>
> Am 09.10.2016 um 16:18 schrieb Timo Janssen:
>
> Hi all.
>
>
> I want to use llvm in my project and I want to make llvm a git
> submodule in my project.
>
> http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project
> <http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project>
>
> At this in the documentation it claims to describe how to
> embed llvm into a project. I tried it that way but it doesn't
> work, because there isn't any findLLVM.cmake in the
> llvm/cmake/modules directory anymore (i don't know if there
> was one in the past).
>
>
> Can someone tell me how to do it now.
>
>
> Timo Janssen
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161010/ab42f010/attachment.html>
More information about the llvm-dev
mailing list