Skip to content

Commit 7ea61f6

Browse files
authored
Merge pull request #21 from YassinLokhat/20-add-cmake
20 add cmake
2 parents cccaa4d + aa74b5d commit 7ea61f6

15 files changed

Lines changed: 138 additions & 111 deletions

.github/workflows/csharp-cmake.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: C# Build with CMake
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
build:
11+
#strategy:
12+
# matrix:
13+
# os: [ubuntu-latest, windows-latest]
14+
#
15+
#runs-on: ${{ matrix.os }}
16+
runs-on: windows-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Setup .NET
21+
uses: actions/setup-dotnet@v4
22+
with:
23+
dotnet-version: 8.0.x
24+
25+
- name: Install CMake
26+
uses: lukka/get-cmake@latest
27+
28+
- name: Create Build Directory
29+
run: mkdir -p build
30+
31+
- name: Configure CMake
32+
run: cmake -S . -B build
33+
34+
- name: Build
35+
run: cmake --build build --config Release
36+
37+
- name: Restore dependencies
38+
run: dotnet restore build/Upsilon.Apps.Passkey.Core.sln
39+
40+
- name: Build
41+
run: dotnet build --no-restore build/Upsilon.Apps.Passkey.Core.sln
42+
43+
- name: Test
44+
run: dotnet test --no-build --verbosity normal build/Upsilon.Apps.Passkey.Core.sln
45+
46+
permissions:
47+
contents: read
48+
issues: write
49+
pull-requests: write

.github/workflows/dotnet.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ _ReSharper*/
3030
.vs/
3131
#Nuget packages folder
3232
packages/
33+
build

CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(Upsilon.Apps.Passkey.Core VERSION 1.0.0 LANGUAGES CSharp)
3+
4+
# Ensure .NET 8.0 is used
5+
set(CMAKE_DOTNET_TARGET_FRAMEWORK "net8.0")
6+
set(CMAKE_DOTNET_SDK "Microsoft.NET.Sdk")
7+
8+
set(CMAKE_SUPPRESS_REGENERATION ON)
9+
10+
set(CMAKE_CSharp_FLAGS_DEBUG "/warn:9999" CACHE STRING "" FORCE)
11+
set(CMAKE_CSharp_FLAGS_RELEASE "/warn:9999" CACHE STRING "" FORCE)
12+
13+
# Main library project
14+
add_subdirectory(Core)
15+
16+
# Unit tests project
17+
add_subdirectory(UnitTests)

Core/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(Core LANGUAGES CSharp)
3+
4+
# Main library project
5+
file(GLOB_RECURSE SRC_FILES
6+
"${CMAKE_CURRENT_SOURCE_DIR}/*.cs"
7+
)
8+
file(GLOB_RECURSE EXCLUDED_FILES
9+
"${CMAKE_CURRENT_SOURCE_DIR}/obj/*"
10+
"${CMAKE_CURRENT_SOURCE_DIR}/bin/*"
11+
)
12+
if(EXCLUDED_FILES)
13+
list(REMOVE_ITEM SRC_FILES ${EXCLUDED_FILES})
14+
endif()
15+
16+
add_library(Core SHARED
17+
${SRC_FILES}
18+
)
19+
20+
# Set properties for the library
21+
set_target_properties(Core PROPERTIES
22+
DOTNET_SDK "${CMAKE_DOTNET_SDK}"
23+
DOTNET_TARGET_FRAMEWORK "${CMAKE_DOTNET_TARGET_FRAMEWORK}"
24+
25+
VS_GLOBAL_ImplicitUsings "enable"
26+
VS_GLOBAL_Nullable "enable"
27+
VS_GLOBAL_Title "$(AssemblyName)"
28+
VS_GLOBAL_Authors "Yassin Lokhat"
29+
VS_GLOBAL_Configurations "Debug;Release"
30+
VS_GLOBAL_Description "A local stored Password Manager Core."
31+
VS_GLOBAL_Version "1.0.0"
32+
VS_GLOBAL_TreatWarningsAsErrors "True"
33+
VS_GLOBAL_WarningLevel "9999"
34+
)

Core/Upsilon.Apps.PassKey.Core.csproj

Lines changed: 0 additions & 26 deletions
This file was deleted.

UnitTests/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(UnitTests LANGUAGES CSharp)
3+
4+
# Unit tests project
5+
file(GLOB_RECURSE SRC_FILES
6+
"${CMAKE_CURRENT_SOURCE_DIR}/*.cs"
7+
)
8+
file(GLOB_RECURSE EXCLUDED_FILES
9+
"${CMAKE_CURRENT_SOURCE_DIR}/obj/*"
10+
"${CMAKE_CURRENT_SOURCE_DIR}/bin/*"
11+
)
12+
if(EXCLUDED_FILES)
13+
list(REMOVE_ITEM SRC_FILES ${EXCLUDED_FILES})
14+
endif()
15+
16+
add_executable(UnitTests
17+
${SRC_FILES}
18+
)
19+
20+
# Set properties for the test project
21+
set_target_properties(UnitTests PROPERTIES
22+
DOTNET_SDK "${CMAKE_DOTNET_SDK}"
23+
DOTNET_TARGET_FRAMEWORK "${CMAKE_DOTNET_TARGET_FRAMEWORK}"
24+
VS_PACKAGE_REFERENCES "FluentAssertions_7.0.0;Microsoft.NET.Test.Sdk_17.11.1;MSTest_3.6.1"
25+
VS_GLOBAL_ImplicitUsings "enable"
26+
)
27+
28+
# Add reference from tests to core library
29+
target_link_libraries(UnitTests Core)

UnitTests/MSTestSettings.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
3+
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]

UnitTests/Models/AccountUnitTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using FluentAssertions;
22
using Upsilon.Apps.PassKey.Core.Public.Enums;
33
using Upsilon.Apps.PassKey.Core.Public.Interfaces;
4+
using Microsoft.VisualStudio.TestTools.UnitTesting;
45

56
namespace Upsilon.Apps.PassKey.UnitTests.Models
67
{

UnitTests/Models/DatabaseUnitTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using FluentAssertions;
22
using Upsilon.Apps.PassKey.Core.Public.Interfaces;
3+
using Microsoft.VisualStudio.TestTools.UnitTesting;
34

45
namespace Upsilon.Apps.PassKey.UnitTests.Models
56
{

0 commit comments

Comments
 (0)