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)