Building LLVM example

at llvm 11.0.

i tried to it, and it works.

maybe have to use add_llvm_executable command for linking with LLVM_LINK_COMPONENTS

cmake_minimum_required(VERSION 3.4.3)

find_package(LLVM REQUIRED CONFIG)
project(BrainF)

message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)

set(LLVM_LINK_COMPONENTS
  BitWriter
  Core
  ExecutionEngine
  MC
  MCJIT
  Support
  nativecodegen
  )

add_llvm_executable(BrainF
  BrainF.cpp
  BrainFDriver.cpp
  )

p.s. update. 2020.11.1.

more info

cmake_minimum_required(VERSION 3.4.3)
project(BrainF)

find_package(LLVM 11 REQUIRED CONFIG)
add_definitions(${LLVM_DEFINITIONS})
include_directories(${LLVM_INCLUDE_DIRS})

message(STATUS "LLVM VERSION : ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

add_executable(BrainF
  BrainF.cpp
  BrainFDriver.cpp
)

llvm_map_components_to_libnames(llvm_libs support core irreader)

target_link_libraries(BrainF llvm_libs)

This thread helped me to get AddLLVM: For the cmake "include" command, what is the difference between a file and a module?

Besides, now after manually setting I have problem: “Library `jit' not found in list of llvm libraries”. The full text of error:

$ cmake .
CMake Error at /usr/src/llvm/cmake/modules/LLVM-Config.cmake:141 (message):
  Library `jit' not found in list of llvm libraries.
Call Stack (most recent call first):
  /usr/src/llvm/cmake/modules/LLVM-Config.cmake:54 (explicit_map_components_to_libraries)
  /usr/src/llvm/cmake/modules/LLVM-Config.cmake:47 (explicit_llvm_config)
  /usr/src/llvm/cmake/modules/AddLLVM.cmake:86 (llvm_config)
  /usr/src/llvm/cmake/modules/AddLLVM.cmake:112 (add_llvm_executable)
  CMakeLists.txt:17 (add_llvm_example)

Tags:

Cmake

Llvm