Home > Software design >  How can I make homebrew's cmake to use system clang
How can I make homebrew's cmake to use system clang

Time:08-02

OS: MacOS 12.4

Installed cmake with

brew install cmake

cmake version 3.23.3

Installed clang with

xcode-select --install

clang version is 13.1.6

Trying to build ccls:

git clone https://github.com/MaskRay/ccls.git
mkdir build && cd build
cmake ..

And getting following output

-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- The C compiler identification is AppleClang 13.1.6.13160021
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c   - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Setting build type to 'Release' as none was specified.
CMake Error at CMakeLists.txt:72 (find_package):
  By not providing "FindClang.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Clang", but
  CMake did not find one.

  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.


-- Configuring incomplete, errors occurred!
See also "/Users/umed/projects/MaskRay/ccls/build/CMakeFiles/CMakeOutput.log".
See also "/Users/umed/projects/MaskRay/ccls/build/CMakeFiles/CMakeError.log".

Is there anyway to make brew's cmake work with system clang?

CodePudding user response:

The question is not correct. CMake uses the system clang successfully, but it can't find clang libraries required by the project.

The Build manual lists the requirements, one of them is

  • Clang LLVM headers and libraries, version >= 7

You get errors because you have not provided that dependency.

brew install llvm@13
  • Related