Update Makefile to add Release & Debug build
This commit is contained in:
parent
285f0938a6
commit
f63a9a64f9
@ -7,10 +7,14 @@ project(BayesNet
|
|||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (CODE_COVERAGE AND NOT ENABLE_TESTING)
|
||||||
|
MESSAGE(FATAL_ERROR "Code coverage requires testing enabled")
|
||||||
|
endif (CODE_COVERAGE AND NOT ENABLE_TESTING)
|
||||||
|
|
||||||
find_package(Torch REQUIRED)
|
find_package(Torch REQUIRED)
|
||||||
|
|
||||||
if (POLICY CMP0135)
|
if (POLICY CMP0135)
|
||||||
cmake_policy(SET CMP0135 NEW)
|
cmake_policy(SET CMP0135 NEW)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Global CMake variables
|
# Global CMake variables
|
||||||
@ -24,24 +28,31 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
|
|||||||
# Options
|
# Options
|
||||||
# -------
|
# -------
|
||||||
option(ENABLE_CLANG_TIDY "Enable to add clang tidy." OFF)
|
option(ENABLE_CLANG_TIDY "Enable to add clang tidy." OFF)
|
||||||
option(ENABLE_TESTING "Unit testing build" ON)
|
option(ENABLE_TESTING "Unit testing build" OFF)
|
||||||
option(CODE_COVERAGE "Collect coverage from test library" ON)
|
option(CODE_COVERAGE "Collect coverage from test library" OFF)
|
||||||
|
|
||||||
set(CMAKE_BUILD_TYPE "Debug")
|
|
||||||
|
|
||||||
# CMakes modules
|
# CMakes modules
|
||||||
# --------------
|
# --------------
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
include(AddGitSubmodule)
|
include(AddGitSubmodule)
|
||||||
include(StaticAnalyzers) # clang-tidy
|
if (CODE_COVERAGE)
|
||||||
include(CodeCoverage)
|
enable_testing()
|
||||||
|
include(CodeCoverage)
|
||||||
|
MESSAGE("Code coverage enabled")
|
||||||
|
set(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||||
|
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
||||||
|
SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
||||||
|
endif (CODE_COVERAGE)
|
||||||
|
|
||||||
|
if (ENABLE_CLANG_TIDY)
|
||||||
|
include(StaticAnalyzers) # clang-tidy
|
||||||
|
endif (ENABLE_CLANG_TIDY)
|
||||||
|
|
||||||
# External libraries - dependencies of BayesNet
|
# External libraries - dependencies of BayesNet
|
||||||
# ---------------------------------------------
|
# ---------------------------------------------
|
||||||
# include(FetchContent)
|
# include(FetchContent)
|
||||||
add_git_submodule("lib/mdlp")
|
add_git_submodule("lib/mdlp")
|
||||||
add_git_submodule("lib/catch2")
|
|
||||||
add_git_submodule("lib/argparse")
|
add_git_submodule("lib/argparse")
|
||||||
add_git_submodule("lib/json")
|
add_git_submodule("lib/json")
|
||||||
|
|
||||||
@ -59,18 +70,11 @@ file(GLOB Platform_SOURCES CONFIGURE_DEPENDS ${BayesNet_SOURCE_DIR}/src/Platform
|
|||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
# -------
|
# -------
|
||||||
|
|
||||||
if (ENABLE_TESTING)
|
if (ENABLE_TESTING)
|
||||||
MESSAGE("Testing enabled")
|
MESSAGE("Testing enabled")
|
||||||
enable_testing()
|
add_git_submodule("lib/catch2")
|
||||||
if (CODE_COVERAGE)
|
|
||||||
#include(CodeCoverage)
|
|
||||||
MESSAGE("Code coverage enabled")
|
|
||||||
set(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
||||||
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
|
|
||||||
SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
|
||||||
endif (CODE_COVERAGE)
|
|
||||||
#find_package(Catch2 3 REQUIRED)
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
#include(Catch)
|
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif (ENABLE_TESTING)
|
endif (ENABLE_TESTING)
|
||||||
|
18
Makefile
18
Makefile
@ -14,16 +14,22 @@ setup: ## Install dependencies for tests and coverage
|
|||||||
dependency: ## Create a dependency graph diagram of the project (build/dependency.png)
|
dependency: ## Create a dependency graph diagram of the project (build/dependency.png)
|
||||||
cd build && cmake .. --graphviz=dependency.dot && dot -Tpng dependency.dot -o dependency.png
|
cd build && cmake .. --graphviz=dependency.dot && dot -Tpng dependency.dot -o dependency.png
|
||||||
|
|
||||||
build: ## Build the project
|
debug: ## Build the project
|
||||||
@echo ">>> Building BayesNet ...";
|
@echo ">>> Building Debug BayesNet ...";
|
||||||
@if [ -d ./build ]; then rm -rf ./build; fi
|
@if [ -d ./build ]; then rm -rf ./build; fi
|
||||||
@mkdir build;
|
@mkdir build;
|
||||||
cmake -S . -B build; \
|
cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON; \
|
||||||
cd build; \
|
cmake --build build -j 32;
|
||||||
make; \
|
|
||||||
|
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
release:
|
||||||
|
@echo ">>> Building Release BayesNet ...";
|
||||||
|
@if [ -d ./build ]; then rm -rf ./build; fi
|
||||||
|
@mkdir build;
|
||||||
|
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release; \
|
||||||
|
cmake --build build -t main -j 32;
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
test: ## Run tests
|
test: ## Run tests
|
||||||
@echo "* Running tests...";
|
@echo "* Running tests...";
|
||||||
find . -name "*.gcda" -print0 | xargs -0 rm
|
find . -name "*.gcda" -print0 | xargs -0 rm
|
||||||
|
Loading…
Reference in New Issue
Block a user