Begin adding conan dependency manager

This commit is contained in:
2025-06-28 01:27:22 +02:00
parent e068bf0a54
commit 059fd33b4e
8 changed files with 183 additions and 22 deletions

View File

@@ -1,5 +1,8 @@
import re
from conan import ConanFile, CMake
import os
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps
from conan.tools.files import save, load
class FimdlpConan(ConanFile):
name = "fimdlp"
@@ -10,25 +13,29 @@ class FimdlpConan(ConanFile):
description = "Discretization algorithm based on the paper by Fayyad & Irani."
topics = ("discretization", "classification", "machine learning")
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
exports_sources = "src/*", "CMakeLists.txt", "README.md"
exports_sources = "src/*", "CMakeLists.txt", "README.md", "config/*", "fimdlpConfig.cmake.in"
def init(self):
def set_version(self):
# Read the CMakeLists.txt file to get the version
# This is a simple example; you might want to use a more robust method
# to parse the CMakeLists.txt file.
# For example, you could use a regex to extract the version number.
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)
try:
content = load(self, "CMakeLists.txt")
match = re.search(r"VERSION\s+(\d+\.\d+\.\d+)", content)
if match:
self.version = match.group(1)
except Exception:
self.version = "2.0.1" # fallback version
def requirements(self):
self.requires("libtorch/2.7.0") # Adjust version as necessary
self.requires("libtorch/2.7.0")
def layout(self):
cmake_layout(self)
def generate(self):
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.generate()
def build(self):
cmake = CMake(self)
@@ -36,10 +43,13 @@ class FimdlpConan(ConanFile):
cmake.build()
def package(self):
# self.copy("*.h", dst="include", src="src/include")
# self.copy("*fimdlp*", dst="lib", keep_path=False)
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.libs = ["fimdlp"]
self.cpp_info.libs = ["fimdlp"]
self.cpp_info.includedirs = ["include"]
self.cpp_info.libdirs = ["lib"]
self.cpp_info.set_property("cmake_find_mode", "both")
self.cpp_info.set_property("cmake_target_name", "fimdlp::fimdlp")
self.cpp_info.set_property("cmake_file_name", "fimdlp")