Skip to content

Commit a67fcab

Browse files
committed
obudump: do not force link statically on non-MSVC platforms
1 parent aee7440 commit a67fcab

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,27 @@ add_executable(obudump
6161
tools/obudump.c
6262
tools/json.c
6363
)
64-
# Always link the tool statically. This is now guaranteed to exist on all platforms.
65-
target_link_libraries(obudump PRIVATE OBUParse::static)
6664
target_include_directories(obudump PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
65+
if(TARGET OBUParse::shared)
66+
target_link_libraries(obudump PRIVATE OBUParse::shared)
67+
else()
68+
target_link_libraries(obudump PRIVATE OBUParse::static)
69+
endif()
70+
71+
# --- RPATH Handling for obudump tool ---
72+
if(UNIX AND TARGET obudump AND TARGET OBUParse::shared)
73+
# This handles the build tree. The executable is in build/bin, the library is in build/lib.
74+
# The RPATH needs to point to the library directory.
75+
set_property(TARGET obudump PROPERTY
76+
BUILD_RPATH "${CMAKE_BINARY_DIR}/lib"
77+
)
78+
79+
# This handles the install tree. The path is relative from the installed bin/ directory
80+
# to the lib/ directory.
81+
set_property(TARGET obudump PROPERTY
82+
INSTALL_RPATH "\$ORIGIN/../lib"
83+
)
84+
endif()
6785

6886
# --- Installation ---
6987
include(GNUInstallDirs)

0 commit comments

Comments
 (0)