mirror of
https://github.com/rmontanana/mdlp.git
synced 2025-08-15 07:25:56 +00:00
Update build method
This commit is contained in:
11
.conan/profiles/default
Normal file
11
.conan/profiles/default
Normal file
@@ -0,0 +1,11 @@
|
||||
[settings]
|
||||
os=Linux
|
||||
arch=x86_64
|
||||
compiler=gcc
|
||||
compiler.version=11
|
||||
compiler.libcxx=libstdc++11
|
||||
build_type=Release
|
||||
|
||||
[conf]
|
||||
tools.system.package_manager:mode=install
|
||||
tools.system.package_manager:sudo=True
|
@@ -9,6 +9,7 @@ project(fimdlp
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
|
||||
# Find dependencies
|
||||
find_package(Torch REQUIRED)
|
||||
|
||||
# Options
|
||||
|
@@ -4,6 +4,7 @@
|
||||
"conan": {}
|
||||
},
|
||||
"include": [
|
||||
"build/Release/generators/CMakePresets.json"
|
||||
"build_release/build/Release/generators/CMakePresets.json",
|
||||
"build_debug/build/Debug/generators/CMakePresets.json"
|
||||
]
|
||||
}
|
153
CONAN_README.md
Normal file
153
CONAN_README.md
Normal file
@@ -0,0 +1,153 @@
|
||||
# Conan Package for fimdlp
|
||||
|
||||
This directory contains the Conan package configuration for the fimdlp library.
|
||||
|
||||
## Dependencies
|
||||
|
||||
The package manages the following dependencies:
|
||||
|
||||
### Build Requirements
|
||||
- **libtorch/2.4.1** - PyTorch C++ library for tensor operations
|
||||
|
||||
### Test Requirements (when testing enabled)
|
||||
- **catch2/3.8.1** - Modern C++ testing framework
|
||||
- **arff-files** - ARFF file format support (included locally in tests/lib/Files/)
|
||||
|
||||
## Building with Conan
|
||||
|
||||
### 1. Install Dependencies and Build
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
conan install . --output-folder=build --build=missing
|
||||
|
||||
# Build the project
|
||||
cd build
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
### 2. Using the Build Script
|
||||
|
||||
```bash
|
||||
# Build release version
|
||||
./scripts/build_conan.sh
|
||||
|
||||
# Build with tests
|
||||
./scripts/build_conan.sh --test
|
||||
```
|
||||
|
||||
## Creating a Package
|
||||
|
||||
### 1. Create Package Locally
|
||||
|
||||
```bash
|
||||
conan create . --profile:build=default --profile:host=default
|
||||
```
|
||||
|
||||
### 2. Create Package with Options
|
||||
|
||||
```bash
|
||||
# Create with testing enabled
|
||||
conan create . -o enable_testing=True --profile:build=default --profile:host=default
|
||||
|
||||
# Create shared library version
|
||||
conan create . -o shared=True --profile:build=default --profile:host=default
|
||||
```
|
||||
|
||||
### 3. Using the Package Creation Script
|
||||
|
||||
```bash
|
||||
./scripts/create_package.sh
|
||||
```
|
||||
|
||||
## Uploading to Cimmeria
|
||||
|
||||
### 1. Configure Remote
|
||||
|
||||
```bash
|
||||
# Add Cimmeria remote
|
||||
conan remote add cimmeria <cimmeria-server-url>
|
||||
|
||||
# Login to Cimmeria
|
||||
conan remote login cimmeria <username>
|
||||
```
|
||||
|
||||
### 2. Upload Package
|
||||
|
||||
```bash
|
||||
# Upload the package
|
||||
conan upload fimdlp/2.1.0 --remote=cimmeria --all
|
||||
|
||||
# Or use the script (will configure remote instructions if not set up)
|
||||
./scripts/create_package.sh
|
||||
```
|
||||
|
||||
## Using the Package
|
||||
|
||||
### In conanfile.txt
|
||||
|
||||
```ini
|
||||
[requires]
|
||||
fimdlp/2.1.0
|
||||
|
||||
[generators]
|
||||
CMakeDeps
|
||||
CMakeToolchain
|
||||
```
|
||||
|
||||
### In conanfile.py
|
||||
|
||||
```python
|
||||
def requirements(self):
|
||||
self.requires("fimdlp/2.1.0")
|
||||
```
|
||||
|
||||
### In CMakeLists.txt
|
||||
|
||||
```cmake
|
||||
find_package(fimdlp REQUIRED)
|
||||
target_link_libraries(your_target fimdlp::fimdlp)
|
||||
```
|
||||
|
||||
## Package Options
|
||||
|
||||
| Option | Values | Default | Description |
|
||||
|--------|--------|---------|-------------|
|
||||
| shared | True/False | False | Build shared library |
|
||||
| fPIC | True/False | True | Position independent code |
|
||||
| enable_testing | True/False | False | Enable test suite |
|
||||
| enable_sample | True/False | False | Build sample program |
|
||||
|
||||
## Example Usage
|
||||
|
||||
```cpp
|
||||
#include <fimdlp/CPPFImdlp.h>
|
||||
#include <fimdlp/Metrics.h>
|
||||
|
||||
int main() {
|
||||
// Create MDLP discretizer
|
||||
CPPFImdlp discretizer;
|
||||
|
||||
// Calculate entropy
|
||||
Metrics metrics;
|
||||
std::vector<int> labels = {0, 1, 0, 1, 1};
|
||||
double entropy = metrics.entropy(labels);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
The package includes comprehensive tests that can be enabled with:
|
||||
|
||||
```bash
|
||||
conan create . -o enable_testing=True
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- C++17 compatible compiler
|
||||
- CMake 3.20 or later
|
||||
- Conan 2.0 or later
|
42
Makefile
42
Makefile
@@ -1,35 +1,41 @@
|
||||
SHELL := /bin/bash
|
||||
.DEFAULT_GOAL := build
|
||||
.PHONY: build test
|
||||
.PHONY: build install test
|
||||
lcov := lcov
|
||||
|
||||
build:
|
||||
@if [ -d build_release ]; then rm -fr build_release; fi
|
||||
@mkdir build_release
|
||||
@cmake -B build_release -S . -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=OFF -DENABLE_SAMPLE=ON
|
||||
@cmake --build build_release -j 8
|
||||
f_debug = build_debug
|
||||
f_release = build_release
|
||||
|
||||
install:
|
||||
build: ## Build the project for Release
|
||||
@echo ">>> Building the project for Release..."
|
||||
@if [ -d $(f_release) ]; then rm -fr $(f_release); fi
|
||||
@conan install . --build=missing -of $(f_release) -s build_type=Release --profile:build=default --profile:host=default
|
||||
cmake -S . -B $(f_release) -DCMAKE_TOOLCHAIN_FILE=$(f_release)/build/Release/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=OFF -DENABLE_SAMPLE=ON
|
||||
@cmake --build $(f_release) -j 8
|
||||
|
||||
install: ## Install the project
|
||||
@echo ">>> Installing the project..."
|
||||
@cmake --build build_release --target install -j 8
|
||||
|
||||
test:
|
||||
@if [ -d build_debug ]; then rm -fr build_debug; fi
|
||||
@mkdir build_debug
|
||||
@cmake -B build_debug -S . -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=ON -DENABLE_SAMPLE=ON
|
||||
@cmake --build build_debug -j 8
|
||||
@cd build_debug/tests && ctest --output-on-failure -j 8
|
||||
@cd build_debug/tests && $(lcov) --capture --directory ../ --demangle-cpp --ignore-errors source,source --ignore-errors mismatch --output-file coverage.info >/dev/null 2>&1; \
|
||||
test: ## Build Debug version and run tests
|
||||
@echo ">>> Building Debug version and running tests..."
|
||||
@if [ -d $(f_debug) ]; then rm -fr $(f_debug); fi
|
||||
@conan install . --build=missing -of $(f_debug) -s build_type=Debug
|
||||
@cmake -B $(f_debug) -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=$(f_debug)/build/Debug/generators/conan_toolchain.cmake -DENABLE_TESTING=ON -DENABLE_SAMPLE=ON
|
||||
@cmake --build $(f_debug) -j 8
|
||||
@cd $(f_debug)/tests && ctest --output-on-failure -j 8
|
||||
@cd $(f_debug)/tests && $(lcov) --capture --directory ../ --demangle-cpp --ignore-errors source,source --ignore-errors mismatch --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info '/usr/*' --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info 'lib/*' --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info 'libtorch/*' --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info 'tests/*' --output-file coverage.info >/dev/null 2>&1; \
|
||||
$(lcov) --remove coverage.info 'gtest/*' --output-file coverage.info >/dev/null 2>&1;
|
||||
@genhtml build_debug/tests/coverage.info --demangle-cpp --output-directory build_debug/tests/coverage --title "Discretizer mdlp Coverage Report" -s -k -f --legend
|
||||
@echo "* Coverage report is generated at build_debug/tests/coverage/index.html"
|
||||
@genhtml $(f_debug)/tests/coverage.info --demangle-cpp --output-directory $(f_debug)/tests/coverage --title "Discretizer mdlp Coverage Report" -s -k -f --legend
|
||||
@echo "* Coverage report is generated at $(f_debug)/tests/coverage/index.html"
|
||||
@which python || (echo ">>> Please install python"; exit 1)
|
||||
@if [ ! -f build_debug/tests/coverage.info ]; then \
|
||||
@if [ ! -f $(f_debug)/tests/coverage.info ]; then \
|
||||
echo ">>> No coverage.info file found!"; \
|
||||
exit 1; \
|
||||
fi
|
||||
@echo ">>> Updating coverage badge..."
|
||||
@env python update_coverage.py build_debug/tests
|
||||
@env python update_coverage.py $(f_debug)/tests
|
101
build_conan/CMakeCache.txt
Normal file
101
build_conan/CMakeCache.txt
Normal file
@@ -0,0 +1,101 @@
|
||||
# This is the CMakeCache file.
|
||||
# For build in directory: /home/rmontanana/Code/mdlp/build_conan
|
||||
# It was generated by CMake: /usr/bin/cmake
|
||||
# You can edit this file to change values found and used by cmake.
|
||||
# If you do not want to change any of the values, simply exit the editor.
|
||||
# If you do want to change a value, simply edit, save, and exit the editor.
|
||||
# The syntax for the file is as follows:
|
||||
# KEY:TYPE=VALUE
|
||||
# KEY is the name of a variable in the cache.
|
||||
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
|
||||
# VALUE is the current value for the KEY.
|
||||
|
||||
########################
|
||||
# EXTERNAL cache entries
|
||||
########################
|
||||
|
||||
//No help, variable specified on the command line.
|
||||
CMAKE_BUILD_TYPE:UNINITIALIZED=Release
|
||||
|
||||
//Value Computed by CMake.
|
||||
CMAKE_FIND_PACKAGE_REDIRECTS_DIR:STATIC=/home/rmontanana/Code/mdlp/build_conan/CMakeFiles/pkgRedirects
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_DESCRIPTION:STATIC=Discretization algorithm based on the paper by Fayyad & Irani Multi-Interval Discretization of Continuous-Valued Attributes for Classification Learning.
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=https://github.com/rmontanana/mdlp
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_NAME:STATIC=fimdlp
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION:STATIC=2.1.0
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_MAJOR:STATIC=2
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_MINOR:STATIC=1
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_PATCH:STATIC=0
|
||||
|
||||
//Value Computed by CMake
|
||||
CMAKE_PROJECT_VERSION_TWEAK:STATIC=
|
||||
|
||||
//No help, variable specified on the command line.
|
||||
CMAKE_TOOLCHAIN_FILE:UNINITIALIZED=conan_toolchain.cmake
|
||||
|
||||
//Value Computed by CMake
|
||||
fimdlp_BINARY_DIR:STATIC=/home/rmontanana/Code/mdlp/build_conan
|
||||
|
||||
//Value Computed by CMake
|
||||
fimdlp_IS_TOP_LEVEL:STATIC=ON
|
||||
|
||||
//Value Computed by CMake
|
||||
fimdlp_SOURCE_DIR:STATIC=/home/rmontanana/Code/mdlp
|
||||
|
||||
|
||||
########################
|
||||
# INTERNAL cache entries
|
||||
########################
|
||||
|
||||
//This is the directory where this CMakeCache.txt was created
|
||||
CMAKE_CACHEFILE_DIR:INTERNAL=/home/rmontanana/Code/mdlp/build_conan
|
||||
//Major version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
|
||||
//Minor version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_MINOR_VERSION:INTERNAL=30
|
||||
//Patch version of cmake used to create the current loaded cache
|
||||
CMAKE_CACHE_PATCH_VERSION:INTERNAL=8
|
||||
//Path to CMake executable.
|
||||
CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
|
||||
//Path to cpack program executable.
|
||||
CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
|
||||
//Path to ctest program executable.
|
||||
CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
|
||||
//Path to cache edit program executable.
|
||||
CMAKE_EDIT_COMMAND:INTERNAL=/usr/bin/ccmake
|
||||
//Name of external makefile project generator.
|
||||
CMAKE_EXTRA_GENERATOR:INTERNAL=
|
||||
//Name of generator.
|
||||
CMAKE_GENERATOR:INTERNAL=Unix Makefiles
|
||||
//Generator instance identifier.
|
||||
CMAKE_GENERATOR_INSTANCE:INTERNAL=
|
||||
//Name of generator platform.
|
||||
CMAKE_GENERATOR_PLATFORM:INTERNAL=
|
||||
//Name of generator toolset.
|
||||
CMAKE_GENERATOR_TOOLSET:INTERNAL=
|
||||
//Source directory with the top level CMakeLists.txt file for this
|
||||
// project
|
||||
CMAKE_HOME_DIRECTORY:INTERNAL=/home/rmontanana/Code/mdlp
|
||||
//number of local generators
|
||||
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
|
||||
//Platform information initialized
|
||||
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
|
||||
//Path to CMake installation.
|
||||
CMAKE_ROOT:INTERNAL=/usr/share/cmake
|
||||
//uname command
|
||||
CMAKE_UNAME:INTERNAL=/usr/bin/uname
|
||||
|
16
conandata.yml
Normal file
16
conandata.yml
Normal file
@@ -0,0 +1,16 @@
|
||||
sources:
|
||||
"2.1.0":
|
||||
url: "https://github.com/rmontanana/mdlp/archive/refs/tags/v2.1.0.tar.gz"
|
||||
sha256: "placeholder_sha256_hash"
|
||||
"2.0.1":
|
||||
url: "https://github.com/rmontanana/mdlp/archive/refs/tags/v2.0.1.tar.gz"
|
||||
sha256: "placeholder_sha256_hash"
|
||||
"2.0.0":
|
||||
url: "https://github.com/rmontanana/mdlp/archive/refs/tags/v2.0.0.tar.gz"
|
||||
sha256: "placeholder_sha256_hash"
|
||||
|
||||
patches:
|
||||
"2.1.0":
|
||||
- patch_file: "patches/001-cmake-fix.patch"
|
||||
patch_description: "Fix CMake configuration for Conan compatibility"
|
||||
patch_type: "portability"
|
90
conanfile.py
90
conanfile.py
@@ -1,8 +1,8 @@
|
||||
import re
|
||||
import os
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps
|
||||
from conan.tools.files import save, load
|
||||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
|
||||
from conan.tools.files import copy
|
||||
import os
|
||||
|
||||
|
||||
class FimdlpConan(ConanFile):
|
||||
name = "fimdlp"
|
||||
@@ -10,10 +10,26 @@ class FimdlpConan(ConanFile):
|
||||
license = "MIT"
|
||||
author = "Ricardo Montañana <rmontanana@gmail.com>"
|
||||
url = "https://github.com/rmontanana/mdlp"
|
||||
description = "Discretization algorithm based on the paper by Fayyad & Irani."
|
||||
topics = ("discretization", "classification", "machine learning")
|
||||
description = "Discretization algorithm based on the paper by Fayyad & Irani Multi-Interval Discretization of Continuous-Valued Attributes for Classification Learning."
|
||||
topics = ("machine-learning", "discretization", "mdlp", "classification")
|
||||
|
||||
# Package configuration
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
exports_sources = "src/*", "CMakeLists.txt", "README.md", "config/*", "fimdlpConfig.cmake.in"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"enable_testing": [True, False],
|
||||
"enable_sample": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"enable_testing": False,
|
||||
"enable_sample": False,
|
||||
}
|
||||
|
||||
# Sources are located in the same place as this recipe, copy them to the recipe
|
||||
exports_sources = "CMakeLists.txt", "src/*", "sample/*", "tests/*", "config/*", "fimdlpConfig.cmake.in"
|
||||
|
||||
def set_version(self):
|
||||
# Read the CMakeLists.txt file to get the version
|
||||
@@ -23,33 +39,75 @@ class FimdlpConan(ConanFile):
|
||||
if match:
|
||||
self.version = match.group(1)
|
||||
except Exception:
|
||||
self.version = "2.0.1" # fallback version
|
||||
|
||||
self.version = "0.0.1" # fallback version
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
self.options.rm_safe("fPIC")
|
||||
|
||||
def configure(self):
|
||||
if self.options.shared:
|
||||
self.options.rm_safe("fPIC")
|
||||
|
||||
def requirements(self):
|
||||
# PyTorch dependency for tensor operations
|
||||
self.requires("libtorch/2.7.0")
|
||||
|
||||
def build_requirements(self):
|
||||
# Test dependencies - only when testing is enabled
|
||||
if self.options.enable_testing:
|
||||
self.requires("catch2/3.8.1")
|
||||
# Note: arff-files is included as a local copy, but could be a conan dependency
|
||||
# For now, we'll use the local version in tests/lib/Files/
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
|
||||
def generate(self):
|
||||
# Generate CMake configuration files
|
||||
deps = CMakeDeps(self)
|
||||
deps.generate()
|
||||
|
||||
tc = CMakeToolchain(self)
|
||||
# Set CMake variables based on options
|
||||
tc.variables["ENABLE_TESTING"] = self.options.enable_testing
|
||||
tc.variables["ENABLE_SAMPLE"] = self.options.enable_sample
|
||||
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
|
||||
tc.generate()
|
||||
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
|
||||
# Run tests if enabled
|
||||
if self.options.enable_testing:
|
||||
cmake.test()
|
||||
|
||||
def package(self):
|
||||
# Install using CMake
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
|
||||
|
||||
# Copy license file
|
||||
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
|
||||
|
||||
def package_info(self):
|
||||
# Library configuration
|
||||
self.cpp_info.libs = ["fimdlp"]
|
||||
self.cpp_info.includedirs = ["include"]
|
||||
self.cpp_info.libdirs = ["lib"]
|
||||
self.cpp_info.set_property("cmake_find_mode", "both")
|
||||
|
||||
# CMake package configuration
|
||||
self.cpp_info.set_property("cmake_file_name", "fimdlp")
|
||||
self.cpp_info.set_property("cmake_target_name", "fimdlp::fimdlp")
|
||||
self.cpp_info.set_property("cmake_file_name", "fimdlp")
|
||||
|
||||
# Compiler features
|
||||
self.cpp_info.cppstd = "17"
|
||||
|
||||
# System libraries (if needed)
|
||||
if self.settings.os in ["Linux", "FreeBSD"]:
|
||||
self.cpp_info.system_libs.append("m") # Math library
|
||||
self.cpp_info.system_libs.append("pthread") # Threading
|
||||
|
||||
# Build information for consumers
|
||||
self.cpp_info.builddirs = ["lib/cmake/fimdlp"]
|
@@ -2,11 +2,14 @@ set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
|
||||
find_package(Torch REQUIRED)
|
||||
|
||||
include_directories(
|
||||
${fimdlp_SOURCE_DIR}/src
|
||||
${fimdlp_SOURCE_DIR}/tests/lib/Files
|
||||
${CMAKE_BINARY_DIR}/configured_files/include
|
||||
${libtorch_INCLUDE_DIRS_RELEASE}
|
||||
)
|
||||
|
||||
add_executable(sample sample.cpp )
|
||||
target_link_libraries(sample fimdlp "${TORCH_LIBRARIES}")
|
||||
target_link_libraries(sample PRIVATE fimdlp torch::torch)
|
||||
|
25
scripts/build_conan.sh
Executable file
25
scripts/build_conan.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Build script for fimdlp using Conan
|
||||
set -e
|
||||
|
||||
echo "Building fimdlp with Conan..."
|
||||
|
||||
# Clean previous builds
|
||||
rm -rf build_conan
|
||||
|
||||
# Install dependencies and build
|
||||
conan install . --output-folder=build_conan --build=missing --profile:build=default --profile:host=default
|
||||
|
||||
# Build the project
|
||||
cd build_conan
|
||||
cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build .
|
||||
|
||||
echo "Build completed successfully!"
|
||||
|
||||
# Run tests if requested
|
||||
if [ "$1" = "--test" ]; then
|
||||
echo "Running tests..."
|
||||
ctest --output-on-failure
|
||||
fi
|
33
scripts/create_package.sh
Executable file
33
scripts/create_package.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to create and upload fimdlp Conan package
|
||||
set -e
|
||||
|
||||
PACKAGE_NAME="fimdlp"
|
||||
PACKAGE_VERSION="2.1.0"
|
||||
REMOTE_NAME="cimmeria"
|
||||
|
||||
echo "Creating Conan package for $PACKAGE_NAME/$PACKAGE_VERSION..."
|
||||
|
||||
# Create the package
|
||||
conan create . --profile:build=default --profile:host=default
|
||||
|
||||
echo "Package created successfully!"
|
||||
|
||||
# Test the package
|
||||
echo "Testing package..."
|
||||
conan test test_package $PACKAGE_NAME/$PACKAGE_VERSION@ --profile:build=default --profile:host=default
|
||||
|
||||
echo "Package tested successfully!"
|
||||
|
||||
# Upload to Cimmeria (if remote is configured)
|
||||
if conan remote list | grep -q "$REMOTE_NAME"; then
|
||||
echo "Uploading package to $REMOTE_NAME..."
|
||||
conan upload $PACKAGE_NAME/$PACKAGE_VERSION --remote=$REMOTE_NAME --all
|
||||
echo "Package uploaded to $REMOTE_NAME successfully!"
|
||||
else
|
||||
echo "Remote '$REMOTE_NAME' not configured. To upload the package:"
|
||||
echo "1. Add the remote: conan remote add $REMOTE_NAME <cimmeria-url>"
|
||||
echo "2. Login: conan remote login $REMOTE_NAME <username>"
|
||||
echo "3. Upload: conan upload $PACKAGE_NAME/$PACKAGE_VERSION --remote=$REMOTE_NAME --all"
|
||||
fi
|
8
test_package/CMakeLists.txt
Normal file
8
test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
project(test_fimdlp)
|
||||
|
||||
find_package(fimdlp REQUIRED)
|
||||
|
||||
add_executable(test_fimdlp src/test_fimdlp.cpp)
|
||||
target_link_libraries(test_fimdlp fimdlp::fimdlp)
|
||||
target_compile_features(test_fimdlp PRIVATE cxx_std_17)
|
28
test_package/conanfile.py
Normal file
28
test_package/conanfile.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
from conan import ConanFile
|
||||
from conan.tools.cmake import CMake, cmake_layout
|
||||
from conan.tools.build import can_run
|
||||
|
||||
|
||||
class FimdlpTestConan(ConanFile):
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
# VirtualBuildEnv and VirtualRunEnv can be avoided if "tools.env:CONAN_RUN_TESTS" is false
|
||||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
|
||||
apply_env = False # avoid the default VirtualBuildEnv from the base class
|
||||
test_type = "explicit"
|
||||
|
||||
def requirements(self):
|
||||
self.requires(self.tested_reference_str)
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
if can_run(self):
|
||||
cmd = os.path.join(self.cpp.build.bindir, "test_fimdlp")
|
||||
self.run(cmd, env="conanrun")
|
27
test_package/src/test_fimdlp.cpp
Normal file
27
test_package/src/test_fimdlp.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <fimdlp/CPPFImdlp.h>
|
||||
#include <fimdlp/Metrics.h>
|
||||
|
||||
int main() {
|
||||
std::cout << "Testing fimdlp library..." << std::endl;
|
||||
|
||||
// Simple test of the library
|
||||
try {
|
||||
// Test Metrics class
|
||||
Metrics metrics;
|
||||
std::vector<int> labels = {0, 0, 1, 1, 0, 1};
|
||||
double entropy = metrics.entropy(labels);
|
||||
std::cout << "Entropy calculated: " << entropy << std::endl;
|
||||
|
||||
// Test CPPFImdlp creation
|
||||
CPPFImdlp discretizer;
|
||||
std::cout << "CPPFImdlp instance created successfully" << std::endl;
|
||||
|
||||
std::cout << "fimdlp library test completed successfully!" << std::endl;
|
||||
return 0;
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Error testing fimdlp library: " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
@@ -1,15 +1,25 @@
|
||||
include(FetchContent)
|
||||
include_directories(${GTEST_INCLUDE_DIRS})
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
# Check if we should use Catch2 from Conan or GoogleTest via FetchContent
|
||||
find_package(Catch2 3 QUIET)
|
||||
|
||||
if(Catch2_FOUND)
|
||||
message(STATUS "Using Catch2 from Conan")
|
||||
set(TEST_FRAMEWORK "Catch2")
|
||||
else()
|
||||
message(STATUS "Using GoogleTest via FetchContent")
|
||||
set(TEST_FRAMEWORK "GoogleTest")
|
||||
include(FetchContent)
|
||||
include_directories(${GTEST_INCLUDE_DIRS})
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
|
||||
)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${TORCH_INCLUDE_DIRS}
|
||||
${libtorch_INCLUDE_DIRS_DEBUG}
|
||||
${fimdlp_SOURCE_DIR}/src
|
||||
${fimdlp_SOURCE_DIR}/tests/lib/Files
|
||||
${CMAKE_BINARY_DIR}/configured_files/include
|
||||
|
Reference in New Issue
Block a user