From aed93910dbe6baa89c3c5edcd73dca2fbb12bcf1 Mon Sep 17 00:00:00 2001 From: Frederik Seiffert Date: Mon, 11 Sep 2023 16:39:04 +0200 Subject: [PATCH] Improve Windows link library dependency Fixes an error when building with CMAKE_LINK_LIBRARIES_ONLY_TARGETS enabled. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 174d56c..c9771e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,9 @@ endif() target_link_libraries(${PROJECT_NAME} PUBLIC ${QT_LIBRARIES}) if(WIN32) - target_link_libraries(${PROJECT_NAME} PRIVATE advapi32) + find_library(advapi32_LIBRARY advapi32 REQUIRED) + mark_as_advanced(advapi32_LIBRARY) + target_link_libraries(${PROJECT_NAME} PRIVATE ${advapi32_LIBRARY}) endif() target_compile_definitions(${PROJECT_NAME} PUBLIC QAPPLICATION_CLASS=${QAPPLICATION_CLASS})