BayesNet/CMakeLists.txt

73 lines
2.0 KiB
CMake
Raw Permalink Normal View History

2023-06-29 20:00:41 +00:00
cmake_minimum_required(VERSION 3.20)
2023-07-17 20:51:15 +00:00
project(BayesNet
VERSION 1.0.3
2023-07-17 20:51:15 +00:00
DESCRIPTION "Bayesian Network and basic classifiers Library."
HOMEPAGE_URL "https://github.com/rmontanana/bayesnet"
LANGUAGES CXX
)
if (CODE_COVERAGE AND NOT ENABLE_TESTING)
MESSAGE(FATAL_ERROR "Code coverage requires testing enabled")
endif (CODE_COVERAGE AND NOT ENABLE_TESTING)
2023-06-29 20:00:41 +00:00
find_package(Torch REQUIRED)
if (POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
2023-06-29 20:00:41 +00:00
endif ()
2023-07-17 20:51:15 +00:00
# Global CMake variables
# ----------------------
2023-06-29 20:00:41 +00:00
set(CMAKE_CXX_STANDARD 17)
2023-07-17 20:51:15 +00:00
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2023-06-29 20:00:41 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
2023-11-08 17:45:35 +00:00
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
2023-07-17 20:51:15 +00:00
# Options
# -------
option(ENABLE_CLANG_TIDY "Enable to add clang tidy." OFF)
option(ENABLE_TESTING "Unit testing build" OFF)
option(CODE_COVERAGE "Collect coverage from test library" OFF)
2023-11-12 21:14:29 +00:00
2023-07-18 09:20:40 +00:00
# CMakes modules
# --------------
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
2023-07-20 16:55:56 +00:00
include(AddGitSubmodule)
2023-11-08 17:45:35 +00:00
if (CODE_COVERAGE)
enable_testing()
include(CodeCoverage)
MESSAGE("Code coverage enabled")
2023-09-03 12:07:11 +00:00
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -O0 -g")
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)
2023-07-20 16:55:56 +00:00
# External libraries - dependencies of BayesNet
# ---------------------------------------------
# include(FetchContent)
add_git_submodule("lib/mdlp")
add_git_submodule("lib/json")
2023-10-11 09:33:29 +00:00
2023-07-17 20:51:15 +00:00
# Subdirectories
# --------------
add_subdirectory(config)
2023-07-20 16:55:56 +00:00
add_subdirectory(lib/Files)
add_subdirectory(src)
2023-07-17 20:51:15 +00:00
file(GLOB BayesNet_SOURCES CONFIGURE_DEPENDS ${BayesNet_SOURCE_DIR}/src/*.cc)
2023-07-17 20:51:15 +00:00
# Testing
# -------
if (ENABLE_TESTING)
2023-07-18 09:20:40 +00:00
MESSAGE("Testing enabled")
2023-09-03 12:07:11 +00:00
add_git_submodule("lib/catch2")
2023-07-17 20:51:15 +00:00
include(CTest)
add_subdirectory(tests)
2023-07-20 21:55:01 +00:00
endif (ENABLE_TESTING)