Skip to content

Commit 3d92a9f

Browse files
committed
cmake: introduce the CSGREP_STATIC option
If set to ON, a statically linked `csgrep-static` executable is built and installed to the `libexec` directory. It is needed for context embedding in legacy build environments. Related: csutils#196
1 parent d215acf commit 3d92a9f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ install(TARGETS
8282
cstrans-df-run
8383
DESTINATION ${CMAKE_INSTALL_BINDIR})
8484

85+
# optionally build statically linked csgrep-static
86+
option(CSGREP_STATIC "Set to ON to build the csgrep-static executable" OFF)
87+
if(CSGREP_STATIC)
88+
add_executable(csgrep-static csgrep.cc)
89+
target_link_options(csgrep-static PRIVATE "-static")
90+
91+
# FIXME: do not hardcode paths to boost static libs
92+
target_link_libraries(csgrep-static cs
93+
/usr/lib64/libboost_filesystem.a
94+
/usr/lib64/libboost_program_options.a
95+
/usr/lib64/libboost_regex.a)
96+
97+
install(TARGETS csgrep-static
98+
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
99+
endif()
100+
85101
# pycsdiff - python binding of csdiff
86102
option(PYCSDIFF_PYTHON2 "Set to ON to build pycsdiff for Python 2" OFF)
87103
option(PYCSDIFF_PYTHON3 "Set to ON to build pycsdiff for Python 3" ON)

0 commit comments

Comments
 (0)