Skip to content

Commit ae3e976

Browse files
jll63claude
andcommitted
dynamic_shared example: run the test from the exe's output directory
boost::dll resolves the relative library name against the working directory. Without WORKING_DIRECTORY, ctest ran the test from the binary tree where a stale boost_openmethod-shared.dll could be picked up, failing at load with ERROR_PROC_NOT_FOUND. Point it at $<TARGET_FILE_DIR:boost_openmethod-dynamic>, where the freshly-built DLL sits co-located with the exe. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent da1dd16 commit ae3e976

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

doc/modules/ROOT/examples/shared_libs/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ add_library(boost_openmethod-shared SHARED extensions.cpp)
3232
target_link_libraries(boost_openmethod-shared PRIVATE Boost::openmethod boost_openmethod-dynamic)
3333
set_target_properties(boost_openmethod-shared PROPERTIES ENABLE_EXPORTS ON)
3434

35-
add_test(NAME boost_openmethod-dynamic_shared COMMAND boost_openmethod-dynamic)
35+
# Run from the directory holding the freshly-built exe and its co-located DLL
36+
# (CMAKE_RUNTIME_OUTPUT_DIRECTORY). dynamic_main.cpp loads the DLL by relative
37+
# name, which boost::dll resolves against the working directory; without this
38+
# the test would pick up a stale copy from the source/binary tree.
39+
add_test(
40+
NAME boost_openmethod-dynamic_shared
41+
COMMAND boost_openmethod-dynamic
42+
WORKING_DIRECTORY $<TARGET_FILE_DIR:boost_openmethod-dynamic>)
3643

3744
# NOTE: build the following target (or ALL) when working on this. Just building
3845
# boost_openmethod-dynamic will *not* build the DLL.

0 commit comments

Comments
 (0)