Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the plain signature for target_link_libraries has already been used with X #29

Open
snweiss opened this issue Dec 13, 2023 · 1 comment
Assignees

Comments

@snweiss
Copy link

snweiss commented Dec 13, 2023

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"
             )

@SergiusTheBest SergiusTheBest self-assigned this Dec 13, 2023
@SergiusTheBest
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants