mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
VS: Add minimal support for Windows Kernel Mode Drivers
Extend the experimental support for `WindowsKernelModeDriver` to the Visual Studio generators. Hard-code some settings for now.
This commit is contained in:
@@ -4,8 +4,4 @@ if(NOT _cmake_windows_kernel_mode_driver_enabled)
|
||||
message(FATAL_ERROR "Windows kernel-mode driver experimental support is not enabled.")
|
||||
endif()
|
||||
|
||||
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
message(FATAL_ERROR "Visual Studio generators do not yet support CMAKE_SYSTEM_NAME=WindowsKernelModeDriver.")
|
||||
endif()
|
||||
|
||||
set(_CMAKE_FEATURE_DETECTION_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
@@ -30,7 +30,7 @@ cmExperimental::FeatureData LookupTable[] = {
|
||||
false },
|
||||
// WindowsKernelModeDriver
|
||||
{ "WindowsKernelModeDriver",
|
||||
"fac18f65-504e-4dbb-b068-f356bb1f2ddb",
|
||||
"9157bf90-2313-44d6-aefa-67cd83c8be7c",
|
||||
"CMAKE_EXPERIMENTAL_WINDOWS_KERNEL_MODE_DRIVER",
|
||||
"CMake's Windows kernel-mode driver support is experimental. It is meant "
|
||||
"only for experimentation and feedback to CMake developers.",
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "cmCryptoHash.h"
|
||||
#include "cmDocumentationEntry.h"
|
||||
#include "cmExperimental.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmGlobalVisualStudio71Generator.h"
|
||||
@@ -476,6 +477,13 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
|
||||
if (!this->InitializeWindowsStore(mf)) {
|
||||
return false;
|
||||
}
|
||||
} else if (this->SystemName == "WindowsKernelModeDriver"_s &&
|
||||
cmExperimental::HasSupportEnabled(
|
||||
*mf, cmExperimental::Feature::WindowsKernelModeDriver)) {
|
||||
this->SystemIsWindowsKernelModeDriver = true;
|
||||
if (!this->InitializeWindowsKernelModeDriver(mf)) {
|
||||
return false;
|
||||
}
|
||||
} else if (this->SystemName == "Android"_s) {
|
||||
if (this->PlatformInGeneratorName) {
|
||||
mf->IssueMessage(
|
||||
@@ -536,6 +544,13 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cmGlobalVisualStudio10Generator::InitializeWindowsKernelModeDriver(
|
||||
cmMakefile*)
|
||||
{
|
||||
this->DefaultPlatformToolset = "WindowsKernelModeDriver10.0";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cmGlobalVisualStudio10Generator::InitializeTegraAndroid(cmMakefile* mf)
|
||||
{
|
||||
std::string v =
|
||||
|
||||
@@ -127,6 +127,12 @@ public:
|
||||
/** Return true if building for WindowsStore */
|
||||
bool TargetsWindowsStore() const { return this->SystemIsWindowsStore; }
|
||||
|
||||
/** Return true if building for WindowsKernelModeDriver */
|
||||
bool TargetsWindowsKernelModeDriver() const
|
||||
{
|
||||
return this->SystemIsWindowsKernelModeDriver;
|
||||
}
|
||||
|
||||
/** Return true if building for Android */
|
||||
bool TargetsAndroid() const { return this->SystemIsAndroid; }
|
||||
|
||||
@@ -188,6 +194,7 @@ protected:
|
||||
virtual bool InitializeWindowsCE(cmMakefile* mf);
|
||||
virtual bool InitializeWindowsPhone(cmMakefile* mf);
|
||||
virtual bool InitializeWindowsStore(cmMakefile* mf);
|
||||
virtual bool InitializeWindowsKernelModeDriver(cmMakefile* mf);
|
||||
virtual bool InitializeTegraAndroid(cmMakefile* mf);
|
||||
virtual bool InitializeAndroid(cmMakefile* mf);
|
||||
|
||||
@@ -249,6 +256,7 @@ protected:
|
||||
bool SystemIsWindowsCE = false;
|
||||
bool SystemIsWindowsPhone = false;
|
||||
bool SystemIsWindowsStore = false;
|
||||
bool SystemIsWindowsKernelModeDriver = false;
|
||||
bool SystemIsAndroid = false;
|
||||
bool MSBuildCommandInitialized = false;
|
||||
|
||||
|
||||
@@ -282,6 +282,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
|
||||
this->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
|
||||
this->NsightTegra = gg->IsNsightTegra();
|
||||
this->Android = gg->TargetsAndroid();
|
||||
this->WindowsKernelMode = gg->TargetsWindowsKernelModeDriver();
|
||||
auto scanProp = target->GetProperty("CXX_SCAN_FOR_MODULES");
|
||||
for (auto const& config : this->Configurations) {
|
||||
if (scanProp.IsSet()) {
|
||||
@@ -1434,7 +1435,11 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues(Elem& e0)
|
||||
switch (this->GeneratorTarget->GetType()) {
|
||||
case cmStateEnums::SHARED_LIBRARY:
|
||||
case cmStateEnums::MODULE_LIBRARY:
|
||||
configType = "DynamicLibrary";
|
||||
if (this->WindowsKernelMode) {
|
||||
configType = "Driver";
|
||||
} else {
|
||||
configType = "DynamicLibrary";
|
||||
}
|
||||
break;
|
||||
case cmStateEnums::OBJECT_LIBRARY:
|
||||
case cmStateEnums::STATIC_LIBRARY:
|
||||
@@ -1479,6 +1484,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues(Elem& e0)
|
||||
} else if (this->Android) {
|
||||
this->WriteAndroidConfigurationValues(e1, c);
|
||||
}
|
||||
|
||||
if (this->WindowsKernelMode) {
|
||||
this->WriteMSDriverConfigurationValues(e1, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1605,6 +1614,14 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
|
||||
oh.OutputFlagMap();
|
||||
}
|
||||
|
||||
void cmVisualStudio10TargetGenerator::WriteMSDriverConfigurationValues(
|
||||
Elem& e1, std::string const&)
|
||||
{
|
||||
// FIXME: Introduce a way for project code to control these.
|
||||
e1.Element("DriverType", "KMDF");
|
||||
e1.Element("DriverTargetPlatform", "Universal");
|
||||
}
|
||||
|
||||
void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesCommon(
|
||||
Elem& e1, std::string const& config)
|
||||
{
|
||||
@@ -3214,9 +3231,13 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
|
||||
if (!this->MSTools) {
|
||||
return;
|
||||
}
|
||||
if (this->WindowsKernelMode) {
|
||||
return;
|
||||
}
|
||||
if (this->ProjectType == VsProjectType::csproj) {
|
||||
return;
|
||||
}
|
||||
|
||||
// static libraries and things greater than modules do not need
|
||||
// to set this option
|
||||
if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
|
||||
@@ -3684,6 +3705,10 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
|
||||
e2.Element("ScanSourceForModuleDependencies",
|
||||
this->ScanSourceForModuleDependencies[configName] ? "true"
|
||||
: "false");
|
||||
if (this->WindowsKernelMode) {
|
||||
e2.Element("WppEnabled", "true");
|
||||
e2.Element("WppRecorderEnabled", "true");
|
||||
}
|
||||
}
|
||||
|
||||
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
|
||||
@@ -4819,6 +4844,10 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups(Elem& e0)
|
||||
this->WriteMasmOptions(e1, c);
|
||||
this->WriteNasmOptions(e1, c);
|
||||
}
|
||||
|
||||
if (this->WindowsKernelMode) {
|
||||
Elem(e1, "DriverSign").Element("FileDigestAlgorithm", "sha256");
|
||||
}
|
||||
// output midl flags <Midl></Midl>
|
||||
this->WriteMidlOptions(e1, c);
|
||||
// write events
|
||||
|
||||
@@ -74,6 +74,7 @@ private:
|
||||
std::string const& config);
|
||||
void WriteMSToolConfigurationValuesCommon(Elem& e1,
|
||||
std::string const& config);
|
||||
void WriteMSDriverConfigurationValues(Elem& e1, std::string const& config);
|
||||
void WriteHeaderSource(Elem& e1, cmSourceFile const* sf,
|
||||
ConfigToSettings const& toolSettings);
|
||||
void WriteExtraSource(Elem& e1, cmSourceFile const* sf,
|
||||
@@ -246,6 +247,7 @@ private:
|
||||
bool Managed = false;
|
||||
bool NsightTegra = false;
|
||||
bool Android = false;
|
||||
bool WindowsKernelMode = false;
|
||||
bool HaveCustomCommandDepfile = false;
|
||||
std::map<std::string, bool> ScanSourceForModuleDependencies;
|
||||
unsigned int NsightTegraVersion[4];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
set(CMAKE_EXPERIMENTAL_WINDOWS_KERNEL_MODE_DRIVER
|
||||
"fac18f65-504e-4dbb-b068-f356bb1f2ddb")
|
||||
"9157bf90-2313-44d6-aefa-67cd83c8be7c")
|
||||
|
||||
cmake_language(GET_EXPERIMENTAL_FEATURE_ENABLED
|
||||
"WindowsKernelModeDriver"
|
||||
|
||||
Reference in New Issue
Block a user