BayesNet/CMakeLists.txt

109 lines
3.3 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
2024-06-09 15:19:38 +00:00
VERSION 1.0.6
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")
2024-07-11 10:29:57 +00:00
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast")
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-default-inline")
endif()
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")
2024-11-20 20:02:56 +00:00
get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
message(STATUS "Languages=${LANGUAGES}")
if (CODE_COVERAGE)
enable_testing()
include(CodeCoverage)
2024-11-20 20:02:56 +00:00
MESSAGE(STATUS "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
# ---------------------------------------------
2024-11-20 20:02:56 +00:00
2023-07-20 16:55:56 +00:00
# include(FetchContent)
add_git_submodule("lib/json")
add_git_submodule("lib/mdlp")
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)
2024-11-20 20:02:56 +00:00
MESSAGE(STATUS "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-05-22 08:17:49 +00:00
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h DESTINATION include/bayesnet CONFIGURATIONS Release)
# Documentation
# -------------
2024-05-23 17:34:48 +00:00
find_package(Doxygen)
2024-09-29 10:48:15 +00:00
if (Doxygen_FOUND)
set(DOC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs)
set(doxyfile_in ${DOC_DIR}/Doxyfile.in)
set(doxyfile ${DOC_DIR}/Doxyfile)
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
doxygen_add_docs(doxygen
WORKING_DIRECTORY ${DOC_DIR}
CONFIG_FILE ${doxyfile})
2024-09-29 10:48:15 +00:00
else (Doxygen_FOUND)
MESSAGE("* Doxygen not found")
endif (Doxygen_FOUND)