BayesNet/CMakeLists.txt

106 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
2023-09-02 11:58:12 +00:00
VERSION 0.2.0
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-12-11 08:06:05 +00:00
option(MPI_ENABLED "Enable MPI options" ON)
if (MPI_ENABLED)
find_package(MPI REQUIRED)
message("MPI_CXX_LIBRARIES=${MPI_CXX_LIBRARIES}")
message("MPI_CXX_INCLUDE_DIRS=${MPI_CXX_INCLUDE_DIRS}")
endif (MPI_ENABLED)
# Boost Library
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
2023-11-12 21:14:29 +00:00
find_package(Boost 1.66.0 REQUIRED COMPONENTS python3 numpy3)
if(Boost_FOUND)
message("Boost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS}")
include_directories(${Boost_INCLUDE_DIRS})
endif()
2023-11-12 21:14:29 +00:00
# Python
find_package(Python3 3.11...3.11.9 COMPONENTS Interpreter Development REQUIRED)
message("Python3_LIBRARIES=${Python3_LIBRARIES}")
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/argparse")
add_git_submodule("lib/json")
2023-10-11 09:33:29 +00:00
2023-10-15 09:19:58 +00:00
find_library(XLSXWRITER_LIB NAMES libxlsxwriter.dylib libxlsxwriter.so PATHS ${BayesNet_SOURCE_DIR}/lib/libxlsxwriter/lib)
message("XLSXWRITER_LIB=${XLSXWRITER_LIB}")
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/BayesNet)
add_subdirectory(src/Platform)
2023-11-12 21:14:29 +00:00
add_subdirectory(src/PyClassifiers)
2023-07-17 20:51:15 +00:00
add_subdirectory(sample)
file(GLOB BayesNet_HEADERS CONFIGURE_DEPENDS ${BayesNet_SOURCE_DIR}/src/BayesNet/*.h ${BayesNet_SOURCE_DIR}/BayesNet/*.h)
file(GLOB BayesNet_SOURCES CONFIGURE_DEPENDS ${BayesNet_SOURCE_DIR}/src/BayesNet/*.cc ${BayesNet_SOURCE_DIR}/src/BayesNet/*.cpp)
file(GLOB Platform_SOURCES CONFIGURE_DEPENDS ${BayesNet_SOURCE_DIR}/src/Platform/*.cc ${BayesNet_SOURCE_DIR}/src/Platform/*.cpp)
2023-07-17 20:51:15 +00:00
# Testing
# -------
2023-07-17 20:51:15 +00:00
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)