Skip to content

Commit 830ed97

Browse files
author
Christopher Di Bella
committed
adds llvm-project to //third_party
Rather than depending on the system's LLVM and Clang, we move Subspace to pull a specific version of llvm-project instead. Due to more modern versions of LLVM being incompatible with Subdoc, we conservatively pin the tag at LLVM 17.0.6, which is the version used by CI.
1 parent e2fe8b7 commit 830ed97

5 files changed

Lines changed: 46 additions & 8 deletions

File tree

subdoc/CMakeLists.txt

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,23 @@ add_executable(subdoc
8383
# subdoc_lib
8484
subspace_default_compile_options(subdoc_lib)
8585

86-
find_package(LLVM REQUIRED)
87-
find_package(Clang REQUIRED)
8886
llvm_config(subdoc_lib)
89-
target_include_directories(subdoc_lib PUBLIC ${LLVM_INCLUDE_DIRS})
90-
target_link_directories(subdoc_lib PUBLIC ${LLVM_LIBRARY_DIRS})
87+
include(FetchContent)
88+
FetchContent_GetProperties(llvm-project)
89+
target_include_directories(subdoc_lib PUBLIC
90+
"${llvm-project_SOURCE_DIR}/clang/include"
91+
"${llvm-project_SOURCE_DIR}/llvm/include"
92+
"${llvm-project_BINARY_DIR}/include"
93+
"${llvm-project_BINARY_DIR}/tools/clang/include"
94+
)
95+
target_link_directories(subdoc_lib PUBLIC
96+
"${llvm-project_BINARY_DIR}/clang/lib"
97+
)
9198

92-
target_link_libraries(subdoc_lib
93-
subspace::lib
94-
md4c
95-
md4c-html
99+
set(SUBDOC_LLVM_DEPS
100+
Support
101+
)
102+
set(SUBDOC_CLANG_DEPS
96103
clangAnalysis
97104
clangAnalysisFlowSensitive
98105
clangAnalysisFlowSensitiveModels
@@ -136,6 +143,14 @@ target_link_libraries(subdoc_lib
136143
clangToolingSyntax
137144
clangTransformer
138145
)
146+
llvm_map_components_to_libnames(llvm_libs "${SUBDOC_LLVM_DEPS};${SUBDOC_CLANG_DEPS}")
147+
148+
target_link_libraries(subdoc_lib
149+
subspace::lib
150+
md4c
151+
md4c-html
152+
${llvm_libs}
153+
)
139154

140155
# subdoc binary
141156
subspace_binary_default_compile_options(subdoc)

third_party/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
include(FetchContent)
22

3+
# Thirds-party projects should be built with warnings disabled to limit noise and build breaks.
4+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -Wno-error")
5+
36
# This directory handles third-party dependency package management.
47
#
58
# Packages that use CMake are handled using `FetchContent`. `FetchContent` is split into two

third_party/FetchContent_Declare.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ add_subdirectory(fmt)
33
add_subdirectory(googletest)
44
add_subdirectory(md4c)
55
add_subdirectory(nanobench)
6+
add_subdirectory(llvm-project)

third_party/FetchContent_MakeAvailable.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ if(SUBSPACE_BUILD_BENCHMARKS)
1313
FetchContent_MakeAvailable(nanobench)
1414
set_property(TARGET nanobench PROPERTY CXX_STANDARD 20)
1515
endif()
16+
17+
FetchContent_MakeAvailable(llvm-project)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
set(LLVM_BUILD_TOOLS No CACHE BOOL "")
2+
set(LLVM_ENABLE_PROJECTS "llvm;clang" CACHE BOOL "")
3+
set(LLVM_ENABLE_WARNINGS No CACHE BOOL "")
4+
set(LLVM_INSTALL_BINUTILS_SYMLINKS No CACHE BOOL "")
5+
set(LLVM_INSTALL_CCTOOLS_SYMLINKS No CACHE BOOL "")
6+
set(LLVM_TARGETS_TO_BUILD "Native" CACHE BOOL "")
7+
set(LLVM_TOOLS_INSTALL_DIR "bin" CACHE STRING "")
8+
9+
FetchContent_Declare(
10+
llvm-project
11+
GIT_REPOSITORY https://github.com/llvm/llvm-project.git
12+
GIT_TAG llvmorg-17.0.6
13+
GIT_SHALLOW Yes
14+
SOURCE_SUBDIR llvm
15+
SYSTEM
16+
OVERRIDE_FIND_PACKAGE
17+
)

0 commit comments

Comments
 (0)