Skip to content

Commit

Permalink
Remove hard-coded Clang_DIR in CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
dc-mak committed Nov 3, 2024
1 parent 39276d4 commit c5f6577
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ jobs:
steps:
- uses: actions/checkout@v3

# clang-15 seems to be required for ClangConfig.cmake
# libclang-14-dev and libclang-cpp14-dev seem to be for the opam conf-libclang package
# llvm-15-dev seems to be for the LLVM cmake files/package
# clang-15 is for ClangConfig.cmake
# libclang-14-dev and libclang-cpp14-dev are for the (silly) opam conf-libclang.15 package
# more details: https://github.com/ocaml/opam-repository/issues/26827
# llvm-15-dev is for LLVMConfig.cmake
- name: System dependencies (ubuntu)
run: |
sudo apt-get install clang-15 cmake libclang-14-dev libclang-15-dev libclang-cpp14-dev llvm-15-dev opam python3
Expand Down
17 changes: 6 additions & 11 deletions cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,16 @@
###########################################################################

# This is helpful: https://alexreinking.com/blog/how-to-use-cmake-without-the-agonizing-pain-part-1.html
# This may be too: https://github.com/onqtam/awesome-cmake

cmake_minimum_required(VERSION 3.16.3)
project(clang-tree-carver)

find_package(LLVM "15.0.7" REQUIRED CONFIG)
# Not sure what the correct/idiomatic CMake is for a situation where packages
# aren't version but CMake defaults to a wrong but earlier one instead of a
# correct later one.
# /usr/lib/cmake/clang-12/ClangConfig.cmake, version: unknown
# /usr/lib/cmake/clang-15/ClangConfig.cmake, version: unknown
# /lib/cmake/clang-12/ClangConfig.cmake, version: unknown
# /lib/cmake/clang-15/ClangConfig.cmake, version: unknown
# So I'm hard-coding it.
set(Clang_DIR "/usr/lib/cmake/clang-15")
find_package(Clang REQUIRED CONFIG)
message("LLVM Libraries: ${LLVM_LIBRARY_DIRS}")
# For some reason, ClangConfig.cmake isn't versioned, and so if there are
# multiple ones on the system, it may pick the wrong one, hence the below hint.
find_package(Clang REQUIRED CONFIG HINTS "${LLVM_LIBRARY_DIRS}/cmake")

set(CLANG_LIBS
clangAnalysis
Expand All @@ -77,7 +72,7 @@ file(GLOB CXX_SOURCES "*.cpp")

# # Whilst it is do-able, and not too icky to link directly with
# # the library instead of calling out to a different process,
# # there the linker-flags had to be copied over into a dune file manually
# # the linker-flags had to be copied over into a dune file manually
# # and the library & executable sizes ended up being stupidly large.

# # For binding via OCaml
Expand Down

0 comments on commit c5f6577

Please sign in to comment.