diff options
author | Brad King <brad.king@kitware.com> | 2020-01-24 15:55:16 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-24 15:55:26 (GMT) |
commit | 786b56942b359e79cce489f12bf4426b4dc505de (patch) | |
tree | d31263fd656d2b0cf9d902281f8f92d3c1ab837c /Tests/RunCMake | |
parent | 4dbc9dfc7a1458878a26e1f0cec1a382e14bf48a (diff) | |
parent | ae1e1909a13fa6e68c33fe92cc8f5c76c30df76f (diff) | |
download | CMake-786b56942b359e79cce489f12bf4426b4dc505de.zip CMake-786b56942b359e79cce489f12bf4426b4dc505de.tar.gz CMake-786b56942b359e79cce489f12bf4426b4dc505de.tar.bz2 |
Merge topic 'vs-dotnet-standard-core'
ae1e1909a1 VS: Add support for .NET Standard and .NET Core
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4240
Diffstat (limited to 'Tests/RunCMake')
8 files changed, 134 insertions, 0 deletions
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 5cbe333..8a04f78 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -53,3 +53,6 @@ if (RunCMake_GENERATOR MATCHES "Visual Studio 1[0-4] 201[0-5]" OR else() run_cmake(UnityBuildNative) endif() + +run_cmake(VsDotnetTargetFramework) +run_cmake(VsDotnetTargetFrameworkVersion) diff --git a/Tests/RunCMake/VS10Project/VSDotnetTargetFrameworkVersion.cmake b/Tests/RunCMake/VS10Project/VSDotnetTargetFrameworkVersion.cmake new file mode 100644 index 0000000..8e0e0b4 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VSDotnetTargetFrameworkVersion.cmake @@ -0,0 +1,10 @@ +enable_language(CSharp) +if(NOT CMAKE_CSharp_COMPILER) + return() +endif() + +set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1") +add_library(foo SHARED foo.cs) + +set(CMAKE_DOTNET_TARGET_FRAMEWORK "netcoreapp3.1") +add_library(bar SHARED foo.cs) diff --git a/Tests/RunCMake/VS10Project/VsDotnetTargetFramework-check.cmake b/Tests/RunCMake/VS10Project/VsDotnetTargetFramework-check.cmake new file mode 100644 index 0000000..e656639 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDotnetTargetFramework-check.cmake @@ -0,0 +1,40 @@ +set(files foo.csproj bar.csproj) + +set(inLib1 FALSE) +set(targetFrameworkInLib1 FALSE) + +set(inLib2 FALSE) +set(targetFrameworksInLib2 FALSE) + +foreach(file ${files}) + set(csProjectFile ${RunCMake_TEST_BINARY_DIR}/${file}) + + if(NOT EXISTS "${csProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.") + return() + endif() + + file(STRINGS "${csProjectFile}" lines) + + foreach(line IN LISTS lines) + if(NOT inLib1) + if(line MATCHES " *<TargetFramework>netcoreapp3.1</TargetFramework> *$") + set(targetFrameworkInLib1 TRUE) + set(inLib1 TRUE) + endif() + elseif(NOT inLib2) + if(line MATCHES " *<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks> *$") + set(targetFrameworksInLib2 TRUE) + set(inLib2 TRUE) + endif() + endif() + endforeach() +endforeach() + +if(NOT targetFrameworkInLib1) + set(RunCMake_TEST_FAILED "TargetFramework not set correctly.") +endif() + +if(NOT targetFrameworksInLib2) + set(RunCMake_TEST_FAILED "TargetFrameworks not set correctly.") +endif() diff --git a/Tests/RunCMake/VS10Project/VsDotnetTargetFramework.cmake b/Tests/RunCMake/VS10Project/VsDotnetTargetFramework.cmake new file mode 100644 index 0000000..f553679 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDotnetTargetFramework.cmake @@ -0,0 +1,11 @@ +enable_language(CSharp) +if(NOT CMAKE_CSharp_COMPILER) + return() +endif() + +set(CMAKE_DOTNET_TARGET_FRAMEWORK "netcoreapp3.1") +set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "net461") +add_library(foo SHARED foo.cs) + +set(CMAKE_DOTNET_TARGET_FRAMEWORK "netcoreapp3.1;net461") +add_library(bar SHARED foo.cs) diff --git a/Tests/RunCMake/VS10Project/VsDotnetTargetFrameworkVersion-check.cmake b/Tests/RunCMake/VS10Project/VsDotnetTargetFrameworkVersion-check.cmake new file mode 100644 index 0000000..d2c3c3b --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDotnetTargetFrameworkVersion-check.cmake @@ -0,0 +1,40 @@ +set(files foo.csproj bar.csproj) + +set(inLib1 FALSE) +set(targetFrameworkInLib1 FALSE) + +set(inLib2 FALSE) +set(targetFrameworksInLib2 FALSE) + +foreach(file ${files}) + set(csProjectFile ${RunCMake_TEST_BINARY_DIR}/${file}) + + if(NOT EXISTS "${csProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.") + return() + endif() + + file(STRINGS "${csProjectFile}" lines) + + foreach(line IN LISTS lines) + if(NOT inLib1) + if(line MATCHES " *<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> *$") + set(targetFrameworkInLib1 TRUE) + set(inLib1 TRUE) + endif() + elseif(NOT inLib2) + if(line MATCHES " *<TargetFramework>netcoreapp3.1</TargetFramework> *$") + set(targetFrameworksInLib2 TRUE) + set(inLib2 TRUE) + endif() + endif() + endforeach() +endforeach() + +if(NOT targetFrameworkInLib1) + set(RunCMake_TEST_FAILED "TargetFrameworkVersion not set correctly.") +endif() + +if(NOT targetFrameworksInLib2) + set(RunCMake_TEST_FAILED "TargetFramework not set correctly.") +endif() diff --git a/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake index 47dac34..7ed0773 100644 --- a/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_external_msproject/RunCMakeTest.cmake @@ -5,3 +5,7 @@ run_cmake(CustomGuid) run_cmake(CustomTypePlatform) run_cmake(CustomGuidTypePlatform) run_cmake(CustomConfig) + +if(RunCMake_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])") + run_cmake(SkipGetTargetFrameworkProperties) +endif() diff --git a/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties-check.cmake b/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties-check.cmake new file mode 100644 index 0000000..375b231 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties-check.cmake @@ -0,0 +1,21 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/ALL_BUILD.vcxproj" all_build) + +macro(project_reference EXTERNAL_PROJECT) + string(REGEX MATCH + "<ProjectReference.Include=.${${EXTERNAL_PROJECT}}.>.*</SkipGetTargetFrameworkProperties>" + EndOfProjectReference + ${all_build} + ) +endmacro() + +set(external_project "external.project") +project_reference(external_project) +if(NOT ${EndOfProjectReference} MATCHES ".*</ProjectReference>") + set(RunCMake_TEST_FAILED "${test} is being set unexpectedly.") +endif() + +set(external_project "external.csproj") +project_reference(external_project) +if(${EndOfProjectReference} MATCHES ".*</ProjectReference>") + set(RunCMake_TEST_FAILED "${test} is not set.") +endif() diff --git a/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties.cmake b/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties.cmake new file mode 100644 index 0000000..f660bd0 --- /dev/null +++ b/Tests/RunCMake/include_external_msproject/SkipGetTargetFrameworkProperties.cmake @@ -0,0 +1,5 @@ +include_external_msproject(external1 external.project + GUID aaa-bbb-ccc-000) + +include_external_msproject(external2 external.csproj + GUID aaa-bbb-ccc-001) |