BayesNet/CMakeLists.txt

89 lines
2.7 KiB
CMake
Raw 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.5.1
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")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -fno-elide-constructors -fno-default-inline -ftest-coverage -O0 -g")
2024-03-19 16:24:21 +00:00
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
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)
2024-03-07 23:37:36 +00:00
option(INSTALL_GTEST "Enable installation of googletest." 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
2024-02-27 09:16:20 +00:00
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
MESSAGE("Debug mode")
set(ENABLE_TESTING ON)
set(CODE_COVERAGE ON)
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (CODE_COVERAGE)
enable_testing()
include(CodeCoverage)
MESSAGE("Code coverage enabled")
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/json")
add_git_submodule("lib/mdlp")
add_subdirectory("lib/Files")
2023-10-11 09:33:29 +00:00
2023-07-17 20:51:15 +00:00
# Subdirectories
# --------------
add_subdirectory(config)
2024-03-08 21:20:54 +00:00
add_subdirectory(bayesnet)
2023-07-17 20:51:15 +00:00
# Testing
# -------
if (ENABLE_TESTING)
MESSAGE("Testing enabled")
add_subdirectory(tests/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)
2024-03-07 23:37:36 +00:00
# Installation
# ------------
install(TARGETS BayesNet
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
CONFIGURATIONS Release)
2024-03-08 21:20:54 +00:00
install(DIRECTORY bayesnet/ DESTINATION include/bayesnet FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h")
2024-03-09 11:27:05 +00:00
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h DESTINATION include/bayesnet CONFIGURATIONS Release)