First profiles
Signed-off-by: Ricardo Montañana Gómez <rmontanana@gmail.com>
This commit is contained in:
@@ -10,37 +10,6 @@ project(bayesnet
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
cmake_policy(SET CMP0135 NEW)
|
cmake_policy(SET CMP0135 NEW)
|
||||||
|
|
||||||
# Package manager detection
|
|
||||||
if(EXISTS ${CMAKE_BINARY_DIR}/conan_toolchain.cmake)
|
|
||||||
include(${CMAKE_BINARY_DIR}/conan_toolchain.cmake)
|
|
||||||
set(USING_CONAN TRUE)
|
|
||||||
message(STATUS "Using Conan package manager")
|
|
||||||
else()
|
|
||||||
set(USING_CONAN FALSE)
|
|
||||||
message(STATUS "Using vcpkg package manager")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Find packages - works with both Conan and vcpkg
|
|
||||||
find_package(Torch CONFIG REQUIRED)
|
|
||||||
find_package(nlohmann_json CONFIG REQUIRED)
|
|
||||||
|
|
||||||
# These packages might not be available in Conan yet, so we handle them conditionally
|
|
||||||
if(NOT USING_CONAN)
|
|
||||||
find_package(fimdlp CONFIG REQUIRED)
|
|
||||||
find_package(folding CONFIG REQUIRED)
|
|
||||||
else()
|
|
||||||
# For Conan, we'll need to either find alternatives or create custom packages
|
|
||||||
# For now, we'll look for them and warn if not found
|
|
||||||
find_package(fimdlp CONFIG QUIET)
|
|
||||||
find_package(folding CONFIG QUIET)
|
|
||||||
if(NOT fimdlp_FOUND)
|
|
||||||
message(WARNING "fimdlp not found - you may need to create a custom Conan recipe")
|
|
||||||
endif()
|
|
||||||
if(NOT folding_FOUND)
|
|
||||||
message(WARNING "folding not found - you may need to create a custom Conan recipe")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Global CMake variables
|
# Global CMake variables
|
||||||
# ----------------------
|
# ----------------------
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
@@ -57,17 +26,32 @@ endif()
|
|||||||
|
|
||||||
# Options
|
# Options
|
||||||
# -------
|
# -------
|
||||||
option(ENABLE_CLANG_TIDY "Enable to add clang tidy" OFF)
|
|
||||||
option(ENABLE_TESTING "Unit testing build" OFF)
|
option(ENABLE_TESTING "Unit testing build" OFF)
|
||||||
option(CODE_COVERAGE "Collect coverage from test library" OFF)
|
option(CODE_COVERAGE "Collect coverage from test library" OFF)
|
||||||
option(INSTALL_GTEST "Enable installation of googletest" OFF)
|
option(USING_CONAN "Use Conan package manager" OFF)
|
||||||
|
|
||||||
|
if(USING_CONAN)
|
||||||
|
message(STATUS "Using Conan package manager")
|
||||||
|
else(USING_CONAN)
|
||||||
|
message(STATUS "Using vcpkg package manager")
|
||||||
|
endif(USING_CONAN)
|
||||||
|
|
||||||
|
find_package(Torch CONFIG REQUIRED)
|
||||||
|
if(NOT TARGET torch::torch)
|
||||||
|
add_library(torch::torch INTERFACE IMPORTED GLOBAL)
|
||||||
|
|
||||||
|
# expose include paths and libraries that the find-module discovered
|
||||||
|
set_target_properties(torch::torch PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${TORCH_INCLUDE_DIRS}"
|
||||||
|
INTERFACE_LINK_LIBRARIES "${TORCH_LIBRARIES}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(fimdlp CONFIG REQUIRED)
|
||||||
|
find_package(folding CONFIG REQUIRED)
|
||||||
|
find_package(nlohmann_json REQUIRED)
|
||||||
|
|
||||||
add_subdirectory(config)
|
add_subdirectory(config)
|
||||||
|
|
||||||
if (ENABLE_CLANG_TIDY)
|
|
||||||
include(StaticAnalyzers) # clang-tidy
|
|
||||||
endif (ENABLE_CLANG_TIDY)
|
|
||||||
|
|
||||||
# Add the library
|
# Add the library
|
||||||
# ---------------
|
# ---------------
|
||||||
include_directories(
|
include_directories(
|
||||||
@@ -79,16 +63,13 @@ file(GLOB_RECURSE Sources "bayesnet/*.cc")
|
|||||||
|
|
||||||
add_library(bayesnet ${Sources})
|
add_library(bayesnet ${Sources})
|
||||||
|
|
||||||
# Link libraries conditionally based on package manager
|
target_link_libraries(bayesnet
|
||||||
set(BAYESNET_LINK_LIBRARIES "${TORCH_LIBRARIES}")
|
nlohmann_json::nlohmann_json
|
||||||
if(fimdlp_FOUND)
|
folding::folding
|
||||||
list(APPEND BAYESNET_LINK_LIBRARIES fimdlp::fimdlp)
|
fimdlp::fimdlp
|
||||||
endif()
|
torch::torch
|
||||||
if(folding_FOUND)
|
arff-files::arff-files
|
||||||
list(APPEND BAYESNET_LINK_LIBRARIES folding::folding)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(bayesnet ${BAYESNET_LINK_LIBRARIES})
|
|
||||||
|
|
||||||
# Testing
|
# Testing
|
||||||
# -------
|
# -------
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"build/Release/generators/CMakePresets.json",
|
"build/Release/generators/CMakePresets.json",
|
||||||
"build_Release/build/Release/generators/CMakePresets.json"
|
"build_Release/build/Release/generators/CMakePresets.json",
|
||||||
|
"build_Debug/build/Debug/generators/CMakePresets.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
266
Makefile
266
Makefile
@@ -1,6 +1,6 @@
|
|||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean debug release sample updatebadge doc doc-install init clean-test conan-init conan-debug conan-release conan-create conan-upload conan-clean
|
.PHONY: viewcoverage coverage setup help install uninstall diagrams buildr buildd test clean vcpkg-debug vcpkg-release vcpkg-sample updatebadge doc doc-install init clean-test conan-debug conan-release conan-create conan-upload conan-clean conan-sample
|
||||||
|
|
||||||
f_release = build_Release
|
f_release = build_Release
|
||||||
f_debug = build_Debug
|
f_debug = build_Debug
|
||||||
@@ -31,7 +31,6 @@ define ClearTests
|
|||||||
fi ;
|
fi ;
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|
||||||
setup: ## Install dependencies for tests and coverage
|
setup: ## Install dependencies for tests and coverage
|
||||||
@if [ "$(shell uname)" = "Darwin" ]; then \
|
@if [ "$(shell uname)" = "Darwin" ]; then \
|
||||||
brew install gcovr; \
|
brew install gcovr; \
|
||||||
@@ -43,47 +42,6 @@ setup: ## Install dependencies for tests and coverage
|
|||||||
fi
|
fi
|
||||||
@echo "* You should install plantuml & graphviz for the diagrams"
|
@echo "* You should install plantuml & graphviz for the diagrams"
|
||||||
|
|
||||||
diagrams: ## Create an UML class diagram & dependency of the project (diagrams/BayesNet.png)
|
|
||||||
@which $(plantuml) || (echo ">>> Please install plantuml"; exit 1)
|
|
||||||
@which $(dot) || (echo ">>> Please install graphviz"; exit 1)
|
|
||||||
@which $(clang-uml) || (echo ">>> Please install clang-uml"; exit 1)
|
|
||||||
@export PLANTUML_LIMIT_SIZE=16384
|
|
||||||
@echo ">>> Creating UML class diagram of the project...";
|
|
||||||
@$(clang-uml) -p
|
|
||||||
@cd $(f_diagrams); \
|
|
||||||
$(plantuml) -tsvg BayesNet.puml
|
|
||||||
@echo ">>> Creating dependency graph diagram of the project...";
|
|
||||||
$(MAKE) debug
|
|
||||||
cd $(f_debug) && cmake .. --graphviz=dependency.dot
|
|
||||||
@$(dot) -Tsvg $(f_debug)/dependency.dot.BayesNet -o $(f_diagrams)/dependency.svg
|
|
||||||
|
|
||||||
buildd: ## Build the debug targets
|
|
||||||
cmake --build $(f_debug) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
|
|
||||||
|
|
||||||
buildr: ## Build the release targets
|
|
||||||
cmake --build $(f_release) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
|
|
||||||
|
|
||||||
clean-test: ## Clean the tests info
|
|
||||||
@echo ">>> Cleaning Debug BayesNet tests...";
|
|
||||||
$(call ClearTests)
|
|
||||||
@echo ">>> Done";
|
|
||||||
|
|
||||||
uninstall: ## Uninstall library
|
|
||||||
@echo ">>> Uninstalling BayesNet...";
|
|
||||||
xargs rm < $(f_release)/install_manifest.txt
|
|
||||||
@echo ">>> Done";
|
|
||||||
|
|
||||||
prefix = "/usr/local"
|
|
||||||
install: ## Install library
|
|
||||||
@echo ">>> Installing BayesNet...";
|
|
||||||
@cmake --install $(f_release) --prefix $(prefix)
|
|
||||||
@echo ">>> Done";
|
|
||||||
|
|
||||||
init: ## Initialize the project installing dependencies
|
|
||||||
@echo ">>> Installing dependencies"
|
|
||||||
@vcpkg install
|
|
||||||
@echo ">>> Done";
|
|
||||||
|
|
||||||
clean: ## Clean the project
|
clean: ## Clean the project
|
||||||
@echo ">>> Cleaning the project..."
|
@echo ">>> Cleaning the project..."
|
||||||
@if test -f CMakeCache.txt ; then echo "- Deleting CMakeCache.txt"; rm -f CMakeCache.txt; fi
|
@if test -f CMakeCache.txt ; then echo "- Deleting CMakeCache.txt"; rm -f CMakeCache.txt; fi
|
||||||
@@ -96,37 +54,38 @@ clean: ## Clean the project
|
|||||||
@$(MAKE) clean-test
|
@$(MAKE) clean-test
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
debug: ## Build a debug version of the project
|
# Build targets
|
||||||
@echo ">>> Building Debug BayesNet...";
|
# =============
|
||||||
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
|
|
||||||
@mkdir $(f_debug);
|
buildd: ## Build the debug targets
|
||||||
@cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
|
cmake --build $(f_debug) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
|
||||||
|
|
||||||
|
buildr: ## Build the release targets
|
||||||
|
cmake --build $(f_release) -t $(app_targets) --parallel $(CMAKE_BUILD_PARALLEL_LEVEL)
|
||||||
|
|
||||||
|
|
||||||
|
# Install targets
|
||||||
|
# ===============
|
||||||
|
|
||||||
|
uninstall: ## Uninstall library
|
||||||
|
@echo ">>> Uninstalling BayesNet...";
|
||||||
|
xargs rm < $(f_release)/install_manifest.txt
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
release: ## Build a Release version of the project
|
prefix = "/usr/local"
|
||||||
@echo ">>> Building Release BayesNet...";
|
install: ## Install library
|
||||||
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
|
@echo ">>> Installing BayesNet...";
|
||||||
@mkdir $(f_release);
|
@cmake --install $(f_release) --prefix $(prefix)
|
||||||
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
|
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
fname = "tests/data/iris.arff"
|
|
||||||
model = "TANLd"
|
|
||||||
sample: ## Build sample
|
|
||||||
@echo ">>> Building Sample...";
|
|
||||||
@if [ -d ./sample/build ]; then rm -rf ./sample/build; fi
|
|
||||||
@cd sample && cmake -B build -S . -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake && \
|
|
||||||
cmake --build build -t bayesnet_sample
|
|
||||||
sample/build/bayesnet_sample $(fname) $(model)
|
|
||||||
@echo ">>> Done";
|
|
||||||
|
|
||||||
fname = "tests/data/iris.arff"
|
# Test targets
|
||||||
sample2: ## Build sample2
|
# ============
|
||||||
@echo ">>> Building Sample...";
|
|
||||||
@if [ -d ./sample/build ]; then rm -rf ./sample/build; fi
|
clean-test: ## Clean the tests info
|
||||||
@cd sample && cmake -B build -S . -D CMAKE_BUILD_TYPE=Debug && cmake --build build -t bayesnet_sample_xspode
|
@echo ">>> Cleaning Debug BayesNet tests...";
|
||||||
sample/build/bayesnet_sample_xspode $(fname)
|
$(call ClearTests)
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
opt = ""
|
opt = ""
|
||||||
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
test: ## Run tests (opt="-s") to verbose output the tests, (opt="-c='Test Maximum Spanning Tree'") to run only that section
|
||||||
@@ -182,6 +141,9 @@ updatebadge: ## Update the coverage badge in README.md
|
|||||||
@env python update_coverage.py $(f_debug)/tests
|
@env python update_coverage.py $(f_debug)/tests
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
# Documentation targets
|
||||||
|
# =====================
|
||||||
|
|
||||||
doc: ## Generate documentation
|
doc: ## Generate documentation
|
||||||
@echo ">>> Generating documentation..."
|
@echo ">>> Generating documentation..."
|
||||||
@cmake --build $(f_release) -t doxygen
|
@cmake --build $(f_release) -t doxygen
|
||||||
@@ -196,6 +158,20 @@ doc: ## Generate documentation
|
|||||||
fi
|
fi
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
diagrams: ## Create an UML class diagram & dependency of the project (diagrams/BayesNet.png)
|
||||||
|
@which $(plantuml) || (echo ">>> Please install plantuml"; exit 1)
|
||||||
|
@which $(dot) || (echo ">>> Please install graphviz"; exit 1)
|
||||||
|
@which $(clang-uml) || (echo ">>> Please install clang-uml"; exit 1)
|
||||||
|
@export PLANTUML_LIMIT_SIZE=16384
|
||||||
|
@echo ">>> Creating UML class diagram of the project...";
|
||||||
|
@$(clang-uml) -p
|
||||||
|
@cd $(f_diagrams); \
|
||||||
|
$(plantuml) -tsvg BayesNet.puml
|
||||||
|
@echo ">>> Creating dependency graph diagram of the project...";
|
||||||
|
$(MAKE) debug
|
||||||
|
cd $(f_debug) && cmake .. --graphviz=dependency.dot
|
||||||
|
@$(dot) -Tsvg $(f_debug)/dependency.dot.BayesNet -o $(f_diagrams)/dependency.svg
|
||||||
|
|
||||||
docdir = ""
|
docdir = ""
|
||||||
doc-install: ## Install documentation
|
doc-install: ## Install documentation
|
||||||
@echo ">>> Installing documentation..."
|
@echo ">>> Installing documentation..."
|
||||||
@@ -210,6 +186,111 @@ doc-install: ## Install documentation
|
|||||||
@sudo cp -rp $(mansrcdir) $(mandestdir)
|
@sudo cp -rp $(mansrcdir) $(mandestdir)
|
||||||
@echo ">>> Done";
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
# Conan package manager targets
|
||||||
|
# =============================
|
||||||
|
|
||||||
|
# conan-debug: ## Build debug version using Conan
|
||||||
|
# @echo ">>> Building Debug BayesNet with Conan..."
|
||||||
|
# @if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
|
||||||
|
# @mkdir $(f_debug)
|
||||||
|
# @conan install . -s build_type=Debug --build=missing -of $(f_debug)
|
||||||
|
# @cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON -D USING_CONAN=ON -DCMAKE_TOOLCHAIN_FILE=$(f_debug)/build/Debug/generators/conan_toolchain.cmake
|
||||||
|
# @echo ">>> Done"
|
||||||
|
conan-debug: ## Build debug version using Conan
|
||||||
|
@echo ">>> Building *Debug* BayesNet with Conan..."
|
||||||
|
@rm -rf $(f_debug) # wipe previous tree
|
||||||
|
@conan install . \
|
||||||
|
-s build_type=Debug \
|
||||||
|
--build=missing \
|
||||||
|
-of $(f_debug) \
|
||||||
|
--profile=debug
|
||||||
|
@cmake -S . -B $(f_debug) \
|
||||||
|
-DCMAKE_BUILD_TYPE=Debug \
|
||||||
|
-DENABLE_TESTING=ON \
|
||||||
|
-DCODE_COVERAGE=ON \
|
||||||
|
-DUSING_CONAN=ON \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=$(f_debug)/build/Debug/generators/conan_toolchain.cmake
|
||||||
|
@echo ">>> Done"
|
||||||
|
|
||||||
|
conan-release: ## Build release version using Conan
|
||||||
|
@echo ">>> Building Release BayesNet with Conan..."
|
||||||
|
@conan install . \
|
||||||
|
-s build_type=Release \
|
||||||
|
--build=missing \
|
||||||
|
-of $(f_debug) \
|
||||||
|
--profile=release
|
||||||
|
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
|
||||||
|
@mkdir $(f_release)
|
||||||
|
@conan install . -s build_type=Release --build=missing -of $(f_release)
|
||||||
|
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release -D USING_CONAN=ON -DCMAKE_TOOLCHAIN_FILE=$(f_release)/build/Release/generators/conan_toolchain.cmake
|
||||||
|
@echo ">>> Done"
|
||||||
|
|
||||||
|
conan-create: ## Create Conan package
|
||||||
|
@echo ">>> Creating Conan package..."
|
||||||
|
@conan create . --build=missing -tf "" --profile=release
|
||||||
|
@conan create . --build=missing -tf "" --profile=debug
|
||||||
|
@echo ">>> Done"
|
||||||
|
|
||||||
|
profile ?= default
|
||||||
|
remote ?= Cimmeria
|
||||||
|
conan-upload: ## Upload package to Conan remote (profile=default remote=conancenter)
|
||||||
|
@echo ">>> Uploading to Conan remote $(remote) with profile $(profile)..."
|
||||||
|
@conan upload bayesnet/$(grep version conanfile.py | cut -d'"' -f2) -r $(remote) --confirm
|
||||||
|
@echo ">>> Done"
|
||||||
|
|
||||||
|
conan-clean: ## Clean Conan cache and build folders
|
||||||
|
@echo ">>> Cleaning Conan cache and build folders..."
|
||||||
|
@conan remove "*" --confirm
|
||||||
|
@if test -d "$(f_release)" ; then rm -rf "$(f_release)"; fi
|
||||||
|
@if test -d "$(f_debug)" ; then rm -rf "$(f_debug)"; fi
|
||||||
|
@echo ">>> Done"
|
||||||
|
|
||||||
|
fname = "tests/data/iris.arff"
|
||||||
|
model = "TANLd"
|
||||||
|
conan-sample: ## Build sample with Conan
|
||||||
|
@echo ">>> Building Sample with Conan...";
|
||||||
|
@if [ -d ./sample/build ]; then rm -rf ./sample/build; fi
|
||||||
|
@cd sample && conan install . --output-folder=build --build=missing
|
||||||
|
@cd sample && cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake && \
|
||||||
|
cmake --build build -t bayesnet_sample
|
||||||
|
sample/build/bayesnet_sample $(fname) $(model)
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
# vcpkg package manager targets
|
||||||
|
# =============================
|
||||||
|
|
||||||
|
vcpkg-init: ## Initialize the project installing dependencies using vcpkg
|
||||||
|
@echo ">>> Installing dependencies with vcpkg"
|
||||||
|
@vcpkg install
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
vcpkg-debug: ## Build a debug version of the project using vcpkg
|
||||||
|
@echo ">>> Building Debug BayesNet with vcpkg...";
|
||||||
|
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
|
||||||
|
@mkdir $(f_debug);
|
||||||
|
@cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
vcpkg-release: ## Build a Release version of the project using vcpkg
|
||||||
|
@echo ">>> Building Release BayesNet with vcpkg...";
|
||||||
|
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
|
||||||
|
@mkdir $(f_release);
|
||||||
|
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
fname = "tests/data/iris.arff"
|
||||||
|
model = "TANLd"
|
||||||
|
vcpkg-sample: ## Build sample with vcpkg
|
||||||
|
@echo ">>> Building Sample with vcpkg...";
|
||||||
|
@if [ -d ./sample/build ]; then rm -rf ./sample/build; fi
|
||||||
|
@cd sample && cmake -B build -S . -D CMAKE_BUILD_TYPE=Release -DUSING_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake && \
|
||||||
|
cmake --build build -t bayesnet_sample
|
||||||
|
sample/build/bayesnet_sample $(fname) $(model)
|
||||||
|
@echo ">>> Done";
|
||||||
|
|
||||||
|
# Help target
|
||||||
|
# ===========
|
||||||
|
|
||||||
help: ## Show help message
|
help: ## Show help message
|
||||||
@IFS=$$'\n' ; \
|
@IFS=$$'\n' ; \
|
||||||
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
|
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
|
||||||
@@ -225,49 +306,4 @@ help: ## Show help message
|
|||||||
printf "%-20s %s" $$help_command ; \
|
printf "%-20s %s" $$help_command ; \
|
||||||
printf '\033[0m'; \
|
printf '\033[0m'; \
|
||||||
printf "%s\n" $$help_info; \
|
printf "%s\n" $$help_info; \
|
||||||
done
|
done
|
||||||
|
|
||||||
# Conan package manager targets
|
|
||||||
# ============================
|
|
||||||
|
|
||||||
conan-init: ## Install dependencies using Conan
|
|
||||||
@echo ">>> Installing dependencies with Conan"
|
|
||||||
@which conan || (echo ">>> Please install Conan first: pip install conan"; exit 1)
|
|
||||||
@conan profile detect --force
|
|
||||||
@conan install . --build=missing
|
|
||||||
@echo ">>> Done"
|
|
||||||
|
|
||||||
conan-debug: ## Build debug version using Conan
|
|
||||||
@echo ">>> Building Debug BayesNet with Conan..."
|
|
||||||
@if [ -d ./$(f_debug) ]; then rm -rf ./$(f_debug); fi
|
|
||||||
@mkdir $(f_debug)
|
|
||||||
@conan install . -s build_type=Debug -o enable_testing=True -o enable_coverage=True --build=missing -of $(f_debug)
|
|
||||||
@cmake -S . -B $(f_debug) -D CMAKE_BUILD_TYPE=Debug -D ENABLE_TESTING=ON -D CODE_COVERAGE=ON
|
|
||||||
@echo ">>> Done"
|
|
||||||
|
|
||||||
conan-release: ## Build release version using Conan
|
|
||||||
@echo ">>> Building Release BayesNet with Conan..."
|
|
||||||
@if [ -d ./$(f_release) ]; then rm -rf ./$(f_release); fi
|
|
||||||
@mkdir $(f_release)
|
|
||||||
@conan install . -s build_type=Release --build=missing -of $(f_release)
|
|
||||||
@cmake -S . -B $(f_release) -D CMAKE_BUILD_TYPE=Release
|
|
||||||
@echo ">>> Done"
|
|
||||||
|
|
||||||
conan-create: ## Create Conan package
|
|
||||||
@echo ">>> Creating Conan package..."
|
|
||||||
@conan create . --build=missing
|
|
||||||
@echo ">>> Done"
|
|
||||||
|
|
||||||
profile ?= default
|
|
||||||
remote ?= conancenter
|
|
||||||
conan-upload: ## Upload package to Conan remote (profile=default remote=conancenter)
|
|
||||||
@echo ">>> Uploading to Conan remote $(remote) with profile $(profile)..."
|
|
||||||
@conan upload bayesnet/$(shell grep version conanfile.py | cut -d'"' -f2) -r $(remote) --confirm
|
|
||||||
@echo ">>> Done"
|
|
||||||
|
|
||||||
conan-clean: ## Clean Conan cache and build folders
|
|
||||||
@echo ">>> Cleaning Conan cache and build folders..."
|
|
||||||
@conan remove "*" --confirm
|
|
||||||
@if test -d "$(f_release)" ; then rm -rf "$(f_release)"; fi
|
|
||||||
@if test -d "$(f_debug)" ; then rm -rf "$(f_debug)"; fi
|
|
||||||
@echo ">>> Done"
|
|
@@ -1,13 +0,0 @@
|
|||||||
include_directories(
|
|
||||||
${BayesNet_SOURCE_DIR}/lib/log
|
|
||||||
${BayesNet_SOURCE_DIR}/lib/mdlp/src
|
|
||||||
${BayesNet_SOURCE_DIR}/lib/folding
|
|
||||||
${BayesNet_SOURCE_DIR}/lib/json/include
|
|
||||||
${BayesNet_SOURCE_DIR}
|
|
||||||
${CMAKE_BINARY_DIR}/configured_files/include
|
|
||||||
)
|
|
||||||
|
|
||||||
file(GLOB_RECURSE Sources "*.cc")
|
|
||||||
|
|
||||||
add_library(BayesNet ${Sources})
|
|
||||||
target_link_libraries(BayesNet fimdlp "${TORCH_LIBRARIES}")
|
|
14
conanfile.py
14
conanfile.py
@@ -5,7 +5,7 @@ import os
|
|||||||
|
|
||||||
class BayesNetConan(ConanFile):
|
class BayesNetConan(ConanFile):
|
||||||
name = "bayesnet"
|
name = "bayesnet"
|
||||||
version = "1.1.2"
|
version = "1.2.0"
|
||||||
|
|
||||||
# Binary configuration
|
# Binary configuration
|
||||||
settings = "os", "compiler", "build_type", "arch"
|
settings = "os", "compiler", "build_type", "arch"
|
||||||
@@ -23,7 +23,7 @@ class BayesNetConan(ConanFile):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Sources are located in the same place as this recipe, copy them to the recipe
|
# Sources are located in the same place as this recipe, copy them to the recipe
|
||||||
exports_sources = "CMakeLists.txt", "bayesnet/*", "config/*", "cmake/*", "tests/*", "bayesnetConfig.cmake.in"
|
exports_sources = "CMakeLists.txt", "bayesnet/*", "config/*", "cmake/*", "docs/*", "tests/*", "bayesnetConfig.cmake.in"
|
||||||
|
|
||||||
def config_options(self):
|
def config_options(self):
|
||||||
if self.settings.os == "Windows":
|
if self.settings.os == "Windows":
|
||||||
@@ -37,19 +37,13 @@ class BayesNetConan(ConanFile):
|
|||||||
# Core dependencies
|
# Core dependencies
|
||||||
self.requires("libtorch/2.7.0")
|
self.requires("libtorch/2.7.0")
|
||||||
self.requires("nlohmann_json/3.11.3")
|
self.requires("nlohmann_json/3.11.3")
|
||||||
|
|
||||||
# Custom dependencies - these will need to be available in your Conan center or custom remotes
|
|
||||||
# For now, we'll comment them out and provide instructions in the README
|
|
||||||
self.requires("folding/1.1.1") # Custom package
|
self.requires("folding/1.1.1") # Custom package
|
||||||
self.requires("fimdlp/2.1.0") # Custom package
|
self.requires("fimdlp/2.1.0") # Custom package
|
||||||
self.requires("arff-files/1.2.0") # Custom package
|
|
||||||
|
|
||||||
# Test dependencies
|
|
||||||
if self.options.enable_testing:
|
|
||||||
self.requires("catch2/3.8.1")
|
|
||||||
|
|
||||||
def build_requirements(self):
|
def build_requirements(self):
|
||||||
self.build_requires("cmake/[>=3.27]")
|
self.build_requires("cmake/[>=3.27]")
|
||||||
|
self.test_requires("arff-files/1.2.0") # Custom package
|
||||||
|
self.test_requires("catch2/3.8.1")
|
||||||
|
|
||||||
def layout(self):
|
def layout(self):
|
||||||
cmake_layout(self)
|
cmake_layout(self)
|
||||||
|
@@ -3,10 +3,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#define PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
|
|
||||||
#define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@
|
|
||||||
#define PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@
|
|
||||||
|
|
||||||
static constexpr std::string_view project_name = "@PROJECT_NAME@";
|
static constexpr std::string_view project_name = "@PROJECT_NAME@";
|
||||||
static constexpr std::string_view project_version = "@PROJECT_VERSION@";
|
static constexpr std::string_view project_version = "@PROJECT_VERSION@";
|
||||||
static constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@";
|
static constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@";
|
||||||
|
@@ -4,37 +4,38 @@ project(bayesnet_sample VERSION 0.1.0 LANGUAGES CXX)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
|
||||||
|
|
||||||
find_package(Torch CONFIG REQUIRED)
|
find_package(Torch CONFIG REQUIRED)
|
||||||
find_package(fimdlp CONFIG REQUIRED)
|
find_package(fimdlp CONFIG REQUIRED)
|
||||||
find_package(folding CONFIG REQUIRED)
|
find_package(folding CONFIG REQUIRED)
|
||||||
find_package(arff-files CONFIG REQUIRED)
|
find_package(arff-files CONFIG REQUIRED)
|
||||||
find_package(nlohmann_json CONFIG REQUIRED)
|
find_package(nlohmann_json REQUIRED)
|
||||||
|
find_package(bayesnet CONFIG REQUIRED)
|
||||||
|
|
||||||
option(BAYESNET_VCPKG_CONFIG "Use vcpkg config for BayesNet" ON)
|
# option(USING_VCPKG "Use vcpkg config for BayesNet" OFF)
|
||||||
|
# option(USING_CONAN "Use Conan config for BayesNet" OFF)
|
||||||
|
|
||||||
if (BAYESNET_VCPKG_CONFIG)
|
# if (USING_VCPKG OR USING_CONAN)
|
||||||
message(STATUS "Using BayesNet vcpkg config")
|
# message(STATUS "Using BayesNet vcpkg config")
|
||||||
find_package(bayesnet CONFIG REQUIRED)
|
# find_package(bayesnet CONFIG REQUIRED)
|
||||||
set(BayesNet_LIBRARIES bayesnet::bayesnet)
|
# set(BayesNet_LIBRARIES bayesnet::bayesnet)
|
||||||
else(BAYESNET_VCPKG_CONFIG)
|
# else(USING_VCPKG)
|
||||||
message(STATUS "Using BayesNet local library config")
|
# message(STATUS "Using BayesNet local library config")
|
||||||
find_library(bayesnet NAMES libbayesnet bayesnet libbayesnet.a PATHS ${Platform_SOURCE_DIR}/../lib/lib REQUIRED)
|
# find_library(bayesnet NAMES libbayesnet bayesnet libbayesnet.a PATHS ${Platform_SOURCE_DIR}/../lib/lib REQUIRED)
|
||||||
find_path(Bayesnet_INCLUDE_DIRS REQUIRED NAMES bayesnet PATHS ${Platform_SOURCE_DIR}/../lib/include)
|
# find_path(Bayesnet_INCLUDE_DIRS REQUIRED NAMES bayesnet PATHS ${Platform_SOURCE_DIR}/../lib/include)
|
||||||
add_library(bayesnet::bayesnet UNKNOWN IMPORTED)
|
# add_library(bayesnet::bayesnet UNKNOWN IMPORTED)
|
||||||
set_target_properties(bayesnet::bayesnet PROPERTIES
|
# set_target_properties(bayesnet::bayesnet PROPERTIES
|
||||||
IMPORTED_LOCATION ${bayesnet}
|
# IMPORTED_LOCATION ${bayesnet}
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${Bayesnet_INCLUDE_DIRS}
|
# INTERFACE_INCLUDE_DIRECTORIES ${Bayesnet_INCLUDE_DIRS}
|
||||||
)
|
# )
|
||||||
endif(BAYESNET_VCPKG_CONFIG)
|
# endif(USING_VCPKG)
|
||||||
message(STATUS "BayesNet: ${bayesnet}")
|
# message(STATUS "BayesNet: ${bayesnet}")
|
||||||
|
|
||||||
add_executable(bayesnet_sample sample.cc)
|
add_executable(bayesnet_sample sample.cc)
|
||||||
target_link_libraries(bayesnet_sample PRIVATE
|
target_link_libraries(bayesnet_sample PRIVATE
|
||||||
fimdlp::fimdlp
|
fimdlp::fimdlp
|
||||||
arff-files::arff-files
|
arff-files::arff-files
|
||||||
"${TORCH_LIBRARIES}"
|
torch::torch
|
||||||
bayesnet::bayesnet
|
bayesnet::bayesnet
|
||||||
folding::folding
|
folding::folding
|
||||||
|
nlohmann_json::nlohmann_json
|
||||||
)
|
)
|
||||||
|
9
sample/CMakeUserPresets.json
Normal file
9
sample/CMakeUserPresets.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"version": 4,
|
||||||
|
"vendor": {
|
||||||
|
"conan": {}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"build/CMakePresets.json"
|
||||||
|
]
|
||||||
|
}
|
14
sample/conanfile.txt
Normal file
14
sample/conanfile.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[requires]
|
||||||
|
libtorch/2.7.0
|
||||||
|
arff-files/1.2.0
|
||||||
|
fimdlp/2.1.0
|
||||||
|
folding/1.1.1
|
||||||
|
bayesnet/1.2.0
|
||||||
|
nlohmann_json/3.11.3
|
||||||
|
|
||||||
|
[generators]
|
||||||
|
CMakeToolchain
|
||||||
|
CMakeDeps
|
||||||
|
|
||||||
|
[options]
|
||||||
|
libtorch/2.7.0:shared=True
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ArffFiles/ArffFiles.hpp>
|
#include <ArffFiles.hpp>
|
||||||
#include <fimdlp/CPPFImdlp.h>
|
#include <fimdlp/CPPFImdlp.h>
|
||||||
#include <bayesnet/classifiers/TANLd.h>
|
#include <bayesnet/classifiers/TANLd.h>
|
||||||
#include <bayesnet/classifiers/KDBLd.h>
|
#include <bayesnet/classifiers/KDBLd.h>
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
. "/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators/conanbuildenv-release-x86_64.sh"
|
@@ -0,0 +1,16 @@
|
|||||||
|
script_folder="/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators"
|
||||||
|
echo "echo Restoring environment" > "$script_folder/deactivate_conanbuildenv-release-x86_64.sh"
|
||||||
|
for v in PATH
|
||||||
|
do
|
||||||
|
is_defined="true"
|
||||||
|
value=$(printenv $v) || is_defined="" || true
|
||||||
|
if [ -n "$value" ] || [ -n "$is_defined" ]
|
||||||
|
then
|
||||||
|
echo export "$v='$value'" >> "$script_folder/deactivate_conanbuildenv-release-x86_64.sh"
|
||||||
|
else
|
||||||
|
echo unset $v >> "$script_folder/deactivate_conanbuildenv-release-x86_64.sh"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
export PATH="/home/rmontanana/.conan2/p/cmakeab16c849c207b/p/bin:$PATH"
|
@@ -0,0 +1 @@
|
|||||||
|
. "/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators/conanrunenv-release-x86_64.sh"
|
@@ -0,0 +1,17 @@
|
|||||||
|
script_folder="/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators"
|
||||||
|
echo "echo Restoring environment" > "$script_folder/deactivate_conanrunenv-release-x86_64.sh"
|
||||||
|
for v in LD_LIBRARY_PATH DYLD_LIBRARY_PATH
|
||||||
|
do
|
||||||
|
is_defined="true"
|
||||||
|
value=$(printenv $v) || is_defined="" || true
|
||||||
|
if [ -n "$value" ] || [ -n "$is_defined" ]
|
||||||
|
then
|
||||||
|
echo export "$v='$value'" >> "$script_folder/deactivate_conanrunenv-release-x86_64.sh"
|
||||||
|
else
|
||||||
|
echo unset $v >> "$script_folder/deactivate_conanrunenv-release-x86_64.sh"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH="/home/rmontanana/.conan2/p/libto33fc3f5110c64/p/lib:$LD_LIBRARY_PATH"
|
||||||
|
export DYLD_LIBRARY_PATH="/home/rmontanana/.conan2/p/libto33fc3f5110c64/p/lib:$DYLD_LIBRARY_PATH"
|
@@ -0,0 +1 @@
|
|||||||
|
. "/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators/deactivate_conanbuildenv-release-x86_64.sh"
|
@@ -0,0 +1 @@
|
|||||||
|
. "/home/rmontanana/Code/BayesNet/test_package/build/gcc-14-x86_64-gnu17-release/generators/deactivate_conanrunenv-release-x86_64.sh"
|
@@ -2,12 +2,13 @@ if(ENABLE_TESTING)
|
|||||||
include_directories(
|
include_directories(
|
||||||
${BayesNet_SOURCE_DIR}
|
${BayesNet_SOURCE_DIR}
|
||||||
${CMAKE_BINARY_DIR}/configured_files/include
|
${CMAKE_BINARY_DIR}/configured_files/include
|
||||||
|
${nlohmann_json_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
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
|
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
|
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})
|
TestUtils.cc TestBayesEnsemble.cc TestModulesVersions.cc TestBoostA2DE.cc TestMST.cc TestXSPODE.cc ${BayesNet_SOURCES})
|
||||||
target_link_libraries(TestBayesNet PUBLIC "${TORCH_LIBRARIES}" fimdlp::fimdlp PRIVATE Catch2::Catch2WithMain)
|
target_link_libraries(TestBayesNet PUBLIC "${TORCH_LIBRARIES}" fimdlp::fimdlp PRIVATE Catch2::Catch2WithMain folding::folding)
|
||||||
add_test(NAME BayesNetworkTest COMMAND TestBayesNet)
|
add_test(NAME BayesNetworkTest COMMAND TestBayesNet)
|
||||||
add_test(NAME A2DE COMMAND TestBayesNet "[A2DE]")
|
add_test(NAME A2DE COMMAND TestBayesNet "[A2DE]")
|
||||||
add_test(NAME BoostA2DE COMMAND TestBayesNet "[BoostA2DE]")
|
add_test(NAME BoostA2DE COMMAND TestBayesNet "[BoostA2DE]")
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <ArffFiles/ArffFiles.hpp>
|
#include <ArffFiles.hpp>
|
||||||
#include <fimdlp/CPPFImdlp.h>
|
#include <fimdlp/CPPFImdlp.h>
|
||||||
#include <folding.hpp>
|
#include <folding.hpp>
|
||||||
#include <bayesnet/network/Network.h>
|
#include <bayesnet/network/Network.h>
|
||||||
|
Reference in New Issue
Block a user