From 260c79f17ddb1947d9e8a9156d59d23ff5609125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Wed, 30 Apr 2025 13:25:37 +0200 Subject: [PATCH] Update installation way --- CMakeLists.txt | 44 ++++++++++++++++++---------------------- Makefile | 2 +- bayesnet/CMakeLists.txt | 10 +++------ config/config.h.in | 2 +- tests/CMakeLists.txt | 11 +++------- tests/TestBayesModels.cc | 2 +- 6 files changed, 29 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84efadc..0c705d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) -project(BayesNet +project(bayesnet VERSION 1.1.1 DESCRIPTION "Bayesian Network and basic classifiers Library." HOMEPAGE_URL "https://github.com/rmontanana/bayesnet" @@ -83,43 +83,39 @@ MESSAGE(STATUS "Testing enabled") add_subdirectory(tests) endif (ENABLE_TESTING) - - ############################################################################################# ############################################################################################# -install(TARGETS BayesNet - EXPORT bayesnetTargets - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin +# Installation +# ------------ +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion ) +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) + install(EXPORT bayesnetTargets - FILE bayesnetTargets.cmake - NAMESPACE bayesnet:: - DESTINATION lib/cmake/bayesnet -) - -include(CMakePackageConfigHelpers) + FILE bayesnetTargets.cmake + NAMESPACE bayesnet:: + DESTINATION lib/cmake/bayesnet) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/bayesnetConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfig.cmake" INSTALL_DESTINATION lib/cmake/bayesnet ) - -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/bayesnetConfig.cmake" - DESTINATION lib/cmake/bayesnet -) -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) - ############################################################################################# ############################################################################################# - - # Installation # ------------ # install(TARGETS BayesNet diff --git a/Makefile b/Makefile index b663aa8..d1bf38f 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 diff --git a/bayesnet/CMakeLists.txt b/bayesnet/CMakeLists.txt index 6815b70..96d3485 100644 --- a/bayesnet/CMakeLists.txt +++ b/bayesnet/CMakeLists.txt @@ -1,13 +1,9 @@ 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} + ${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}") +add_library(bayesnet ${Sources}) +target_link_libraries(bayesnet fimdlp::fimdlp folding::folding "${TORCH_LIBRARIES}") 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/tests/CMakeLists.txt b/tests/CMakeLists.txt index 11f2b2c..c83939c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,17 +1,12 @@ 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} + ${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}) + 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) add_test(NAME BayesNetworkTest COMMAND TestBayesNet) add_test(NAME A2DE COMMAND TestBayesNet "[A2DE]") 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]") {