[cmake-developers] [PATCH] Add target property VS_CONFIGURATION_TYPE to Visual Studio 10 target generator
Fabian.Otto at rohde-schwarz.com
Fabian.Otto at rohde-schwarz.com
Mon Feb 22 11:35:52 EST 2016
Hi all,
I implemented a small extension to the Visual Studio 10 target generator
that I would like to share.
The patch adds the target property VS_CONFIGURATION_TYPE. It allows to set
an arbitrary value to the "ConfigurationType" property in the generated
Visual Studio project file. By default, the generator fills in
"DynamicLibrary", "StaticLibrary", "Application" or "Utility", depending
on the target type.
This is useful if you want to build a Windows Kernel Mode Driver. The
Visual Studio property sheets that are part of the Windows Driver Kit
8/8.1/10 expect the value "Driver" in the "ConfigurationType" property. So
by setting VS_CONFIGURATION_TYPE to "Driver", the generator fills that in
instead of e.g. "DynamicLibrary".
Please let me know if this change is acceptable.
Best regards
Fabian
---
Help/manual/cmake-properties.7.rst | 1 +
Help/prop_tgt/VS_CONFIGURATION_TYPE.rst | 10 ++++
Source/cmVisualStudio10TargetGenerator.cxx | 79
+++++++++++++++++-------------
3 files changed, 55 insertions(+), 35 deletions(-)
create mode 100644 Help/prop_tgt/VS_CONFIGURATION_TYPE.rst
diff --git a/Help/manual/cmake-properties.7.rst
b/Help/manual/cmake-properties.7.rst
index a41d484..d6618fe 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -255,6 +255,7 @@ Properties on Targets
/prop_tgt/TYPE
/prop_tgt/VERSION
/prop_tgt/VISIBILITY_INLINES_HIDDEN
+ /prop_tgt/VS_CONFIGURATION_TYPE
/prop_tgt/VS_DESKTOP_EXTENSIONS_VERSION
/prop_tgt/VS_DOTNET_REFERENCES
/prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION
diff --git a/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst
b/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst
new file mode 100644
index 0000000..3aa87f1
--- /dev/null
+++ b/Help/prop_tgt/VS_CONFIGURATION_TYPE.rst
@@ -0,0 +1,10 @@
+VS_CONFIGURATION_TYPE
+---------------------
+
+Visual Studio project configuration type.
+
+Sets the "ConfigurationType" attribute for a generated Visual Studio
project.
+If this property is set, it overrides the default setting that is based
on
+the target type (e.g. "StaticLibrary", "Application", ...).
+
+Supported on Visual Studio 2010 and higher.
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx
b/Source/cmVisualStudio10TargetGenerator.cxx
index 09d4a90..796ad19 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -696,43 +696,52 @@ void
cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
i->c_str(),
1, " Label=\"Configuration\"", "\n");
std::string configType = "<ConfigurationType>";
- switch(this->GeneratorTarget->GetType())
- {
- case cmState::SHARED_LIBRARY:
- case cmState::MODULE_LIBRARY:
- configType += "DynamicLibrary";
- break;
- case cmState::OBJECT_LIBRARY:
- case cmState::STATIC_LIBRARY:
- configType += "StaticLibrary";
- break;
- case cmState::EXECUTABLE:
- if(this->NsightTegra &&
- !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI"))
- {
- // Android executables are .so too.
+ const char* vsConfigurationType =
+ this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE");
+ if(vsConfigurationType)
+ {
+ configType += cmVS10EscapeXML(vsConfigurationType);
+ }
+ else
+ {
+ switch(this->GeneratorTarget->GetType())
+ {
+ case cmState::SHARED_LIBRARY:
+ case cmState::MODULE_LIBRARY:
configType += "DynamicLibrary";
- }
- else
- {
- configType += "Application";
- }
- break;
- case cmState::UTILITY:
- case cmState::GLOBAL_TARGET:
- if(this->NsightTegra)
- {
- // Tegra-Android platform does not understand "Utility".
+ break;
+ case cmState::OBJECT_LIBRARY:
+ case cmState::STATIC_LIBRARY:
configType += "StaticLibrary";
- }
- else
- {
- configType += "Utility";
- }
- break;
- case cmState::UNKNOWN_LIBRARY:
- case cmState::INTERFACE_LIBRARY:
- break;
+ break;
+ case cmState::EXECUTABLE:
+ if(this->NsightTegra &&
+ !this->GeneratorTarget->GetPropertyAsBool("ANDROID_GUI"))
+ {
+ // Android executables are .so too.
+ configType += "DynamicLibrary";
+ }
+ else
+ {
+ configType += "Application";
+ }
+ break;
+ case cmState::UTILITY:
+ case cmState::GLOBAL_TARGET:
+ if(this->NsightTegra)
+ {
+ // Tegra-Android platform does not understand "Utility".
+ configType += "StaticLibrary";
+ }
+ else
+ {
+ configType += "Utility";
+ }
+ break;
+ case cmState::UNKNOWN_LIBRARY:
+ case cmState::INTERFACE_LIBRARY:
+ break;
+ }
}
configType += "</ConfigurationType>\n";
this->WriteString(configType.c_str(), 2);
--
2.7.1.windows.2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160222/a21e6a4a/attachment-0001.html>
More information about the cmake-developers
mailing list