Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit ca4b135

Browse files
authored
Merge pull request #125 from pmem/static-capstone
Add option to statically link capstone
2 parents 4404983 + 2ce2bc5 commit ca4b135

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

CMakeLists.txt

+9-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ option(TREAT_WARNINGS_AS_ERRORS
4848
"make the build fail on any warnings during compilation, or linking" ON)
4949
option(EXPECT_SPURIOUS_SYSCALLS
5050
"account for some unexpected syscalls in tests - enable while using sanitizers, gcov" OFF)
51+
option(STATIC_CAPSTONE "statically link libcapstone into the shared library" OFF)
52+
5153
find_program(CTAGS ctags)
5254
if(CTAGS)
5355
option(AUTO_RUN_CTAGS "create tags file every on every rebuild" ON)
@@ -138,8 +140,14 @@ add_dependencies(syscall_intercept_static generate_syscall_intercept_scoped)
138140
set_target_properties(syscall_intercept_base_c
139141
PROPERTIES C_VISIBILITY_PRESET hidden)
140142

143+
set(CAPSTONE_LINK_MODE "-Bdynamic")
144+
if (STATIC_CAPSTONE)
145+
set(CAPSTONE_LINK_MODE "-Bstatic")
146+
endif()
147+
141148
target_link_libraries(syscall_intercept_shared
142-
PRIVATE ${CMAKE_DL_LIBS} ${capstone_LIBRARIES}
149+
PRIVATE ${CMAKE_DL_LIBS}
150+
"-Wl,--push-state,${CAPSTONE_LINK_MODE} -lcapstone -Wl,--pop-state"
143151
"-Wl,--version-script=${CMAKE_SOURCE_DIR}/version.map")
144152

145153
target_link_libraries(syscall_intercept_static

0 commit comments

Comments
 (0)