mirror of
https://github.com/rmontanana/mdlp.git
synced 2025-08-15 15:35:55 +00:00
Refactor library version and installation
This commit is contained in:
@@ -1,11 +1,24 @@
|
|||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
project(fimdlp)
|
project(fimdlp
|
||||||
|
LANGUAGES CXX
|
||||||
|
DESCRIPTION "Discretization algorithm based on the paper by Fayyad & Irani Multi-Interval Discretization of Continuous-Valued Attributes for Classification Learning."
|
||||||
|
HOMEPAGE_URL "https://github.com/rmontanana/mdlp"
|
||||||
|
VERSION 2.0.1
|
||||||
|
)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
cmake_policy(SET CMP0135 NEW)
|
cmake_policy(SET CMP0135 NEW)
|
||||||
|
|
||||||
find_package(Torch CONFIG REQUIRED)
|
find_package(Torch CONFIG REQUIRED)
|
||||||
|
|
||||||
|
# Options
|
||||||
|
# -------
|
||||||
|
option(ENABLE_TESTING OFF)
|
||||||
|
option(ENABLE_SAMPLE OFF)
|
||||||
|
option(COVERAGE OFF)
|
||||||
|
|
||||||
|
add_subdirectory(config)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-elide-constructors")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-elide-constructors")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
||||||
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||||
@@ -13,23 +26,24 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_TESTING)
|
if (ENABLE_TESTING)
|
||||||
MESSAGE("Debug mode")
|
message("Debug mode")
|
||||||
enable_testing()
|
enable_testing()
|
||||||
set(CODE_COVERAGE ON)
|
set(CODE_COVERAGE ON)
|
||||||
SET(GCC_COVERAGE_LINK_FLAGS " ${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
set(GCC_COVERAGE_LINK_FLAGS "${GCC_COVERAGE_LINK_FLAGS} -lgcov --coverage")
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
else(ENABLE_TESTING)
|
else()
|
||||||
MESSAGE("Release mode")
|
message("Release mode")
|
||||||
endif(ENABLE_TESTING)
|
endif()
|
||||||
|
|
||||||
if (ENABLE_SAMPLE)
|
if (ENABLE_SAMPLE)
|
||||||
message("Building sample")
|
message("Building sample")
|
||||||
add_subdirectory(sample)
|
add_subdirectory(sample)
|
||||||
endif(ENABLE_SAMPLE)
|
endif()
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${TORCH_INCLUDE_DIRS}
|
${TORCH_INCLUDE_DIRS}
|
||||||
${fimdlp_SOURCE_DIR}/src
|
${fimdlp_SOURCE_DIR}/src
|
||||||
|
${CMAKE_BINARY_DIR}/configured_files/include
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(fimdlp src/CPPFImdlp.cpp src/Metrics.cpp src/BinDisc.cpp src/Discretizer.cpp)
|
add_library(fimdlp src/CPPFImdlp.cpp src/Metrics.cpp src/BinDisc.cpp src/Discretizer.cpp)
|
||||||
@@ -37,8 +51,29 @@ target_link_libraries(fimdlp "${TORCH_LIBRARIES}")
|
|||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
# ------------
|
# ------------
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
write_basic_package_version_file(
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/fimdlpConfigVersion.cmake"
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY AnyNewerVersion
|
||||||
|
)
|
||||||
|
|
||||||
install(TARGETS fimdlp
|
install(TARGETS fimdlp
|
||||||
|
EXPORT fimdlpTargets
|
||||||
ARCHIVE DESTINATION lib
|
ARCHIVE DESTINATION lib
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
CONFIGURATIONS Release)
|
CONFIGURATIONS Release)
|
||||||
|
|
||||||
install(DIRECTORY src/ DESTINATION include/fimdlp FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h")
|
install(DIRECTORY src/ DESTINATION include/fimdlp FILES_MATCHING CONFIGURATIONS Release PATTERN "*.h")
|
||||||
|
install(FILES ${CMAKE_BINARY_DIR}/configured_files/include/config.h DESTINATION include/fimdlp CONFIGURATIONS Release)
|
||||||
|
|
||||||
|
install(EXPORT fimdlpTargets
|
||||||
|
FILE fimdlpTargets.cmake
|
||||||
|
NAMESPACE fimdlp::
|
||||||
|
DESTINATION lib/cmake/fimdlp)
|
||||||
|
|
||||||
|
configure_file(fimdlpConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/fimdlpConfig.cmake" @ONLY)
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/fimdlpConfig.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/fimdlpConfigVersion.cmake"
|
||||||
|
DESTINATION lib/cmake/fimdlp)
|
||||||
|
|
||||||
|
4
config/CMakeLists.txt
Normal file
4
config/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
configure_file(
|
||||||
|
"config.h.in"
|
||||||
|
"${CMAKE_BINARY_DIR}/configured_files/include/config.h" ESCAPE_QUOTES
|
||||||
|
)
|
13
config/config.h.in
Normal file
13
config/config.h.in
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#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_version = "@PROJECT_VERSION@";
|
||||||
|
static constexpr std::string_view project_description = "@PROJECT_DESCRIPTION@";
|
||||||
|
static constexpr std::string_view git_sha = "@GIT_SHA@";
|
2
fimdlpConfig.cmake.in
Normal file
2
fimdlpConfig.cmake.in
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/fimdlpTargets.cmake")
|
@@ -5,6 +5,7 @@ set(CMAKE_BUILD_TYPE Debug)
|
|||||||
include_directories(
|
include_directories(
|
||||||
${fimdlp_SOURCE_DIR}/src
|
${fimdlp_SOURCE_DIR}/src
|
||||||
${fimdlp_SOURCE_DIR}/tests/lib/Files
|
${fimdlp_SOURCE_DIR}/tests/lib/Files
|
||||||
|
${CMAKE_BINARY_DIR}/configured_files/include
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(sample sample.cpp )
|
add_executable(sample sample.cpp )
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "typesFImdlp.h"
|
#include "typesFImdlp.h"
|
||||||
#include <torch/torch.h>
|
#include <torch/torch.h>
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
namespace mdlp {
|
namespace mdlp {
|
||||||
enum class bound_dir_t {
|
enum class bound_dir_t {
|
||||||
@@ -29,7 +30,7 @@ namespace mdlp {
|
|||||||
void fit_t(const torch::Tensor& X_, const torch::Tensor& y_);
|
void fit_t(const torch::Tensor& X_, const torch::Tensor& y_);
|
||||||
torch::Tensor transform_t(const torch::Tensor& X_);
|
torch::Tensor transform_t(const torch::Tensor& X_);
|
||||||
torch::Tensor fit_transform_t(const torch::Tensor& X_, const torch::Tensor& y_);
|
torch::Tensor fit_transform_t(const torch::Tensor& X_, const torch::Tensor& y_);
|
||||||
static inline std::string version() { return "2.0.1"; };
|
static inline std::string version() { return { project_version.begin(), project_version.end() };; };
|
||||||
protected:
|
protected:
|
||||||
labels_t discretizedData = labels_t();
|
labels_t discretizedData = labels_t();
|
||||||
cutPoints_t cutPoints; // At least two cutpoints must be provided, the first and the last will be ignored in transform
|
cutPoints_t cutPoints; // At least two cutpoints must be provided, the first and the last will be ignored in transform
|
||||||
|
@@ -12,6 +12,7 @@ include_directories(
|
|||||||
${TORCH_INCLUDE_DIRS}
|
${TORCH_INCLUDE_DIRS}
|
||||||
${fimdlp_SOURCE_DIR}/src
|
${fimdlp_SOURCE_DIR}/src
|
||||||
${fimdlp_SOURCE_DIR}/tests/lib/Files
|
${fimdlp_SOURCE_DIR}/tests/lib/Files
|
||||||
|
${CMAKE_BINARY_DIR}/configured_files/include
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(Metrics_unittest ${fimdlp_SOURCE_DIR}/src/Metrics.cpp Metrics_unittest.cpp)
|
add_executable(Metrics_unittest ${fimdlp_SOURCE_DIR}/src/Metrics.cpp Metrics_unittest.cpp)
|
||||||
|
Reference in New Issue
Block a user