Skip to content

Commit eda7d52

Browse files
authored
Initial commit
0 parents  commit eda7d52

23 files changed

+1274
-0
lines changed

.github/workflows/ci_tests.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: "CI tests"
2+
3+
on: [ push, workflow_dispatch ]
4+
5+
jobs:
6+
build-mingw:
7+
name: Tests and application run on Windows Latest MinGW
8+
runs-on: windows-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Create CMake cache
14+
run: |
15+
cmake -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles"
16+
cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles"
17+
18+
- name: Build main target
19+
shell: bash
20+
run: |
21+
cmake --build cmake-build-release --target cpp_tests || echo Built with errors
22+
23+
- name: Build tests target
24+
shell: bash
25+
run: |
26+
cmake --build cmake-build-debug --target cpp_tests_tests || echo Built with errors
27+
28+
- name: Run program
29+
working-directory: .\cmake-build-release
30+
run: |
31+
.\cpp_tests.exe --help
32+
33+
- name: Run tests
34+
working-directory: .\cmake-build-debug
35+
run: |
36+
echo "Currently unable to run tests on Windows Latest MinGW. See https://gitmemories.com/cristianadam/HelloWorld/issues/12 and https://github.com/microsoft/vscode-cmake-tools/issues/2451"
37+
% .\cpp_tests_tests.exe
38+
39+
build-matrix:
40+
name: Tests and application run on ${{ matrix.config.name }}
41+
runs-on: ${{ matrix.config.os }}
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
config:
46+
- {
47+
name: "Windows Latest MSVC", artifact: "Windows-MSVC.tar.xz",
48+
os: windows-latest,
49+
build_type: "Release", cc: "cl", cxx: "cl",
50+
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
51+
}
52+
- {
53+
name: "Ubuntu Latest GCC", artifact: "Linux.tar.xz",
54+
os: ubuntu-latest,
55+
build_type: "Release", cc: "gcc", cxx: "g++"
56+
}
57+
- {
58+
name: "macOS Latest Clang", artifact: "macOS.tar.xz",
59+
os: macos-latest,
60+
build_type: "Release", cc: "clang", cxx: "clang++"
61+
}
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- name: Create CMake cache
67+
shell: bash
68+
run: |
69+
cmake -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release
70+
cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug
71+
72+
- name: Build main target
73+
shell: bash
74+
run: |
75+
cmake --build cmake-build-release --target cpp_tests || echo "Built with errors"
76+
77+
- name: Build tests target
78+
shell: bash
79+
run: |
80+
cmake --build cmake-build-debug --target cpp_tests_tests || echo "Built with errors"
81+
82+
- name: Run program
83+
shell: bash
84+
working-directory: ./cmake-build-release
85+
run: |
86+
if [ "$RUNNER_OS" == "Windows" ]; then
87+
./cpp_tests.exe --help
88+
else
89+
cd bin
90+
./cpp_tests --help
91+
fi
92+
93+
- name: Run tests
94+
shell: bash
95+
working-directory: ./cmake-build-debug
96+
run: |
97+
if [ "$RUNNER_OS" == "Windows" ]; then
98+
./cpp_tests_tests.exe
99+
else
100+
cd tests
101+
./cpp_tests_tests
102+
fi
103+
104+
memory-leaks:
105+
name: Find memory leaks in tests
106+
runs-on: ubuntu-latest
107+
steps:
108+
- uses: actions/checkout@v4
109+
110+
- name: Install valgrind
111+
run: |
112+
sudo apt-get update && sudo apt-get -y install valgrind
113+
114+
- name: Create CMake cache
115+
run: |
116+
cmake -S . -B cmake-build -DCMAKE_BUILD_TYPE=Debug
117+
118+
- name: Build tests target
119+
run: |
120+
cmake --build cmake-build --target cpp_tests_tests
121+
122+
- name: Run valgrind
123+
working-directory: ./cmake-build/tests
124+
run: |
125+
valgrind --leak-check=full --track-origins=yes --error-exitcode=1 ./cpp_tests_tests

.gitignore

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# CMake
2+
**cmake-build*/
3+
4+
# All idea files
5+
**.idea*/
6+
7+
# File-based project format
8+
*.iws
9+
10+
# IntelliJ
11+
**out/
12+
13+
# mpeltonen/sbt-idea plugin
14+
**.idea_modules/
15+
16+
# JIRA plugin
17+
atlassian-ide-plugin.xml
18+
19+
# Crashlytics plugin (for Android Studio and IntelliJ)
20+
com_crashlytics_export_strings.xml
21+
crashlytics.properties
22+
crashlytics-build.properties
23+
fabric.properties
24+
25+
# Prerequisites
26+
*.d
27+
28+
# Compiled Object files
29+
*.slo
30+
*.lo
31+
*.o
32+
*.obj
33+
34+
# Precompiled Headers
35+
*.gch
36+
*.pch
37+
38+
# Compiled Dynamic libraries
39+
*.so
40+
*.dylib
41+
*.dll
42+
43+
# Fortran module files
44+
*.mod
45+
*.smod
46+
47+
# Compiled Static libraries
48+
*.lai
49+
*.la
50+
*.a
51+
*.lib
52+
53+
# Executables
54+
*.exe
55+
*.out
56+
*.app

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.12)
2+
3+
project(
4+
cpp_tests # Rename the project here and in ci_tests.yml
5+
VERSION 0.1
6+
DESCRIPTION "C++ Project with Google tests"
7+
LANGUAGES CXX
8+
)
9+
10+
set(CMAKE_CXX_STANDARD 20)
11+
12+
if (WIN32) # Install dlls in the same directory as the executable on Windows
13+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
14+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
15+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
16+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
17+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
18+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
19+
endif ()
20+
21+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
22+
set(CMAKE_CXX_FLAGS_DEBUG "/MDd")
23+
set(CMAKE_CXX_FLAGS_RELEASE "/O2")
24+
else ()
25+
set(CMAKE_CXX_FLAGS_DEBUG "-g")
26+
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
27+
endif ()
28+
29+
add_subdirectory(lib)
30+
add_subdirectory(bin)
31+
32+
33+
enable_testing()
34+
add_subdirectory(tests)

0 commit comments

Comments
 (0)