From e5af2bb6e8773060a959343039acac7987afaa86 Mon Sep 17 00:00:00 2001
From: AnonymusRaccoon
Date: Thu, 23 Jan 2020 10:30:14 +0100
Subject: [PATCH] Remaking the Cmake and the CI to clean up
---
.github/workflows/build.yml | 4 ++--
.github/workflows/test.yml | 6 +++---
CMakeLists.txt | 18 +++++++-----------
sources/main.cpp => main.cpp | 0
4 files changed, 12 insertions(+), 16 deletions(-)
rename sources/main.cpp => main.cpp (100%)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index dc6fc79..07ac030 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -12,9 +12,9 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Build Makefile with CMake
- run: cmake .
+ run: cmake -S . -B build
- name: Build with Makefile
- run: make
+ run: make -C build ComSquare
- name: Archive production artifact
uses: actions/upload-artifact@v1
with:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 396cc05..a583351 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -22,11 +22,11 @@ jobs:
- name: Install Gcovr
run: python -m pip install --upgrade pip gcovr
- name: Build Makefile with CMake
- run: cmake -DTEST=on .
+ run: cmake -S . -B build
- name: Build with Makefile
- run: make
+ run: make -C build unit_tests
- name: Execute tests
- run: ./unit_tests
+ run: .build/unit_tests
- name: Output coverage
run: gcovr -e tests/ -o coverage.xml --xml
- name: Publish to CodeCov
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 32da58f..bda854b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,16 +7,12 @@ project(ComSquare)
# show compilation warnings
add_compile_options(-W -Wall -Wextra -Wshadow)
-if (TEST)
- # make unit tests
- add_executable(unit_tests sources/hello.cpp tests/hello.cpp)
+# make unit tests
+add_executable(unit_tests sources/hello.cpp tests/hello.cpp)
- # include criterion & coverage
- target_link_libraries(unit_tests criterion -lgcov)
- target_compile_options(unit_tests PUBLIC -fprofile-arcs -ftest-coverage -g -O0)
+# include criterion & coverage
+target_link_libraries(unit_tests criterion -lgcov)
+target_compile_options(unit_tests PUBLIC -fprofile-arcs -ftest-coverage)
-else (TEST)
- # make app
- add_executable(ComSquare sources/main.cpp sources/hello.cpp)
-
-endif (TEST)
+# make app
+add_executable(ComSquare main.cpp sources/hello.cpp)
diff --git a/sources/main.cpp b/main.cpp
similarity index 100%
rename from sources/main.cpp
rename to main.cpp