diff --git a/cmake/FindWdk.cmake b/cmake/FindWdk.cmake index 6987305..86757db 100644 --- a/cmake/FindWdk.cmake +++ b/cmake/FindWdk.cmake @@ -56,7 +56,7 @@ endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(WDK REQUIRED_VARS WDK_LATEST_NTDDK_FILE) -if (NOT WDK_LATEST_NTDDK_FILE) +if(NOT WDK_LATEST_NTDDK_FILE) return() endif() @@ -104,8 +104,11 @@ set(WDK_COMPILE_DEFINITIONS_DEBUG "MSC_NOOPT;DEPRECATE_DDK_FUNCTIONS=1;DBG=1") if(CMAKE_SIZEOF_VOID_P EQUAL 4) list(APPEND WDK_COMPILE_DEFINITIONS "_X86_=1;i386=1;STD_CALL") set(WDK_PLATFORM "x86") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 8 AND CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64") + list(APPEND WDK_COMPILE_DEFINITIONS "_ARM64_;ARM64") + set(WDK_PLATFORM "arm64") elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) - list(APPEND WDK_COMPILE_DEFINITIONS "_WIN64;_AMD64_;AMD64") + list(APPEND WDK_COMPILE_DEFINITIONS "_AMD64_;AMD64") set(WDK_PLATFORM "x64") else() message(FATAL_ERROR "Unsupported architecture") @@ -130,7 +133,7 @@ foreach(LIBRARY IN LISTS WDK_LIBRARIES) get_filename_component(LIBRARY_NAME ${LIBRARY} NAME_WE) string(TOUPPER ${LIBRARY_NAME} LIBRARY_NAME) add_library(WDK::${LIBRARY_NAME} INTERFACE IMPORTED) - set_property(TARGET WDK::${LIBRARY_NAME} PROPERTY INTERFACE_LINK_LIBRARIES ${LIBRARY}) + set_property(TARGET WDK::${LIBRARY_NAME} PROPERTY INTERFACE_LINK_LIBRARIES ${LIBRARY}) endforeach(LIBRARY) unset(WDK_LIBRARIES) @@ -155,7 +158,17 @@ 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} WDK::NTOSKRNL WDK::HAL WDK::WMILIB) + + if(WDK::BUFFEROVERFLOWK) + target_link_libraries(${_target} WDK::BUFFEROVERFLOWK) # to support Windows 7 and Vista + else() + target_link_libraries(${_target} WDK::BUFFEROVERFLOWFASTFAILK) + endif() + + if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64") + target_link_libraries(${_target} "arm64rt.lib") + endif() if(CMAKE_SIZEOF_VOID_P EQUAL 4) target_link_libraries(${_target} WDK::MEMCMP) @@ -170,13 +183,13 @@ function(wdk_add_driver _target) if(CMAKE_SIZEOF_VOID_P EQUAL 4) set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS "/ENTRY:FxDriverEntry@8") - elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS "/ENTRY:FxDriverEntry") endif() else() if(CMAKE_SIZEOF_VOID_P EQUAL 4) set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS "/ENTRY:GsDriverEntry@8") - elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS "/ENTRY:GsDriverEntry") endif() endif()