From ba3fd12efb1957b85678389116f7bd36e0660c3f Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 17 May 2020 19:41:57 +0200 Subject: [PATCH] CMake: fix linking the DLL sample in monolithic build --- build/cmake/functions.cmake | 4 +++- build/cmake/samples/CMakeLists.txt | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 230df3dd63..741358f633 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -791,7 +791,9 @@ endfunction() # Link libraries to a sample function(wx_link_sample_libraries name) - target_link_libraries(${name} ${ARGN}) + if(TARGET ${name}) + target_link_libraries(${name} PUBLIC ${ARGN}) + endif() endfunction() # Add a option and mark is as advanced if it starts with wxUSE_ diff --git a/build/cmake/samples/CMakeLists.txt b/build/cmake/samples/CMakeLists.txt index a5c003da4e..fcf11fb681 100644 --- a/build/cmake/samples/CMakeLists.txt +++ b/build/cmake/samples/CMakeLists.txt @@ -262,10 +262,12 @@ if(WIN32) if(NOT wxBUILD_SHARED) # this test only makes sense with statically built wx, otherwise # the same copy of wx would be used - wx_add_sample(dll wx_exe.cpp my_dll.h NAME wx_exe FOLDER dll LIBRARIES my_dll) + wx_add_sample(dll wx_exe.cpp my_dll.h NAME wx_exe FOLDER dll) + wx_link_sample_libraries(wx_exe my_dll) endif() - wx_add_sample(dll sdk_exe.cpp my_dll.h NAME sdk_exe FOLDER dll LIBRARIES my_dll) + wx_add_sample(dll sdk_exe.cpp my_dll.h NAME sdk_exe FOLDER dll) + wx_link_sample_libraries(sdk_exe my_dll) endif() wx_add_sample(regtest RES regtest.rc DEPENDS wxUSE_REGKEY)