diff --git a/CHANGELOG.md b/CHANGELOG.md
index 59f08a4..c5efcdb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Internal
-- Add changes to .clang-format to ajust to vscode format style thanks to
+- Add changes to .clang-format to adjust to vscode format style thanks to
- Remove all the dependencies as git submodules and add them as vcpkg dependencies.
- Fix the dependencies versions for this specific BayesNet version.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5212607..c2ca40a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,21 +1,19 @@
-cmake_minimum_required(VERSION 3.20)
+cmake_minimum_required(VERSION 3.27)
-project(BayesNet
- VERSION 1.1.0
+project(bayesnet
+ VERSION 1.1.1
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)
+set(CMAKE_CXX_STANDARD 17)
+cmake_policy(SET CMP0135 NEW)
-find_package(Torch REQUIRED)
-
-if (POLICY CMP0135)
- cmake_policy(SET CMP0135 NEW)
-endif ()
+find_package(Torch CONFIG REQUIRED)
+find_package(fimdlp CONFIG REQUIRED)
+find_package(nlohmann_json CONFIG REQUIRED)
+find_package(folding CONFIG REQUIRED)
# Global CMake variables
# ----------------------
@@ -33,76 +31,83 @@ endif()
# 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)
-option(INSTALL_GTEST "Enable installation of googletest." OFF)
+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)
+option(INSTALL_GTEST "Enable installation of googletest" OFF)
-# CMakes modules
-# --------------
-set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
-
-if (CMAKE_BUILD_TYPE STREQUAL "Debug")
- MESSAGE("Debug mode")
- set(ENABLE_TESTING ON)
- set(CODE_COVERAGE ON)
-endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
-
-get_property(LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
-message(STATUS "Languages=${LANGUAGES}")
-if (CODE_COVERAGE)
- enable_testing()
- include(CodeCoverage)
- MESSAGE(STATUS "Code coverage enabled")
- SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
-endif (CODE_COVERAGE)
+add_subdirectory(config)
if (ENABLE_CLANG_TIDY)
- include(StaticAnalyzers) # clang-tidy
+ include(StaticAnalyzers) # clang-tidy
endif (ENABLE_CLANG_TIDY)
-# External libraries - dependencies of BayesNet
-# ---------------------------------------------
+# Add the library
+# ---------------
+include_directories(
+ ${bayesnet_SOURCE_DIR}
+ ${CMAKE_BINARY_DIR}/configured_files/include
+)
-find_package(Torch CONFIG REQUIRED)
-find_package(fimdlp CONFIG REQUIRED)
-find_package(nlohmann_json CONFIG REQUIRED)
-find_package(folding CONFIG REQUIRED)
+file(GLOB_RECURSE Sources "bayesnet/*.cc")
-# Subdirectories
-# --------------
-add_subdirectory(config)
-add_subdirectory(bayesnet)
+add_library(bayesnet ${Sources})
+target_link_libraries(bayesnet fimdlp::fimdlp folding::folding "${TORCH_LIBRARIES}")
# Testing
# -------
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ MESSAGE("Debug mode")
+ set(ENABLE_TESTING ON)
+ set(CODE_COVERAGE ON)
+endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
if (ENABLE_TESTING)
-MESSAGE(STATUS "Testing enabled")
- find_package(Catch2 CONFIG REQUIRED)
- include(CTest)
- add_subdirectory(tests)
+ MESSAGE(STATUS "Testing enabled")
+ find_package(Catch2 CONFIG REQUIRED)
+ find_package(arff-files CONFIG REQUIRED)
+ enable_testing()
+ include(CTest)
+ add_subdirectory(tests)
+else(ENABLE_TESTING)
+ message("Release mode")
endif (ENABLE_TESTING)
# Installation
# ------------
-install(TARGETS BayesNet
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfigVersion.cmake"
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
+
+configure_package_config_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/bayesnetConfig.cmake.in
+ "${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfig.cmake"
+ INSTALL_DESTINATION share/bayesnet)
+
+install(TARGETS bayesnet
+ EXPORT bayesnetTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
CONFIGURATIONS Release)
-install(DIRECTORY bayesnet/ DESTINATION include/bayesnet FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h")
-install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h DESTINATION include/bayesnet CONFIGURATIONS Release)
-# Documentation
-# -------------
-find_package(Doxygen)
-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})
-else (Doxygen_FOUND)
- MESSAGE("* Doxygen not found")
-endif (Doxygen_FOUND)
+install(DIRECTORY bayesnet/
+ DESTINATION include/bayesnet
+ FILES_MATCHING
+ CONFIGURATIONS Release
+ PATTERN "*.h")
+install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/bayesnet/config.h
+ DESTINATION include/bayesnet
+ CONFIGURATIONS Release)
+
+install(EXPORT bayesnetTargets
+ FILE bayesnetTargets.cmake
+ NAMESPACE bayesnet::
+ DESTINATION share/bayesnet)
+
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfigVersion.cmake"
+ DESTINATION share/bayesnet
+)
diff --git a/Makefile b/Makefile
index b663aa8..f4c0292 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ SHELL := /bin/bash
f_release = build_Release
f_debug = build_Debug
f_diagrams = diagrams
-app_targets = BayesNet
+app_targets = bayesnet
test_targets = TestBayesNet
clang-uml = clang-uml
plantuml = plantuml
@@ -86,10 +86,13 @@ init: ## Initialize the project installing dependencies
clean: ## Clean the project
@echo ">>> Cleaning the project..."
- @if test -d build_Debug ; then echo "- Deleting build_Debug folder" ; rm -rf build_Debug; fi
- @if test -d build_Release ; then echo "- Deleting build_Release folder" ; rm -rf build_Release; fi
@if test -f CMakeCache.txt ; then echo "- Deleting CMakeCache.txt"; rm -f CMakeCache.txt; fi
- @if test -d vcpkg_installed ; then echo "- Deleting vcpkg_installed folder" ; rm -rf vcpkg_installed; fi
+ @for folder in $(f_release) $(f_debug) vpcpkg_installed install_test ; do \
+ if test -d "$$folder" ; then \
+ echo "- Deleting $$folder folder" ; \
+ rm -rf "$$folder"; \
+ fi; \
+ done
@$(MAKE) clean-test
@echo ">>> Done";
diff --git a/bayesnetConfig.cmake.in b/bayesnetConfig.cmake.in
new file mode 100644
index 0000000..2194463
--- /dev/null
+++ b/bayesnetConfig.cmake.in
@@ -0,0 +1,4 @@
+@PACKAGE_INIT@
+
+include("${CMAKE_CURRENT_LIST_DIR}/bayesnetTargets.cmake")
+
diff --git a/config/config.h.in b/config/config.h.in
index 832c3a5..116f6e5 100644
--- a/config/config.h.in
+++ b/config/config.h.in
@@ -11,4 +11,4 @@ static constexpr std::string_view project_name = "@PROJECT_NAME@";
static constexpr std::string_view project_version = "@PROJECT_VERSION@";
static constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@";
static constexpr std::string_view git_sha = "@GIT_SHA@";
-static constexpr std::string_view data_path = "@BayesNet_SOURCE_DIR@/tests/data/";
\ No newline at end of file
+static constexpr std::string_view data_path = "@bayesnet_SOURCE_DIR@/tests/data/";
\ No newline at end of file
diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt
index 0cab4bc..82c8a60 100644
--- a/sample/CMakeLists.txt
+++ b/sample/CMakeLists.txt
@@ -1,15 +1,16 @@
cmake_minimum_required(VERSION 3.20)
-project(bayesnet_sample)
+project(bayesnet_sample VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_BUILD_TYPE Release)
+
find_package(Torch CONFIG REQUIRED)
-find_package(bayesnet CONFIG REQUIRED)
find_package(fimdlp CONFIG REQUIRED)
find_package(folding CONFIG REQUIRED)
find_package(arff-files CONFIG REQUIRED)
-find_package(nlohman_json CONFIG REQUIRED)
+find_package(bayesnet CONFIG REQUIRED)
add_executable(bayesnet_sample sample.cc)
target_link_libraries(bayesnet_sample PRIVATE
@@ -17,6 +18,5 @@ target_link_libraries(bayesnet_sample PRIVATE
arff-files::arff-files
"${TORCH_LIBRARIES}"
bayesnet::bayesnet
- nlohmann_json::nlohmann_json
folding::folding
)
diff --git a/sample/vcpkg-configuration.json b/sample/vcpkg-configuration.json
index 8ac2108..1c2ccde 100644
--- a/sample/vcpkg-configuration.json
+++ b/sample/vcpkg-configuration.json
@@ -1,21 +1,21 @@
{
+ "default-registry": {
+ "kind": "git",
+ "baseline": "760bfd0c8d7c89ec640aec4df89418b7c2745605",
+ "repository": "https://github.com/microsoft/vcpkg"
+ },
"registries": [
{
"kind": "git",
"repository": "https://github.com/rmontanana/vcpkg-stash",
- "baseline": "393efa4e74e053b6f02c4ab03738c8fe796b28e5",
+ "baseline": "1ea69243c0e8b0de77c9d1dd6e1d7593ae7f3627",
"packages": [
- "folding",
- "bayesnet",
"arff-files",
+ "bayesnet",
"fimdlp",
+ "folding",
"libtorch-bin"
]
}
- ],
- "default-registry": {
- "kind": "git",
- "repository": "https://github.com/microsoft/vcpkg",
- "baseline": "760bfd0c8d7c89ec640aec4df89418b7c2745605"
- }
+ ]
}
\ No newline at end of file
diff --git a/sample/vcpkg.json b/sample/vcpkg.json
index f9bfbd4..d8ef389 100644
--- a/sample/vcpkg.json
+++ b/sample/vcpkg.json
@@ -2,11 +2,32 @@
"name": "sample-project",
"version-string": "0.1.0",
"dependencies": [
- "bayesnet",
- "folding",
"arff-files",
"fimdlp",
- "nlohmann-json",
- "libtorch-bin"
+ "libtorch-bin",
+ "folding",
+ "bayesnet"
+ ],
+ "overrides": [
+ {
+ "name": "arff-files",
+ "version": "1.1.0"
+ },
+ {
+ "name": "fimdlp",
+ "version": "2.0.1"
+ },
+ {
+ "name": "libtorch-bin",
+ "version": "2.7.0"
+ },
+ {
+ "name": "bayesnet",
+ "version": "1.1.1"
+ },
+ {
+ "name": "folding",
+ "version": "1.1.1"
+ }
]
}
\ No newline at end of file
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 11f2b2c..383687f 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,18 +1,13 @@
if(ENABLE_TESTING)
include_directories(
- ${BayesNet_SOURCE_DIR}/tests/lib/Files
- ${BayesNet_SOURCE_DIR}/lib/folding
- ${BayesNet_SOURCE_DIR}/lib/mdlp/src
- ${BayesNet_SOURCE_DIR}/lib/log
- ${BayesNet_SOURCE_DIR}/lib/json/include
${BayesNet_SOURCE_DIR}
${CMAKE_BINARY_DIR}/configured_files/include
)
- file(GLOB_RECURSE BayesNet_SOURCES "${BayesNet_SOURCE_DIR}/bayesnet/*.cc")
+ file(GLOB_RECURSE BayesNet_SOURCES "${bayesnet_SOURCE_DIR}/bayesnet/*.cc")
add_executable(TestBayesNet TestBayesNetwork.cc TestBayesNode.cc TestBayesClassifier.cc TestXSPnDE.cc TestXBA2DE.cc
TestBayesModels.cc TestBayesMetrics.cc TestFeatureSelection.cc TestBoostAODE.cc TestXBAODE.cc TestA2DE.cc
TestUtils.cc TestBayesEnsemble.cc TestModulesVersions.cc TestBoostA2DE.cc TestMST.cc TestXSPODE.cc ${BayesNet_SOURCES})
- target_link_libraries(TestBayesNet PUBLIC "${TORCH_LIBRARIES}" fimdlp PRIVATE Catch2::Catch2WithMain)
+ target_link_libraries(TestBayesNet PUBLIC "${TORCH_LIBRARIES}" fimdlp::fimdlp PRIVATE Catch2::Catch2WithMain)
add_test(NAME BayesNetworkTest COMMAND TestBayesNet)
add_test(NAME A2DE COMMAND TestBayesNet "[A2DE]")
add_test(NAME BoostA2DE COMMAND TestBayesNet "[BoostA2DE]")
diff --git a/tests/TestBayesModels.cc b/tests/TestBayesModels.cc
index ed9cbd0..7a80cb8 100644
--- a/tests/TestBayesModels.cc
+++ b/tests/TestBayesModels.cc
@@ -20,7 +20,7 @@
#include "bayesnet/ensembles/AODELd.h"
#include "bayesnet/ensembles/BoostAODE.h"
-const std::string ACTUAL_VERSION = "1.1.0";
+const std::string ACTUAL_VERSION = "1.1.1";
TEST_CASE("Test Bayesian Classifiers score & version", "[Models]")
{
diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json
index cff5ca2..99ad7d9 100644
--- a/vcpkg-configuration.json
+++ b/vcpkg-configuration.json
@@ -8,7 +8,7 @@
{
"kind": "git",
"repository": "https://github.com/rmontanana/vcpkg-stash",
- "baseline": "393efa4e74e053b6f02c4ab03738c8fe796b28e5",
+ "baseline": "1ea69243c0e8b0de77c9d1dd6e1d7593ae7f3627",
"packages": [
"arff-files",
"fimdlp",