summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/VS10Project/VsDotnetStartupObject-check.cmake22
-rw-r--r--Tests/RunCMake/VS10Project/VsDotnetStartupObject.cmake10
-rw-r--r--Tests/RunCMake/VsDotnetSdk/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject-check.cmake22
-rw-r--r--Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject.cmake11
6 files changed, 67 insertions, 0 deletions
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index 273b9d5..ee8821a 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -83,6 +83,7 @@ else()
run_UnityBuildPCH()
endif()
+run_cmake(VsDotnetStartupObject)
run_cmake(VsDotnetTargetFramework)
run_cmake(VsDotnetTargetFrameworkVersion)
run_cmake(VsNoCompileBatching)
diff --git a/Tests/RunCMake/VS10Project/VsDotnetStartupObject-check.cmake b/Tests/RunCMake/VS10Project/VsDotnetStartupObject-check.cmake
new file mode 100644
index 0000000..b3e5e37
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDotnetStartupObject-check.cmake
@@ -0,0 +1,22 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+endif()
+
+set(startupObjectSet FALSE)
+
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<StartupObject[^>]*>([^<>]+)</StartupObject>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "MyCompany.Package.MyStarterClass")
+ message(STATUS "foo.csproj has StartupObject class set")
+ set(startupObjectSet TRUE)
+ endif()
+ endif()
+endforeach()
+
+if(NOT startupObjectSet)
+ set(RunCMake_TEST_FAILED "StartupObject not found or not set correctly.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VS10Project/VsDotnetStartupObject.cmake b/Tests/RunCMake/VS10Project/VsDotnetStartupObject.cmake
new file mode 100644
index 0000000..8a0ec5e
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsDotnetStartupObject.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_executable(foo foo.cs)
+
+set_target_properties(foo PROPERTIES VS_DOTNET_STARTUP_OBJECT "MyCompany.Package.MyStarterClass")
diff --git a/Tests/RunCMake/VsDotnetSdk/RunCMakeTest.cmake b/Tests/RunCMake/VsDotnetSdk/RunCMakeTest.cmake
index b174c25..9c9074e 100644
--- a/Tests/RunCMake/VsDotnetSdk/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VsDotnetSdk/RunCMakeTest.cmake
@@ -3,6 +3,7 @@ include(RunCMake)
run_cmake(VsDotnetSdkCustomCommandsTarget)
run_cmake(VsDotnetSdkCustomCommandsSource)
+run_cmake(VsDotnetSdkStartupObject)
run_cmake(DotnetSdkVariables)
function(run_VsDotnetSdk)
diff --git a/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject-check.cmake b/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject-check.cmake
new file mode 100644
index 0000000..e81de30
--- /dev/null
+++ b/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject-check.cmake
@@ -0,0 +1,22 @@
+set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj")
+if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
+ return()
+endif()
+
+set(startupObjectSet FALSE)
+
+file(STRINGS "${vcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<StartupObject[^>]*>([^<>]+)</StartupObject>$")
+ if("${CMAKE_MATCH_1}" STREQUAL "CSharpOnly.CSharpOnly")
+ message(STATUS "foo.csproj has StartupObject class set")
+ set(startupObjectSet TRUE)
+ endif()
+ endif()
+endforeach()
+
+if(NOT startupObjectSet)
+ set(RunCMake_TEST_FAILED "StartupObject not found or not set correctly.")
+ return()
+endif()
diff --git a/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject.cmake b/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject.cmake
new file mode 100644
index 0000000..9ccd4f2
--- /dev/null
+++ b/Tests/RunCMake/VsDotnetSdk/VsDotnetSdkStartupObject.cmake
@@ -0,0 +1,11 @@
+enable_language(CSharp)
+if(NOT CMAKE_CSharp_COMPILER)
+ return()
+endif()
+
+set(CMAKE_DOTNET_SDK "Microsoft.NET.Sdk")
+set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "net5.0")
+
+add_executable(foo csharponly.cs lib1.cs)
+
+set_target_properties(foo PROPERTIES VS_DOTNET_STARTUP_OBJECT "CSharpOnly.CSharpOnly")