mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-21 23:00:50 +08:00
VS: Fix managed C++ project generation for VS 2022
VS 2022 expects managed `.vcxproj` files to have a `ManagedAssembly` element. Fixes: #22583
This commit is contained in:
@@ -581,6 +581,10 @@ void cmVisualStudio10TargetGenerator::Generate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->Managed) {
|
if (this->Managed) {
|
||||||
|
if (this->LocalGenerator->GetVersion() >=
|
||||||
|
cmGlobalVisualStudioGenerator::VS17) {
|
||||||
|
e1.Element("ManagedAssembly", "true");
|
||||||
|
}
|
||||||
std::string outputType;
|
std::string outputType;
|
||||||
switch (this->GeneratorTarget->GetType()) {
|
switch (this->GeneratorTarget->GetType()) {
|
||||||
case cmStateEnums::OBJECT_LIBRARY:
|
case cmStateEnums::OBJECT_LIBRARY:
|
||||||
|
@@ -33,6 +33,12 @@ set(TARGET_RESX
|
|||||||
|
|
||||||
set(TARGET_LIBRARIES ${SYSLIBS})
|
set(TARGET_LIBRARIES ${SYSLIBS})
|
||||||
add_executable(${PROJECT_NAME} ${TARGET_SRC} ${TARGET_H} ${TARGET_RESX})
|
add_executable(${PROJECT_NAME} ${TARGET_SRC} ${TARGET_H} ${TARGET_RESX})
|
||||||
|
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 1[0-6]")
|
||||||
|
# VS 17 2022 and above require a global mark on managed assemblies.
|
||||||
|
# CMake adds this automatically when using COMMON_LANGUAGE_RUNTIME,
|
||||||
|
# but this test covers direct use of /clr.
|
||||||
|
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_GLOBAL_ManagedAssembly "true")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Note: The property VS_GLOBAL_KEYWORD must be set.
|
# Note: The property VS_GLOBAL_KEYWORD must be set.
|
||||||
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_GLOBAL_KEYWORD "ManagedCProj")
|
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_GLOBAL_KEYWORD "ManagedCProj")
|
||||||
|
Reference in New Issue
Block a user