diff options
Diffstat (limited to 'Tests/RunCMake/VS10Project')
5 files changed, 104 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() |