Skip to content

Commit c2166c5

Browse files
committed
Add dynamic linking target for executable and make it default.
1 parent 8072e4d commit c2166c5

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/CMakeLists.txt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,20 @@ add_executable(testCompressedStream test/TestCompressedStream.cpp)
111111
target_link_libraries(testCompressedStream libkanzi)
112112

113113
# Main executable
114+
115+
# Dynamically linked executable
114116
add_executable(kanzi ${APP_SOURCES})
115-
target_link_libraries(kanzi libkanzi)
117+
target_link_libraries(kanzi libkanzi_shared)
118+
119+
# Set RPATH for Linux so it finds libkanzi.so at runtime
120+
set_target_properties(kanzi PROPERTIES
121+
BUILD_WITH_INSTALL_RPATH TRUE
122+
INSTALL_RPATH "$ORIGIN/../lib"
123+
)
124+
125+
# Statically linked executable
126+
add_executable(kanzi_static ${APP_SOURCES})
127+
target_link_libraries(kanzi_static libkanzi)
116128

117129
# Custom target to build all tests
118130
add_custom_target(test
@@ -133,7 +145,12 @@ add_custom_target(lib
133145
DEPENDS static_lib shared_lib
134146
)
135147

136-
# Install the main executable
148+
# Install the statically linked executable
149+
install(TARGETS kanzi_static
150+
RUNTIME DESTINATION bin
151+
)
152+
153+
# Install dynamically linked executable
137154
install(TARGETS kanzi
138155
RUNTIME DESTINATION bin
139156
)

0 commit comments

Comments
 (0)