parent
812b0be621
commit
0721f9bf0f
@ -416,6 +416,7 @@ syn keyword cmakeProperty contained
|
||||
\ VS_DOTNET_STARTUP_OBJECT
|
||||
\ VS_DOTNET_TARGET_FRAMEWORK_VERSION
|
||||
\ VS_DPI_AWARE
|
||||
\ VS_FRAMEWORK_REFERENCES
|
||||
\ VS_GLOBAL_KEYWORD
|
||||
\ VS_GLOBAL_PROJECT_TYPES
|
||||
\ VS_GLOBAL_ROOTNAMESPACE
|
||||
|
@ -430,6 +430,7 @@ Properties on Targets
|
||||
/prop_tgt/VS_DOTNET_STARTUP_OBJECT
|
||||
/prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION
|
||||
/prop_tgt/VS_DPI_AWARE
|
||||
/prop_tgt/VS_FRAMEWORK_REFERENCES
|
||||
/prop_tgt/VS_GLOBAL_KEYWORD
|
||||
/prop_tgt/VS_GLOBAL_PROJECT_TYPES
|
||||
/prop_tgt/VS_GLOBAL_ROOTNAMESPACE
|
||||
|
12
Help/prop_tgt/VS_FRAMEWORK_REFERENCES.rst
Normal file
12
Help/prop_tgt/VS_FRAMEWORK_REFERENCES.rst
Normal file
@ -0,0 +1,12 @@
|
||||
VS_FRAMEWORK_REFERENCES
|
||||
-----------------------
|
||||
|
||||
.. versionadded:: 3.31
|
||||
|
||||
Visual Studio framework references.
|
||||
Specify a :ref:`semicolon-separated list <CMake Language Lists>` of framework references
|
||||
to be added to a generated Visual Studio project. For example:
|
||||
|
||||
* "Microsoft.WindowsDesktop.App.WPF" for WPF applications
|
||||
* "Microsoft.WindowsDesktop.App.WindowsForms" for WinForms applications
|
||||
* "Microsoft.WindowsDesktop.App" for applications using both frameworks
|
5
Help/release/dev/vs-framework-references.rst
Normal file
5
Help/release/dev/vs-framework-references.rst
Normal file
@ -0,0 +1,5 @@
|
||||
vs-framework-references
|
||||
-----------------------
|
||||
|
||||
* The :prop_tgt:`VS_FRAMEWORK_REFERENCES` target property was added
|
||||
to tell :ref:`Visual Studio Generators` to add framework references.
|
@ -813,6 +813,7 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
|
||||
this->WriteCustomCommands(e0);
|
||||
this->WriteAllSources(e0);
|
||||
this->WriteDotNetReferences(e0);
|
||||
this->WriteFrameworkReferences(e0);
|
||||
this->WritePackageReferences(e0);
|
||||
this->WriteImports(e0);
|
||||
this->WriteEmbeddedResourceGroup(e0);
|
||||
@ -1187,6 +1188,21 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReference(
|
||||
this->WriteDotNetReferenceCustomTags(e2, ref);
|
||||
}
|
||||
|
||||
void cmVisualStudio10TargetGenerator::WriteFrameworkReferences(Elem& e0)
|
||||
{
|
||||
cmList references;
|
||||
if (cmValue vsFrameworkReferences =
|
||||
this->GeneratorTarget->GetProperty("VS_FRAMEWORK_REFERENCES")) {
|
||||
references.assign(*vsFrameworkReferences);
|
||||
}
|
||||
|
||||
Elem e1(e0, "ItemGroup");
|
||||
for (auto const& ref : references) {
|
||||
Elem e2(e1, "FrameworkReference");
|
||||
e2.Attribute("Include", ref);
|
||||
}
|
||||
}
|
||||
|
||||
void cmVisualStudio10TargetGenerator::WriteImports(Elem& e0)
|
||||
{
|
||||
cmValue imports =
|
||||
|
@ -91,6 +91,7 @@ private:
|
||||
void WriteDotNetReference(Elem& e1, std::string const& ref,
|
||||
std::string const& hint,
|
||||
std::string const& config);
|
||||
void WriteFrameworkReferences(Elem& e0);
|
||||
void WriteDotNetDocumentationFile(Elem& e0);
|
||||
void WriteImports(Elem& e0);
|
||||
void WriteDotNetReferenceCustomTags(Elem& e2, std::string const& ref);
|
||||
|
@ -98,6 +98,7 @@ run_cmake(DebugInformationFormat)
|
||||
run_cmake(VsCLREmpty)
|
||||
run_cmake(VsCLRPure)
|
||||
run_cmake(VsCLRSafe)
|
||||
run_cmake(VsFrameworkReference)
|
||||
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.20)
|
||||
run_cmake(VsCLRNetcore)
|
||||
|
24
Tests/RunCMake/VS10Project/VsFrameworkReference-check.cmake
Normal file
24
Tests/RunCMake/VS10Project/VsFrameworkReference-check.cmake
Normal file
@ -0,0 +1,24 @@
|
||||
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
|
||||
if(NOT EXISTS "${vcProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(frameworkReferenceSet FALSE)
|
||||
|
||||
file(STRINGS "${vcProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<FrameworkReference Include=\"([^\"]*)\" />$")
|
||||
if("${CMAKE_MATCH_1}" STREQUAL "Microsoft.WindowsDesktop.App.WPF")
|
||||
message(STATUS "foo.vcxproj has FrameworkReference set")
|
||||
set(frameworkReferenceSet TRUE)
|
||||
else()
|
||||
message(STATUS "foo.vcxproj has FrameworkReference incorrectly set to ${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT frameworkReferenceSet)
|
||||
set(RunCMake_TEST_FAILED "FrameworkReference not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
8
Tests/RunCMake/VS10Project/VsFrameworkReference.cmake
Normal file
8
Tests/RunCMake/VS10Project/VsFrameworkReference.cmake
Normal file
@ -0,0 +1,8 @@
|
||||
enable_language(CXX)
|
||||
|
||||
add_executable(foo foo.cpp)
|
||||
|
||||
set_target_properties(foo PROPERTIES
|
||||
COMMON_LANGUAGE_RUNTIME "netcore"
|
||||
DOTNET_TARGET_FRAMEWORK "net8.0-windows"
|
||||
VS_FRAMEWORK_REFERENCES "Microsoft.WindowsDesktop.App.WPF")
|
Loading…
Reference in New Issue
Block a user