Merge pull request 'Create version 1.1.2' (#2) from 112 into main

Reviewed-on: #2
This commit is contained in:
2025-07-19 17:51:24 +00:00
11 changed files with 189 additions and 15 deletions

1
.gitignore vendored
View File

@@ -63,3 +63,4 @@ conandeps*.cmake
Find*.cmake
module-*.cmake
CMakeUserPresets.json
.claude

View File

@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.1.2] 2025-07-19
### Changed
- Update cmake and make build and conan integration
- Remove CMakeUserPresets
- Add libtorch 2.7.1 dependency
- Fix conan package version
- Add conan integration for dependency management
- Remove git submodules
## [1.1.1] 2024-12-13
- Added a new parameter `quiet` to enable/disable the warning messages in the Stratified K-Fold partitioning. Default value `true`.

View File

@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.20)
project(Folding
VERSION 1.1.2
DESCRIPTION "Folding utility for BayesNet library"
HOMEPAGE_URL "https://github.com/rmontanana/folding"
LANGUAGES CXX
@@ -25,6 +26,10 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
# -------
option(ENABLE_TESTING "Unit testing build" OFF)
# Subdirectories
# --------------
add_subdirectory(config)
# Testing
# -------
if (ENABLE_TESTING)
@@ -39,3 +44,55 @@ endif (ENABLE_TESTING)
# Library
# --------
add_library(folding INTERFACE folding.hpp)
target_include_directories(folding INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/configured_files/include>
$<INSTALL_INTERFACE:include>
)
# Install
# -------
install(TARGETS folding EXPORT FoldingTargets
INCLUDES DESTINATION include
)
install(EXPORT FoldingTargets
FILE FoldingTargets.cmake
NAMESPACE Folding::
DESTINATION lib/cmake/Folding
)
# Install the main header file
install(FILES folding.hpp
DESTINATION include
)
# Install the generated configuration header
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/configured_files/include/folding_config.h"
DESTINATION include
)
# Install documentation files
install(FILES LICENSE README.md
DESTINATION share/doc/Folding
)
# Create and install package configuration files
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/FoldingConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FoldingConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/FoldingConfig.cmake"
INSTALL_DESTINATION lib/cmake/Folding
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/FoldingConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/FoldingConfigVersion.cmake"
DESTINATION lib/cmake/Folding
)

View File

@@ -29,7 +29,7 @@ build: ## Build a debug version of the project
@if [ -d $(f_debug) ]; then rm -rf $(f_debug); fi
@mkdir $(f_debug);
conan install . -of $(f_debug) -s build_type=Debug -b missing
cmake -B $(f_debug) -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=$(f_debug)/build/Debug/generators/conan_toolchain.cmake -DENABLE_TESTING=ON
cmake -B $(f_debug) -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=$(f_debug)/conan_toolchain.cmake -DENABLE_TESTING=ON
cmake --build $(f_debug) -t $(test_targets) $(n_procs)
@echo ">>> Done";

View File

@@ -0,0 +1,5 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/FoldingTargets.cmake")
check_required_components(Folding)

View File

@@ -1,22 +1,39 @@
import re
from conan import ConanFile
from conan.tools.files import copy
from conan.tools.cmake import cmake_layout
from conan.tools.cmake import CMakeToolchain, CMakeDeps
class FoldingConan(ConanFile):
name = "folding"
version = "1.1.1"
version = "X.X.X"
description = "K-Fold and stratified K-Fold header-only library"
url = "https://github.com/rmontanana/folding"
license = "MIT"
homepage = "https://github.com/rmontanana/folding"
topics = ("kfold", "stratified folding", "mdlp")
no_copy_source = True
exports_sources = "folding.hpp"
exports_sources = (
"folding.hpp",
"LICENSE",
"README.md",
"CMakeLists.txt",
"config/*",
"cmake/*",
)
package_type = "header-library"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps", "CMakeToolchain"
settings = "build_type", "compiler", "arch", "os"
def init(self):
# Read the CMakeLists.txt file to get the version
with open("CMakeLists.txt", "r") as f:
lines = f.readlines()
for line in lines:
if "VERSION" in line:
# Extract the version number using regex
match = re.search(r"VERSION\s+(\d+\.\d+\.\d+)", line)
if match:
self.version = match.group(1)
def requirements(self):
self.requires("libtorch/2.7.1")
@@ -25,15 +42,79 @@ class FoldingConan(ConanFile):
self.tool_requires("cmake/[>=3.15]")
# Test dependencies
self.test_requires("catch2/3.8.1")
self.test_requires("arff-files/1.2.0")
self.test_requires("fimdlp/2.1.0")
self.test_requires("arff-files/1.2.1")
self.test_requires("fimdlp/2.1.1")
def layout(self):
cmake_layout(self)
# Only use cmake_layout for conan packaging, not for development builds
# This can be detected by checking if we're in a conan cache folder
if (
hasattr(self, "folders")
and hasattr(self.folders, "base_build")
and self.folders.base_build
and ".conan2" in self.folders.base_build
):
from conan.tools.cmake import cmake_layout
cmake_layout(self)
def generate(self):
# Generate CMake toolchain file
tc = CMakeToolchain(self)
tc.generate()
# Generate CMake dependencies file (needed for test requirements like catch2)
deps = CMakeDeps(self)
deps.generate()
def build(self):
# Use CMake to generate the config file through existing config system
from conan.tools.cmake import CMake
cmake = CMake(self)
# Configure with minimal options - just enough to generate the config file
cmake.configure(
build_script_folder=None,
cli_args=["-DENABLE_TESTING=OFF"],
)
# No need to build anything, just configure to generate the config file
def package(self):
copy(self, "*.hpp", src=self.source_folder, dst=self.package_folder)
# Copy header file
copy(
self,
"folding.hpp",
src=self.source_folder,
dst=self.package_folder,
keep_path=False,
)
# Copy the generated config file from CMake build folder
copy(
self,
"folding_config.h",
src=f"{self.build_folder}/configured_files/include",
dst=self.package_folder,
keep_path=False,
)
# Copy license and readme for package documentation
copy(
self,
"LICENSE",
src=self.source_folder,
dst=self.package_folder,
keep_path=False,
)
copy(
self,
"README.md",
src=self.source_folder,
dst=self.package_folder,
keep_path=False,
)
def package_info(self):
# Header-only library configuration
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
# Set include directory (header will be in package root)
self.cpp_info.includedirs = ["."]

4
config/CMakeLists.txt Normal file
View File

@@ -0,0 +1,4 @@
configure_file(
"config.h.in"
"${CMAKE_BINARY_DIR}/configured_files/include/folding_config.h" ESCAPE_QUOTES
)

12
config/config.h.in Normal file
View File

@@ -0,0 +1,12 @@
#pragma once
#define FOLDING_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define FOLDING_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define FOLDING_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define FOLDING_VERSION "@PROJECT_VERSION@"
static constexpr std::string_view folding_project_name = "@PROJECT_NAME@";
static constexpr std::string_view folding_project_version = "@PROJECT_VERSION@";
static constexpr std::string_view folding_project_description = "@PROJECT_DESCRIPTION@";
static constexpr std::string_view folding_data_path = "@Folding_SOURCE_DIR@/tests/data/";

View File

@@ -10,8 +10,8 @@
#include <map>
#include <random>
#include <vector>
#include <folding_config.h>
namespace folding {
const std::string FOLDING_VERSION = "1.1.1";
class Fold {
public:
inline Fold(int k, int n, int seed = -1) : k(k), n(n), seed(seed)

View File

@@ -9,10 +9,11 @@
#include <catch2/generators/catch_generators.hpp>
#include "TestUtils.h"
#include "folding.hpp"
#include <folding_config.h>
TEST_CASE("Version Test", "[Folding]")
{
std::string actual_version = "1.1.1";
std::string actual_version = FOLDING_VERSION;
auto data = std::vector<int>(100);
folding::StratifiedKFold stratified_kfold(5, data, 17);
REQUIRE(stratified_kfold.version() == actual_version);

View File

@@ -8,6 +8,7 @@
#include <tuple>
#include "ArffFiles.hpp"
#include "fimdlp/CPPFImdlp.h"
#include "folding_config.h"
bool file_exists(const std::string& name);
std::pair<vector<mdlp::labels_t>, map<std::string, int>> discretize(std::vector<mdlp::samples_t>& X, mdlp::labels_t& y, std::vector<string> features);
@@ -44,11 +45,12 @@ class Paths {
public:
static std::string datasets()
{
return "data/";
std::string result = { folding_data_path.begin(), folding_data_path.end() };
return result + "/";
}
static std::string csv()
{
return "../../tests/csv/";
return datasets() + "../csv/";
}
};
class CSVFiles {
@@ -73,4 +75,4 @@ public:
return indices;
}
};
#endif //TEST_UTILS_H
#endif //TEST_UTILS_H