FindWDK icon indicating copy to clipboard operation
FindWDK copied to clipboard

the plain signature for target_link_libraries has already been used with X

Open snweiss opened this issue 1 year ago • 1 comments

A "the plain signature for target_link_libraries has already been used with ..." error is generated when trying to add private link dependencies after a target was generated with wdk_add_driver :

wdk_add_driver(driver WINVER 0x0A00)
target_link_libraries(driver PRIVATE WDK::WDMSEC)

This can be workaround by just removing the "PRIVATE" option but our use-case is slightly more complex since the link dependencies are set by down-stream cmake infrastructure files that are shared among different projects.

This is the patch that we're currently using to mitigate the issue

diff --git a/FindWdk.cmake b/FindWdk.cmake
index 6987305..c5ba280 100644
--- a/FindWdk.cmake
+++ b/FindWdk.cmake
@@ -155,15 +155,15 @@ function(wdk_add_driver _target)
         "${WDK_ROOT}/Include/${WDK_INC_VERSION}/km/crt"
         )
 
-    target_link_libraries(${_target} WDK::NTOSKRNL WDK::HAL WDK::BUFFEROVERFLOWK WDK::WMILIB)
+    target_link_libraries(${_target} PRIVATE WDK::NTOSKRNL WDK::HAL WDK::BUFFEROVERFLOWK WDK::WMILIB)
 
     if(CMAKE_SIZEOF_VOID_P EQUAL 4)
-        target_link_libraries(${_target} WDK::MEMCMP)
+        target_link_libraries(${_target} PRIVATE WDK::MEMCMP)
     endif()
 
     if(DEFINED WDK_KMDF)
         target_include_directories(${_target} SYSTEM PRIVATE "${WDK_ROOT}/Include/wdf/kmdf/${WDK_KMDF}")
-        target_link_libraries(${_target}
+        target_link_libraries(${_target} PRIVATE
             "${WDK_ROOT}/Lib/wdf/kmdf/${WDK_PLATFORM}/${WDK_KMDF}/WdfDriverEntry.lib"
             "${WDK_ROOT}/Lib/wdf/kmdf/${WDK_PLATFORM}/${WDK_KMDF}/WdfLdr.lib"
             )

snweiss avatar Dec 13 '23 12:12 snweiss

Yes, target_link_libraries should be modernized to specify visibility (private, public, interface). Thanks for reporting!

SergiusTheBest avatar Dec 13 '23 12:12 SergiusTheBest