mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 00:11:07 -06:00
cmVisualStudio10TargetGenerator: Fix .NET Compact Framework projects.
Fixes: #18672
This commit is contained in:
@@ -297,6 +297,11 @@ std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString(
|
||||
"$(UserRootDir)\\Microsoft.CSharp.$(Platform).user.props"
|
||||
#define VS10_CSharp_TARGETS "$(MSBuildToolsPath)\\Microsoft.CSharp.targets"
|
||||
|
||||
#define VS10_CSharp_NETCF_TARGETS \
|
||||
"$(MSBuildExtensionsPath)\\Microsoft\\$(TargetFrameworkIdentifier)\\" \
|
||||
"$(TargetFrameworkTargetsVersion)\\Microsoft.$(TargetFrameworkIdentifier)" \
|
||||
".CSharp.targets"
|
||||
|
||||
void cmVisualStudio10TargetGenerator::Generate()
|
||||
{
|
||||
// do not generate external ms projects
|
||||
@@ -480,9 +485,31 @@ void cmVisualStudio10TargetGenerator::Generate()
|
||||
targetFrameworkVersion = this->GeneratorTarget->GetProperty(
|
||||
"DOTNET_TARGET_FRAMEWORK_VERSION");
|
||||
}
|
||||
if (!targetFrameworkVersion && this->ProjectType == csproj &&
|
||||
this->GlobalGenerator->TargetsWindowsCE() &&
|
||||
this->GlobalGenerator->GetVersion() ==
|
||||
cmGlobalVisualStudioGenerator::VS12) {
|
||||
// VS12 .NETCF default to .NET framework 3.9
|
||||
targetFrameworkVersion = "v3.9";
|
||||
}
|
||||
if (targetFrameworkVersion) {
|
||||
e1.Element("TargetFrameworkVersion", targetFrameworkVersion);
|
||||
}
|
||||
if (this->ProjectType == csproj &&
|
||||
this->GlobalGenerator->TargetsWindowsCE()) {
|
||||
const char* targetFrameworkId = this->GeneratorTarget->GetProperty(
|
||||
"VS_TARGET_FRAMEWORK_IDENTIFIER");
|
||||
if (!targetFrameworkId) {
|
||||
targetFrameworkId = "WindowsEmbeddedCompact";
|
||||
}
|
||||
e1.Element("TargetFrameworkIdentifier", targetFrameworkId);
|
||||
const char* targetFrameworkVer = this->GeneratorTarget->GetProperty(
|
||||
"VS_TARGET_FRAMEWORKS_TARGET_VERSION");
|
||||
if (!targetFrameworkVer) {
|
||||
targetFrameworkVer = "v8.0";
|
||||
}
|
||||
e1.Element("TargetFrameworkTargetsVersion", targetFrameworkVer);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable the project upgrade prompt that is displayed the first time a
|
||||
@@ -638,7 +665,11 @@ void cmVisualStudio10TargetGenerator::Generate()
|
||||
Elem(e0, "Import").Attribute("Project", VS10_CXX_TARGETS);
|
||||
break;
|
||||
case csproj:
|
||||
Elem(e0, "Import").Attribute("Project", VS10_CSharp_TARGETS);
|
||||
if (this->GlobalGenerator->TargetsWindowsCE()) {
|
||||
Elem(e0, "Import").Attribute("Project", VS10_CSharp_NETCF_TARGETS);
|
||||
} else {
|
||||
Elem(e0, "Import").Attribute("Project", VS10_CSharp_TARGETS);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,3 +6,4 @@ set(RunCMake_GENERATOR_INSTANCE "")
|
||||
set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=WindowsCE )
|
||||
|
||||
run_cmake(VsCEDebuggerDeploy)
|
||||
run_cmake(VSCSharpCFProject)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#
|
||||
# Check C# Compact Framework project for required elements.
|
||||
#
|
||||
set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
|
||||
if(NOT EXISTS "${csProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if( NOT ${CMAKE_SYSTEM_NAME} STREQUAL "WindowsCE" )
|
||||
set(RunCMake_TEST_FAILED "Test only valid for WindowsCE")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(FoundTargetFrameworkTargetsVersion FALSE)
|
||||
set(FoundDotNetFrameworkVersion FALSE)
|
||||
set(FoundTargetFrameworkIdentifier FALSE)
|
||||
set(FoundCFTargetsImport FALSE)
|
||||
|
||||
|
||||
file(STRINGS "${csProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
#message(STATUS ${line})
|
||||
if(line MATCHES "^ *<TargetFrameworkIdentifier>WindowsEmbeddedCompact</TargetFrameworkIdentifier> *$")
|
||||
set(FoundTargetFrameworkIdentifier TRUE)
|
||||
elseif(line MATCHES " *<TargetFrameworkVersion>v3.9</TargetFrameworkVersion> *$")
|
||||
set(FoundDotNetFrameworkVersion TRUE)
|
||||
elseif(line MATCHES " *<TargetFrameworkTargetsVersion>v8.0</TargetFrameworkTargetsVersion> *$")
|
||||
set(FoundTargetFrameworkTargetsVersion TRUE)
|
||||
elseif( line MATCHES " *<Import Project=\"\\$\\(MSBuildExtensionsPath\\)\\\\Microsoft\\\\\\$\\(TargetFrameworkIdentifier\\)\\\\\\$\\(TargetFrameworkTargetsVersion\\)\\\\Microsoft\\.\\$\\(TargetFrameworkIdentifier\\)\\.CSharp\\.targets\" */> *" )
|
||||
set(FoundCFTargetsImport TRUE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
if(NOT FoundTargetFrameworkTargetsVersion)
|
||||
set(RunCMake_TEST_FAILED "TargetFrameworkIdentifier not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT FoundDotNetFrameworkVersion)
|
||||
set(RunCMake_TEST_FAILED "TargetFrameworkVersion not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT FoundTargetFrameworkIdentifier)
|
||||
set(RunCMake_TEST_FAILED "TargetFrameworkTargetsVersion not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT FoundCFTargetsImport)
|
||||
set(RunCMake_TEST_FAILED "Import of Compact Framework targets file not found or not set correctly.")
|
||||
return()
|
||||
endif()
|
||||
8
Tests/RunCMake/VS10ProjectWinCE/VsCSharpCFProject.cmake
Normal file
8
Tests/RunCMake/VS10ProjectWinCE/VsCSharpCFProject.cmake
Normal file
@@ -0,0 +1,8 @@
|
||||
enable_language(CSharp)
|
||||
|
||||
add_library(foo SHARED foo.cs )
|
||||
|
||||
set_target_properties(foo
|
||||
PROPERTIES
|
||||
DOTNET_TARGET_FRAMEWORK_VERSION "v3.9"
|
||||
)
|
||||
Reference in New Issue
Block a user