Skip to content

Commit 4540e31

Browse files
committed
[#19]:svarga:build, make LLVM static linking opt-in via H5CPP_STATIC_LINK_LLVM
1 parent ff8e4f6 commit 4540e31

2 files changed

Lines changed: 69 additions & 68 deletions

File tree

.github/workflows/package.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ jobs:
105105
cmake -S . -B build -G Ninja \
106106
-DCMAKE_BUILD_TYPE=Release \
107107
-DLLVM_DIR="$LLVM_DIR" \
108-
-DClang_DIR="$Clang_DIR"
108+
-DClang_DIR="$Clang_DIR" \
109+
-DH5CPP_STATIC_LINK_LLVM=ON
109110
110111
- name: Configure (Windows)
111112
if: runner.os == 'Windows'

CMakeLists.txt

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -66,74 +66,75 @@ target_compile_definitions(h5cpp PRIVATE
6666
${LLVM_DEFINITIONS}
6767
)
6868

69-
# --- Static linking: explicit library lists ---
70-
71-
set(_clang_libs
72-
clangTooling
73-
clangFormat
74-
clangToolingInclusions
75-
clangToolingCore
76-
clangRewrite
77-
clangFrontend
78-
clangDriver
79-
clangSerialization
80-
clangSema
81-
clangParse
82-
clangAPINotes
83-
clangEdit
84-
clangAnalysis
85-
clangASTMatchers
86-
clangAST
87-
clangSupport
88-
clangLex
89-
clangBasic
90-
)
69+
# Linking
70+
option(H5CPP_STATIC_LINK_LLVM "Static-link LLVM and Clang libraries (Linux only)" OFF)
71+
72+
if(H5CPP_STATIC_LINK_LLVM AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
73+
# Explicit static library lists
74+
set(_clang_libs
75+
clangTooling
76+
clangFormat
77+
clangToolingInclusions
78+
clangToolingCore
79+
clangRewrite
80+
clangFrontend
81+
clangDriver
82+
clangSerialization
83+
clangSema
84+
clangParse
85+
clangAPINotes
86+
clangEdit
87+
clangAnalysis
88+
clangASTMatchers
89+
clangAST
90+
clangSupport
91+
clangLex
92+
clangBasic
93+
)
9194

92-
# Filtered LLVM static libs (exclude unused targets/components)
93-
set(_llvm_components
94-
LLVMAggressiveInstCombine
95-
LLVMAnalysis
96-
LLVMAsmParser
97-
LLVMBinaryFormat
98-
LLVMBitReader
99-
LLVMBitWriter
100-
LLVMBitstreamReader
101-
LLVMCodeGen
102-
LLVMCodeGenTypes
103-
LLVMCore
104-
LLVMDebugInfoDWARF
105-
LLVMDemangle
106-
LLVMFrontendAtomic
107-
LLVMFrontendOffloading
108-
LLVMFrontendOpenMP
109-
LLVMIRReader
110-
LLVMInstCombine
111-
LLVMInstrumentation
112-
LLVMLinker
113-
LLVMMC
114-
LLVMMCParser
115-
LLVMObject
116-
LLVMOption
117-
LLVMPasses
118-
LLVMProfileData
119-
LLVMRemarks
120-
LLVMScalarOpts
121-
LLVMSupport
122-
LLVMTarget
123-
LLVMWindowsDriver
124-
LLVMTargetParser
125-
LLVMTextAPI
126-
LLVMTransformUtils
127-
LLVMVectorize
128-
LLVMX86AsmParser
129-
LLVMX86CodeGen
130-
LLVMX86Desc
131-
LLVMX86Disassembler
132-
LLVMX86Info
133-
LLVMipo
134-
)
95+
set(_llvm_components
96+
LLVMAggressiveInstCombine
97+
LLVMAnalysis
98+
LLVMAsmParser
99+
LLVMBinaryFormat
100+
LLVMBitReader
101+
LLVMBitWriter
102+
LLVMBitstreamReader
103+
LLVMCodeGen
104+
LLVMCodeGenTypes
105+
LLVMCore
106+
LLVMDebugInfoDWARF
107+
LLVMDemangle
108+
LLVMFrontendAtomic
109+
LLVMFrontendOffloading
110+
LLVMFrontendOpenMP
111+
LLVMIRReader
112+
LLVMInstCombine
113+
LLVMInstrumentation
114+
LLVMLinker
115+
LLVMMC
116+
LLVMMCParser
117+
LLVMObject
118+
LLVMOption
119+
LLVMPasses
120+
LLVMProfileData
121+
LLVMRemarks
122+
LLVMScalarOpts
123+
LLVMSupport
124+
LLVMTarget
125+
LLVMWindowsDriver
126+
LLVMTargetParser
127+
LLVMTextAPI
128+
LLVMTransformUtils
129+
LLVMVectorize
130+
LLVMX86AsmParser
131+
LLVMX86CodeGen
132+
LLVMX86Desc
133+
LLVMX86Disassembler
134+
LLVMX86Info
135+
LLVMipo
136+
)
135137

136-
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
137138
set(_lib_ext ".a")
138139
set(_llvm_lib_dir "${LLVM_LIBRARY_DIRS}")
139140

@@ -174,7 +175,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
174175
-lz ${ZSTD_LIBRARY} -lxml2 -lffi -ldl -lpthread -lm -lrt
175176
)
176177
else()
177-
# macOS / Windows: use CMake imported targets (may link dynamically)
178178
target_link_libraries(h5cpp PRIVATE clangTooling)
179179
endif()
180180

0 commit comments

Comments
 (0)