Skip to content

Commit

Permalink
[CMake] Add a workaround for #25
Browse files Browse the repository at this point in the history
Because of the problem reported in #25, on Ubuntu Bionic we can't just
request LLVM 11.0.0 (or LLVM 11.0.1) with `find_package`. Instead, we
jsut add an extra check to make sure that LLVM's major version is indeed
11.

llvm-tutor will happily work with both LLVM 11.1.0 and LLVM 11.0.1.
However, on Darwin there's only LLVM 11.0.0 and on Ubuntu Bionic only
LLVM 11.1.0. So either we use:
  * find_package(LLVM 11.0.0 REQUIRED CONFIG) on Darwin
  * find_package(LLVM 11.1.0 REQUIRED CONFIG) on Ubuntu Bionic
or, we opt in for the solution implemented in this patch. Both are just
workarounds.
  • Loading branch information
banach-space committed Jan 16, 2021
1 parent 6f16181 commit 72cb20d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ endif()
# find_package can locate it)
list(APPEND CMAKE_PREFIX_PATH "${LT_LLVM_INSTALL_DIR}/lib/cmake/llvm/")

find_package(LLVM 11.0.0 REQUIRED CONFIG)
find_package(LLVM REQUIRED CONFIG)
# FIXME: This is a warkaround for #25. Remove once resolved and use
# find_package(LLVM 11.0.0 REQUIERED CONFIG) above.
if(NOT "11" VERSION_EQUAL "${LLVM_VERSION_MAJOR}")
message(FATAL_ERROR "Found LLVM ${LLVM_VERSION_MAJOR}, but need LLVM 11")
endif()

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

Expand Down
4 changes: 3 additions & 1 deletion HelloWorld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ set(LT_LLVM_INSTALL_DIR "" CACHE PATH "LLVM installation directory")
# find_package can locate it)
list(APPEND CMAKE_PREFIX_PATH "${LT_LLVM_INSTALL_DIR}/lib/cmake/llvm/")

find_package(LLVM 11.0.0 REQUIRED CONFIG)
# FIXME: This is a warkaround for #25. Remove once resolved and use
# find_package(LLVM 11.0.0 REQUIERED CONFIG) instead.
find_package(LLVM REQUIRED CONFIG)

# HelloWorld includes headers from LLVM - update the include paths accordingly
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
Expand Down

0 comments on commit 72cb20d

Please sign in to comment.