SergiusTheBest / FindWDK

CMake module for building drivers with Windows Development Kit (WDK)
BSD 3-Clause "New" or "Revised" License
251 stars 53 forks source link
cmake cmake-module driver kernel-driver kmdf wdk windows

FindWDK

CMake module for building drivers with Windows Development Kit (WDK) Build status CI

Introduction

FindWDK makes it possible to build kernel drivers and kernel libraries with Windows Development Kit (WDK) and CMake.

Requirements:

Usage

Add FindWDK to the module search path and call find_package:

list(APPEND CMAKE_MODULE_PATH "<path_to_FindWDK>")
find_package(WDK REQUIRED)

FindWDK will search for the latest installed Windows Development Kit (WDK) and expose commands for creating kernel drivers and kernel libraries. Also the following variables will be defined:

WDKContentRoot environment variable overrides the default WDK search path.

Kernel driver

The following command adds a kernel driver target called <name> to be built from the source files listed in the command invocation:

wdk_add_driver(<name> 
    [EXCLUDE_FROM_ALL]
    [KMDF <kmdf_version>]
    [WINVER <winver_version>]
    [NTDDI_VERSION <ntddi_version>]
    source1 [source2 ...]
    )

Options:

Example:

wdk_add_driver(KmdfCppDriver 
    KMDF 1.15 
    WINVER 0x0602
    Main.cpp
    )

Kernel library

The following command adds a kernel library target called <name> to be built from the source files listed in the command invocation:

wdk_add_library(<name> [STATIC | SHARED]
    [EXCLUDE_FROM_ALL]
    [KMDF <kmdf_version>]
    [WINVER <winver_version>]
    [NTDDI_VERSION <ntddi_version>]
    source1 [source2 ...]
    )

Options:

Example:

wdk_add_library(KmdfCppLib STATIC 
    KMDF 1.15
    WINVER 0x0602
    KmdfCppLib.h 
    KmdfCppLib.cpp
    )

Linking to WDK libraries

FindWDK creates imported targets for all WDK libraries. The naming pattern is WDK::<UPPERCASED_LIBNAME>. Linking a minifilter driver to FltMgr.lib is shown below:

target_link_libraries(MinifilterCppDriver WDK::FLTMGR)

Samples

Take a look at the samples folder to see how WMD and KMDF drivers and libraries are built.

License

FindWDK is licensed under the OSI-approved 3-clause BSD license. You can freely use it in your commercial or opensource software.

Version history

Version 1.0.2 (TBD)

Version 1.0.1 (13 Mar 2018)

Version 1.0.0 (03 Feb 2018)