Skip to content

Commit e412bba

Browse files
[Build] Self-contained UIX applications
- Use self-contained applications, avoids relying on installed .NET runtimes - CMake generated solutions with mixed C#, C++ and C++/CLI projects require that managed project files are in separate folders from native projects due to an issue with Nuget resolving. - Fixed sham dependencies on schema .NET bindings, as Visual Studio .NET targets cannot depend on custom commands, create intermediary target to merge all schema dependencies. - Upgraded to .NET6.0, better support for missing .NET runtimes and numerous fixes to self-contained apps - Default to latest C# language version for the given SDK - .NET6 implicitly disables com-interop support with trimming, re-enable it #48
1 parent 15a999e commit e412bba

File tree

51 files changed

+356
-81
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+356
-81
lines changed

Build/CSharp.cmake

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,47 +34,64 @@ function(Project_AddDotNet NAME)
3434
# DotNet
3535
set_target_properties(
3636
${NAME} PROPERTIES
37-
VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.8"
37+
DOTNET_SDK "Microsoft.NET.Sdk"
38+
DOTNET_TARGET_FRAMEWORK "net6.0"
39+
VS_GLOBAL_Platforms "x64"
40+
VS_GLOBAL_RuntimeIdentifier "win-x64"
41+
VS_GLOBAL_SelfContained "true"
42+
VS_GLOBAL_AppendTargetFrameworkToOutputPath "false"
43+
VS_GLOBAL_AppendRuntimeIdentifierToOutputPath "false"
3844
VS_GLOBAL_ROOTNAMESPACE ${NAME}
3945
)
4046

4147
# IDE source discovery
4248
SetSourceDiscovery(${NAME} CS Include Source Schema)
4349
endfunction()
4450

51+
# Add a .NET merge target for generated files
52+
# ! Must be called in the same CMakeLists.txt as the custom commands
53+
function(Project_AddDotNetGeneratedMerge NAME GENERATED_SOURCES)
54+
set(Command "")
55+
56+
# Copy each schema target
57+
foreach(File ${${GENERATED_SOURCES}})
58+
list(APPEND Command COMMAND "${CMAKE_COMMAND}" -E copy "${File}.gen" "${File}")
59+
60+
# Generated project / MSBUILD does not check that if inbound file originates from
61+
# another target.
62+
if (NOT EXISTS ${File})
63+
file(WRITE "${File}" "Generation target file")
64+
endif()
65+
endforeach()
66+
67+
# Schema Gen -> Schema
68+
add_custom_target(
69+
${NAME}
70+
DEPENDS ${${GENERATED_SOURCES}_Gen}
71+
BYPRODUCTS ${${GENERATED_SOURCES}}
72+
${Command}
73+
)
74+
endfunction()
75+
4576
function(Project_AddDotNetEx)
4677
cmake_parse_arguments(
4778
ARGS
4879
"UNSAFE;EXECUTABLE" # Options
4980
"NAME;LANG;PROPS" # One Value
50-
"SOURCE;GENERATED;ASSEMBLIES;LIBS;FLAGS" # Multi Value
81+
"SOURCE;DEPENDENCIES;ASSEMBLIES;LIBS;FLAGS" # Multi Value
5182
${ARGN}
5283
)
5384

54-
if (NOT "${ARGS_GENERATED}" STREQUAL "")
55-
# Generate sham target
56-
# ! WORKAROUND, Visual Studio generators do not support C# sources from add_custom_command
57-
# Check introduced by 3.24
58-
add_library(${ARGS_NAME}.Sham INTERFACE ${${ARGS_GENERATED}_Sham})
59-
60-
# Create dummy file to keep MSVC happy
61-
if (NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${${ARGS_GENERATED}_Sham}")
62-
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${${ARGS_GENERATED}_Sham}" Sham)
63-
endif()
64-
endif()
65-
6685
# Create library
6786
if ("${ARGS_EXECUTABLE}")
6887
add_executable(
6988
${ARGS_NAME}
7089
${ARGS_SOURCE}
71-
${${ARGS_GENERATED}}
7290
)
7391
else()
7492
add_library(
7593
${ARGS_NAME} SHARED
7694
${ARGS_SOURCE}
77-
${${ARGS_GENERATED}}
7895
)
7996
endif()
8097

@@ -95,7 +112,13 @@ function(Project_AddDotNetEx)
95112
# Set .NET, link to assemblies and libs
96113
set_target_properties(
97114
${ARGS_NAME} PROPERTIES
98-
VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.8"
115+
DOTNET_SDK "Microsoft.NET.Sdk"
116+
DOTNET_TARGET_FRAMEWORK "net6.0"
117+
VS_GLOBAL_Platforms "x64"
118+
VS_GLOBAL_RuntimeIdentifier "win-x64"
119+
VS_GLOBAL_SelfContained "true"
120+
VS_GLOBAL_AppendTargetFrameworkToOutputPath "false"
121+
VS_GLOBAL_AppendRuntimeIdentifierToOutputPath "false"
99122
VS_GLOBAL_ROOTNAMESPACE "${ARGS_NAME}"
100123
VS_DOTNET_REFERENCES "${ARGS_ASSEMBLIES};${ARGS_LIBS}"
101124
VS_USER_PROPS "${CMAKE_SOURCE_DIR}/Build/cs.configuration.props"
@@ -128,10 +151,10 @@ function(Project_AddDotNetEx)
128151
endif()
129152
endif()
130153

131-
# Reference sham target to let dependencies generate before use
132-
if (NOT "${ARGS_GENERATED}" STREQUAL "")
133-
add_dependencies(${ARGS_NAME} ${ARGS_NAME}.Sham)
134-
endif()
154+
# Add additional dependencies
155+
if (NOT "${ARGS_DEPENDENCIES}" STREQUAL "")
156+
add_dependencies(${ARGS_NAME} ${ARGS_DEPENDENCIES})
157+
endif()
135158

136159
# IDE source discovery
137160
SetSourceDiscovery(${ARGS_NAME} ${ARGS_LANG} Include Source)

Build/cs.configuration.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ResolveNuGetPackages>false</ResolveNuGetPackages>
5+
</PropertyGroup>
36
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="Configuration">
47
<Optimize>true</Optimize>
58
</PropertyGroup>

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ if (${ENABLE_UIX} AND CMAKE_GENERATOR MATCHES "Visual Studio")
149149
enable_language(CSharp)
150150

151151
# Set standard C# properties
152-
SET(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "v4.8")
153-
SET(CMAKE_CSharp_FLAGS "/langversion:6")
152+
SET(CMAKE_DOTNET_TARGET_FRAMEWORK "net6.0")
153+
SET(CMAKE_CSharp_FLAGS "/langversion:latest")
154154
SET(CMAKE_CSharp_FLAGS "/platform:x64")
155155
else()
156156
set(BUILD_UIX OFF)

Source/Features/Concurrency/Backend/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@ Project_AddTest(
7474
#----- .Net bindings -----#
7575

7676
if (${BUILD_UIX})
77-
Project_AddSchemaDotNet(GRS.Features.Concurrency.Backend.DotNet GeneratedCS)
77+
Project_AddDotNetGeneratedMerge(GRS.Features.Concurrency.Backend.DotNet.GenMerge GeneratedCS)
78+
add_subdirectory(DotNet)
7879
endif()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# The MIT License (MIT)
3+
#
4+
# Copyright (c) 2024 Advanced Micro Devices, Inc.,
5+
# Fatalist Development AB (Avalanche Studio Group),
6+
# and Miguel Petersen.
7+
#
8+
# All Rights Reserved.
9+
#
10+
# Permission is hereby granted, free of charge, to any person obtaining a copy
11+
# of this software and associated documentation files (the "Software"), to deal
12+
# in the Software without restriction, including without limitation the rights
13+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14+
# of the Software, and to permit persons to whom the Software is furnished to do so,
15+
# subject to the following conditions:
16+
#
17+
# The above copyright notice and this permission notice shall be included in all
18+
# copies or substantial portions of the Software.
19+
#
20+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23+
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
#
26+
27+
Project_AddSchemaDotNet(
28+
GRS.Features.Concurrency.Backend.DotNet
29+
GRS.Features.Concurrency.Backend.DotNet.GenMerge
30+
GeneratedCS
31+
)

Source/Features/Concurrency/Frontend/UIX/UIX.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<TargetCulture>en</TargetCulture>
66
<Nullable>enable</Nullable>
77
<Configurations>Debug;Release;MinSizeRel;RelWithDebInfo</Configurations>

Source/Features/Descriptor/Backend/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@ Project_AddTest(
7474
#----- .Net bindings -----#
7575

7676
if (${BUILD_UIX})
77-
Project_AddSchemaDotNet(GRS.Features.Descriptor.Backend.DotNet GeneratedCS)
77+
Project_AddDotNetGeneratedMerge(GRS.Features.Descriptor.Backend.DotNet.GenMerge GeneratedCS)
78+
add_subdirectory(DotNet)
7879
endif()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# The MIT License (MIT)
3+
#
4+
# Copyright (c) 2024 Advanced Micro Devices, Inc.,
5+
# Fatalist Development AB (Avalanche Studio Group),
6+
# and Miguel Petersen.
7+
#
8+
# All Rights Reserved.
9+
#
10+
# Permission is hereby granted, free of charge, to any person obtaining a copy
11+
# of this software and associated documentation files (the "Software"), to deal
12+
# in the Software without restriction, including without limitation the rights
13+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14+
# of the Software, and to permit persons to whom the Software is furnished to do so,
15+
# subject to the following conditions:
16+
#
17+
# The above copyright notice and this permission notice shall be included in all
18+
# copies or substantial portions of the Software.
19+
#
20+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23+
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
#
26+
27+
Project_AddSchemaDotNet(
28+
GRS.Features.Descriptor.Backend.DotNet
29+
GRS.Features.Descriptor.Backend.DotNet.GenMerge
30+
GeneratedCS
31+
)

Source/Features/Descriptor/Frontend/UIX/UIX.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<TargetCulture>en</TargetCulture>
66
<Nullable>enable</Nullable>
77
<Configurations>Debug;Release;MinSizeRel;RelWithDebInfo</Configurations>

Source/Features/ExportStability/Backend/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,6 @@ Project_AddTest(
6969
#----- .Net bindings -----#
7070

7171
if (${BUILD_UIX})
72-
Project_AddSchemaDotNet(GRS.Features.ExportStability.Backend.DotNet GeneratedCS)
72+
Project_AddDotNetGeneratedMerge(GRS.Features.ExportStability.Backend.DotNet.GenMerge GeneratedCS)
73+
add_subdirectory(DotNet)
7374
endif()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# The MIT License (MIT)
3+
#
4+
# Copyright (c) 2024 Advanced Micro Devices, Inc.,
5+
# Fatalist Development AB (Avalanche Studio Group),
6+
# and Miguel Petersen.
7+
#
8+
# All Rights Reserved.
9+
#
10+
# Permission is hereby granted, free of charge, to any person obtaining a copy
11+
# of this software and associated documentation files (the "Software"), to deal
12+
# in the Software without restriction, including without limitation the rights
13+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14+
# of the Software, and to permit persons to whom the Software is furnished to do so,
15+
# subject to the following conditions:
16+
#
17+
# The above copyright notice and this permission notice shall be included in all
18+
# copies or substantial portions of the Software.
19+
#
20+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23+
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
#
26+
27+
Project_AddSchemaDotNet(
28+
GRS.Features.ExportStability.Backend.DotNet
29+
GRS.Features.ExportStability.Backend.DotNet.GenMerge
30+
GeneratedCS
31+
)

Source/Features/ExportStability/Frontend/UIX/UIX.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<TargetCulture>en</TargetCulture>
66
<Nullable>enable</Nullable>
77
<Configurations>Debug;Release;MinSizeRel;RelWithDebInfo</Configurations>

Source/Features/Initialization/Backend/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,6 @@ Project_AddTest(
7676
#----- .Net bindings -----#
7777

7878
if (${BUILD_UIX})
79-
Project_AddSchemaDotNet(GRS.Features.Initialization.Backend.DotNet GeneratedCS)
79+
Project_AddDotNetGeneratedMerge(GRS.Features.Initialization.Backend.DotNet.GenMerge GeneratedCS)
80+
add_subdirectory(DotNet)
8081
endif()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# The MIT License (MIT)
3+
#
4+
# Copyright (c) 2024 Advanced Micro Devices, Inc.,
5+
# Fatalist Development AB (Avalanche Studio Group),
6+
# and Miguel Petersen.
7+
#
8+
# All Rights Reserved.
9+
#
10+
# Permission is hereby granted, free of charge, to any person obtaining a copy
11+
# of this software and associated documentation files (the "Software"), to deal
12+
# in the Software without restriction, including without limitation the rights
13+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14+
# of the Software, and to permit persons to whom the Software is furnished to do so,
15+
# subject to the following conditions:
16+
#
17+
# The above copyright notice and this permission notice shall be included in all
18+
# copies or substantial portions of the Software.
19+
#
20+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23+
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
#
26+
27+
Project_AddSchemaDotNet(
28+
GRS.Features.Initialization.Backend.DotNet
29+
GRS.Features.Initialization.Backend.DotNet.GenMerge
30+
GeneratedCS
31+
)

Source/Features/Initialization/Frontend/UIX/UIX.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<TargetCulture>en</TargetCulture>
66
<Nullable>enable</Nullable>
77
<Configurations>Debug;Release;MinSizeRel;RelWithDebInfo</Configurations>

Source/Features/Loop/Backend/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@ Project_AddTest(
7474
#----- .Net bindings -----#
7575

7676
if (${BUILD_UIX})
77-
Project_AddSchemaDotNet(GRS.Features.Loop.Backend.DotNet GeneratedCS)
77+
Project_AddDotNetGeneratedMerge(GRS.Features.Loop.Backend.DotNet.GenMerge GeneratedCS)
78+
add_subdirectory(DotNet)
7879
endif()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# The MIT License (MIT)
3+
#
4+
# Copyright (c) 2024 Advanced Micro Devices, Inc.,
5+
# Fatalist Development AB (Avalanche Studio Group),
6+
# and Miguel Petersen.
7+
#
8+
# All Rights Reserved.
9+
#
10+
# Permission is hereby granted, free of charge, to any person obtaining a copy
11+
# of this software and associated documentation files (the "Software"), to deal
12+
# in the Software without restriction, including without limitation the rights
13+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14+
# of the Software, and to permit persons to whom the Software is furnished to do so,
15+
# subject to the following conditions:
16+
#
17+
# The above copyright notice and this permission notice shall be included in all
18+
# copies or substantial portions of the Software.
19+
#
20+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23+
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24+
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
#
26+
27+
Project_AddSchemaDotNet(
28+
GRS.Features.Loop.Backend.DotNet
29+
GRS.Features.Loop.Backend.DotNet.GenMerge
30+
GeneratedCS
31+
)

Source/Features/Loop/Frontend/UIX/UIX.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<TargetCulture>en</TargetCulture>
66
<Nullable>enable</Nullable>
77
<Configurations>Debug;Release;MinSizeRel;RelWithDebInfo</Configurations>

Source/Features/ResourceBounds/Backend/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,6 @@ Project_AddTest(
7474
#----- .Net bindings -----#
7575

7676
if (${BUILD_UIX})
77-
Project_AddSchemaDotNet(GRS.Features.ResourceBounds.Backend.DotNet GeneratedCS)
77+
Project_AddDotNetGeneratedMerge(GRS.Features.ResourceBounds.Backend.DotNet.GenMerge GeneratedCS)
78+
add_subdirectory(DotNet)
7879
endif()

0 commit comments

Comments
 (0)