ClangConfig.cmake missing

I have build the llvm and clang from source. I want to use these two in another cpp project which is having a CMakeLists.txt as follows:

cmake_minimum_required(VERSION 3.10)
project(CppSDK)

# Find LLVM package
find_package(LLVM REQUIRED CONFIG)

# Print out the LLVM version
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

# Set the LLVM include directory
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})

# Find Clang package
find_package(Clang REQUIRED CONFIG)

# Print out the Clang version
message(STATUS "Found Clang ${Clang_VERSION}")
message(STATUS "Using ClangConfig.cmake in: ${Clang_DIR}")

# Set the Clang include directory
include_directories(${Clang_INCLUDE_DIRS})
add_definitions(${Clang_DEFINITIONS})

# Add your source files
add_executable(my_tool main.cpp)

# Link against LLVM and Clang libraries
llvm_map_components_to_libnames(llvm_libs core support)
target_link_libraries(my_tool ${llvm_libs} Clang)

I have set the LLVM_DIR to <path-to-build-tree>/build/cmake/modules/CMakeFiles which contains LLVMConfig.cmake. Now when I am building my cpp project it says:

CMake Error at CMakeLists.txt:16 (find_package):
  Could not find a package configuration file provided by "Clang" with any of
  the following names:

    ClangConfig.cmake
    clang-config.cmake

  Add the installation prefix of "Clang" to CMAKE_PREFIX_PATH or set
  "Clang_DIR" to a directory containing one of the above files.  If "Clang"
  provides a separate development package or SDK, be sure it has been
  installed.

However there is no ClangConfig.cmake in the build directory of llvm-project. Is the process changed to use LLVM and clang as libraries changed ? if yes, then what is the correct way of using llvm and clang as libraries in my own cpp project

1 Like

I see it at lib/cmake/clang/ClangConfig.cmake in my builddir.

1 Like

Thanks @ben.boeckel for the response. I surely found the file on the path !