Skip to content

Commit 5eaf36c

Browse files
authored
Merge pull request #109 from smasherprog/UpdateNetBuild
adding more configuration options
2 parents b147bce + bf02734 commit 5eaf36c

6 files changed

+34
-13
lines changed

Example_CSharp/CMakeLists.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ execute_process(COMMAND dotnet --version
1010
if(result)
1111
message(WARNING "CMake failed: dotnet executable not found but by this build. You must install dotnet to generate csharp bindings")
1212
else()
13+
set(PLATFORM x64)
14+
if(NOT DEFINED CMAKE_GENERATOR_PLATFORM)
15+
set(PLATFORM x64)
16+
elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32")
17+
set(PLATFORM x86)
18+
ENDIF()
1319
message(STATUS "Found dotnet executable CSHARP bindings will be generated!")
1420
add_custom_command(OUTPUT ${OUTPUT}
1521
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:screen_capture_lite_shared> ${CMAKE_CURRENT_LIST_DIR}
@@ -20,8 +26,8 @@ else()
2026
COMMAND ${CMAKE_COMMAND} -E copy
2127
${CMAKE_CURRENT_LIST_DIR}/Program.cs
2228
${CMAKE_BINARY_DIR}/Example_CSharp
23-
COMMAND dotnet build --configuration ${CMAKE_BUILD_TYPE} ${CMAKE_BINARY_DIR}/Example_CSharp/${CSPROJ} -o ${CMAKE_BINARY_DIR}
24-
COMMENT "Building DOTNET Example ${CMAKE_BINARY_DIR}/${OUTPUT}"
29+
COMMAND dotnet build --configuration ${CMAKE_BUILD_TYPE} /p:Platform=${PLATFORM} ${CMAKE_BINARY_DIR}/Example_CSharp/${CSPROJ} -o ${CMAKE_BINARY_DIR}
30+
COMMENT "Building ${PROJECT_NAME} dotnet build --configuration ${CMAKE_BUILD_TYPE} /p:Platform=${PLATFORM} ${CMAKE_BINARY_DIR}/Example_CSharp/${CSPROJ} -o ${CMAKE_BINARY_DIR}"
2531
)
2632
add_custom_target(${PROJECT_NAME} ALL DEPENDS ${OUTPUT})
2733
add_dependencies(${PROJECT_NAME} screen_capture_lite_csharp)

Example_CSharp/screen_capture_lite_example_csharp.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net5.0</TargetFramework>
6-
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
6+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
7+
<Platforms>x64;x86</Platforms>
78
</PropertyGroup>
89

910
<ItemGroup>

Example_CSharp/screen_capture_lite_example_csharp.sln

+12-6
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "screen_capture_lite_example
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10-
Debug|Any CPU = Debug|Any CPU
11-
Release|Any CPU = Release|Any CPU
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
1214
EndGlobalSection
1315
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Release|Any CPU.Build.0 = Release|Any CPU
16+
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Debug|x64.ActiveCfg = Debug|x64
17+
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Debug|x64.Build.0 = Debug|x64
18+
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Debug|x86.ActiveCfg = Debug|x86
19+
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Debug|x86.Build.0 = Debug|x86
20+
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Release|x64.ActiveCfg = Release|x64
21+
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Release|x64.Build.0 = Release|x64
22+
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Release|x86.ActiveCfg = Release|x86
23+
{24D20C01-8959-4C09-99A0-9AD0681E1B53}.Release|x86.Build.0 = Release|x86
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

azure-devops/build-windows.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- task: CMake@1
1212
inputs:
13-
cmakeArgs: '.. -G"Visual Studio 16 2019" -A ${{ parameters.targetPlatform }} -DCMAKE_INSTALL_PREFIX=./output'
13+
cmakeArgs: '.. -G"Visual Studio 16 2019" -DCMAKE_GENERATOR_PLATFORM=${{ parameters.targetPlatform }} -A ${{ parameters.targetPlatform }} -DCMAKE_INSTALL_PREFIX=./output'
1414
- task: CMake@1
1515
inputs:
1616
cmakeArgs: '--build . --target INSTALL'

src_csharp/CMakeLists.txt

+10-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ execute_process(COMMAND dotnet --version
99
ERROR_QUIET)
1010
if(result)
1111
message(WARNING "CMake failed: dotnet executable not found but by this build. You must install dotnet to generate csharp bindings")
12-
else()
12+
else()
13+
set(PLATFORM x64)
14+
if(NOT DEFINED CMAKE_GENERATOR_PLATFORM)
15+
set(PLATFORM x64)
16+
elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32")
17+
set(PLATFORM x86)
18+
ENDIF()
19+
1320
message(STATUS "Found dotnet executable CSHARP bindings will be generated!")
1421
add_custom_command(OUTPUT ${OUTPUT}
1522
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:screen_capture_lite_shared> ${CMAKE_CURRENT_LIST_DIR}
@@ -20,8 +27,8 @@ else()
2027
COMMAND ${CMAKE_COMMAND} -E copy
2128
${CMAKE_CURRENT_LIST_DIR}/Screen_Capture_Lite.cs
2229
${CMAKE_BINARY_DIR}/src_csharp
23-
COMMAND dotnet build --configuration ${CMAKE_BUILD_TYPE} ${CMAKE_BINARY_DIR}/src_csharp/${CSPROJ} -o ${CMAKE_BINARY_DIR}
24-
COMMENT "Building DOTNET assembly ${CMAKE_BINARY_DIR}/${OUTPUT}"
30+
COMMAND dotnet build --configuration ${CMAKE_BUILD_TYPE} /p:Platform=${PLATFORM} ${CMAKE_BINARY_DIR}/src_csharp/${CSPROJ} -o ${CMAKE_BINARY_DIR}
31+
COMMENT "Building ${PROJECT_NAME} dotnet build --configuration ${CMAKE_BUILD_TYPE} /p:Platform=${PLATFORM} ${CMAKE_BINARY_DIR}/src_csharp/${CSPROJ} -o ${CMAKE_BINARY_DIR}"
2532
)
2633

2734
add_custom_target(${PROJECT_NAME} ALL DEPENDS ${OUTPUT})

src_csharp/screen_capture_lite_csharp.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5+
<Platforms>x64;x86</Platforms>
56
</PropertyGroup>
67

78
</Project>

0 commit comments

Comments
 (0)