Skip to content

Commit

Permalink
Add ARM64 support (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergiusTheBest committed Jul 12, 2024
1 parent c941028 commit f672a0f
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions cmake/FindWdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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")
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit f672a0f

Please sign in to comment.