Fix cmakelists
Some checks failed
CI/CD Pipeline / Code Linting (push) Failing after 14s
CI/CD Pipeline / Build and Test (Debug, clang, ubuntu-latest) (push) Failing after 5m7s
CI/CD Pipeline / Build and Test (Debug, gcc, ubuntu-latest) (push) Failing after 5m52s
CI/CD Pipeline / Build and Test (Release, clang, ubuntu-20.04) (push) Failing after 5m47s
CI/CD Pipeline / Build and Test (Release, clang, ubuntu-latest) (push) Failing after 5m13s
CI/CD Pipeline / Build and Test (Release, gcc, ubuntu-20.04) (push) Failing after 5m32s
CI/CD Pipeline / Build and Test (Release, gcc, ubuntu-latest) (push) Failing after 5m46s
CI/CD Pipeline / Docker Build Test (push) Failing after 32s
CI/CD Pipeline / Performance Benchmarks (push) Has been skipped
CI/CD Pipeline / Build Documentation (push) Failing after 21s
CI/CD Pipeline / Create Release Package (push) Has been skipped
Some checks failed
CI/CD Pipeline / Code Linting (push) Failing after 14s
CI/CD Pipeline / Build and Test (Debug, clang, ubuntu-latest) (push) Failing after 5m7s
CI/CD Pipeline / Build and Test (Debug, gcc, ubuntu-latest) (push) Failing after 5m52s
CI/CD Pipeline / Build and Test (Release, clang, ubuntu-20.04) (push) Failing after 5m47s
CI/CD Pipeline / Build and Test (Release, clang, ubuntu-latest) (push) Failing after 5m13s
CI/CD Pipeline / Build and Test (Release, gcc, ubuntu-20.04) (push) Failing after 5m32s
CI/CD Pipeline / Build and Test (Release, gcc, ubuntu-latest) (push) Failing after 5m46s
CI/CD Pipeline / Docker Build Test (push) Failing after 32s
CI/CD Pipeline / Performance Benchmarks (push) Has been skipped
CI/CD Pipeline / Build Documentation (push) Failing after 21s
CI/CD Pipeline / Create Release Package (push) Has been skipped
This commit is contained in:
@@ -6,6 +6,7 @@ project(SVMClassifier
|
|||||||
HOMEPAGE_URL "https://gitea.rmontanana.es/rmontanana/SVMClassifier"
|
HOMEPAGE_URL "https://gitea.rmontanana.es/rmontanana/SVMClassifier"
|
||||||
)
|
)
|
||||||
set(PROJECT_AUTHOR "Ricardo Montañana Gómez")
|
set(PROJECT_AUTHOR "Ricardo Montañana Gómez")
|
||||||
|
|
||||||
# Set C++ standard
|
# Set C++ standard
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
@@ -32,6 +33,7 @@ endif()
|
|||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
# Fetch nlohmann/json
|
# Fetch nlohmann/json
|
||||||
|
set(JSON_Install ON CACHE BOOL "Install nlohmann-json when my project is installed" FORCE)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
nlohmann_json
|
nlohmann_json
|
||||||
GIT_REPOSITORY https://github.com/nlohmann/json.git
|
GIT_REPOSITORY https://github.com/nlohmann/json.git
|
||||||
@@ -52,8 +54,6 @@ add_subdirectory(external)
|
|||||||
|
|
||||||
# Include directories
|
# Include directories
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/external/libsvm)
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/external/liblinear)
|
|
||||||
|
|
||||||
# Create the main library
|
# Create the main library
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
@@ -74,14 +74,14 @@ set(HEADERS
|
|||||||
# Create library
|
# Create library
|
||||||
add_library(svm_classifier STATIC ${SOURCES} ${HEADERS})
|
add_library(svm_classifier STATIC ${SOURCES} ${HEADERS})
|
||||||
|
|
||||||
# Link libraries with PRIVATE linkage to avoid export issues
|
# Link libraries - Updated to use object libraries instead of static libraries
|
||||||
target_link_libraries(svm_classifier
|
target_link_libraries(svm_classifier
|
||||||
PUBLIC
|
PUBLIC
|
||||||
${TORCH_LIBRARIES}
|
${TORCH_LIBRARIES}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
nlohmann_json::nlohmann_json
|
nlohmann_json::nlohmann_json
|
||||||
libsvm_static
|
$<TARGET_OBJECTS:libsvm_objects>
|
||||||
liblinear_static
|
$<TARGET_OBJECTS:liblinear_objects>
|
||||||
)
|
)
|
||||||
|
|
||||||
# Set include directories
|
# Set include directories
|
||||||
@@ -90,10 +90,28 @@ target_include_directories(svm_classifier
|
|||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/external/libsvm
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/external/liblinear
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add include directories from external libraries using variables set by external/CMakeLists.txt
|
||||||
|
if(LIBSVM_INCLUDE_DIR)
|
||||||
|
target_include_directories(svm_classifier
|
||||||
|
PRIVATE ${LIBSVM_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBLINEAR_INCLUDE_DIR)
|
||||||
|
target_include_directories(svm_classifier
|
||||||
|
PRIVATE ${LIBLINEAR_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBLINEAR_BLAS_INCLUDE_DIR)
|
||||||
|
target_include_directories(svm_classifier
|
||||||
|
PRIVATE ${LIBLINEAR_BLAS_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Compiler-specific options
|
# Compiler-specific options
|
||||||
target_compile_features(svm_classifier PUBLIC cxx_std_17)
|
target_compile_features(svm_classifier PUBLIC cxx_std_17)
|
||||||
|
|
||||||
|
@@ -1,39 +1,42 @@
|
|||||||
# SVMClassifierConfig.cmake.in
|
|
||||||
# CMake configuration file for SVMClassifier package
|
|
||||||
|
|
||||||
@PACKAGE_INIT@
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
# Set the version
|
# SVMClassifier package configuration file
|
||||||
set(SVMClassifier_VERSION @PACKAGE_VERSION@)
|
|
||||||
|
|
||||||
# Find required dependencies
|
# Check if components are specified
|
||||||
|
set(_supported_components )
|
||||||
|
|
||||||
|
# Handle components
|
||||||
|
foreach(_comp ${SVMClassifier_FIND_COMPONENTS})
|
||||||
|
if(NOT _comp IN_LIST _supported_components)
|
||||||
|
set(SVMClassifier_FOUND FALSE)
|
||||||
|
set(SVMClassifier_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Include dependencies that are required for using SVMClassifier
|
||||||
|
include(CMakeFindDependencyMacro)
|
||||||
|
|
||||||
|
# Find Torch dependency
|
||||||
find_dependency(Torch REQUIRED)
|
find_dependency(Torch REQUIRED)
|
||||||
find_dependency(PkgConfig REQUIRED)
|
|
||||||
|
|
||||||
# Include nlohmann_json
|
# Note: nlohmann_json, libsvm, and liblinear are linked privately
|
||||||
if(NOT TARGET nlohmann_json::nlohmann_json)
|
# so they don't need to be found here
|
||||||
find_package(nlohmann_json 3.11.0 REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Include the targets file
|
# Include the targets file
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/SVMClassifierTargets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/SVMClassifierTargets.cmake")
|
||||||
|
|
||||||
# Set variables for backward compatibility
|
# Set variables for compatibility
|
||||||
set(SVMClassifier_LIBRARIES SVMClassifier::svm_classifier)
|
set(SVMClassifier_LIBRARIES SVMClassifier::svm_classifier)
|
||||||
set(SVMClassifier_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include")
|
set(SVMClassifier_INCLUDE_DIRS)
|
||||||
|
|
||||||
# Verify that the targets were imported
|
# Get the include directories from the target
|
||||||
if(NOT TARGET SVMClassifier::svm_classifier)
|
get_target_property(_inc_dirs SVMClassifier::svm_classifier INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
message(FATAL_ERROR "SVMClassifier::svm_classifier target not found")
|
if(_inc_dirs)
|
||||||
|
set(SVMClassifier_INCLUDE_DIRS ${_inc_dirs})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Check that all required components have been found
|
||||||
|
check_required_components(SVMClassifier)
|
||||||
|
|
||||||
# Set found flag
|
# Set found flag
|
||||||
set(SVMClassifier_FOUND TRUE)
|
set(SVMClassifier_FOUND TRUE)
|
||||||
|
|
||||||
# Print status message
|
|
||||||
if(NOT SVMClassifier_FIND_QUIETLY)
|
|
||||||
message(STATUS "Found SVMClassifier: ${PACKAGE_PREFIX_DIR} (found version \"${SVMClassifier_VERSION}\")")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Check version compatibility
|
|
||||||
check_required_components(SVMClassifier)
|
|
62
external/CMakeLists.txt
vendored
62
external/CMakeLists.txt
vendored
@@ -1,3 +1,5 @@
|
|||||||
|
# External dependencies CMakeLists.txt - Fixed version with OBJECT libraries
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
# Set policies for FetchContent
|
# Set policies for FetchContent
|
||||||
@@ -21,23 +23,33 @@ FetchContent_Declare(
|
|||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(liblinear)
|
FetchContent_MakeAvailable(liblinear)
|
||||||
|
|
||||||
# Build libsvm as static library
|
# Build libsvm as OBJECT library to avoid export issues
|
||||||
if(EXISTS "${libsvm_SOURCE_DIR}/svm.cpp")
|
if(EXISTS "${libsvm_SOURCE_DIR}/svm.cpp")
|
||||||
set(LIBSVM_SOURCES "${libsvm_SOURCE_DIR}/svm.cpp")
|
set(LIBSVM_SOURCES "${libsvm_SOURCE_DIR}/svm.cpp")
|
||||||
|
|
||||||
add_library(libsvm_static STATIC ${LIBSVM_SOURCES})
|
add_library(libsvm_objects OBJECT ${LIBSVM_SOURCES})
|
||||||
target_include_directories(libsvm_static PUBLIC ${libsvm_SOURCE_DIR})
|
|
||||||
|
# Set properties for the object library
|
||||||
|
target_include_directories(libsvm_objects
|
||||||
|
PRIVATE
|
||||||
|
${libsvm_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
# Set C++ standard for libsvm
|
# Set C++ standard for libsvm
|
||||||
target_compile_features(libsvm_static PUBLIC cxx_std_17)
|
target_compile_features(libsvm_objects PRIVATE cxx_std_17)
|
||||||
|
|
||||||
message(STATUS "libsvm built successfully")
|
# Make the include directory available to parent scope
|
||||||
|
set(LIBSVM_INCLUDE_DIR ${libsvm_SOURCE_DIR} PARENT_SCOPE)
|
||||||
|
|
||||||
|
message(STATUS "libsvm built successfully as object library")
|
||||||
else()
|
else()
|
||||||
message(WARNING "libsvm source files not found, creating dummy target")
|
message(WARNING "libsvm source files not found")
|
||||||
add_library(libsvm_static INTERFACE)
|
# Create empty object library
|
||||||
|
add_library(libsvm_objects OBJECT)
|
||||||
|
set(LIBSVM_INCLUDE_DIR "" PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build liblinear as static library
|
# Build liblinear as OBJECT library
|
||||||
set(LIBLINEAR_SOURCES)
|
set(LIBLINEAR_SOURCES)
|
||||||
|
|
||||||
# Check for main liblinear source files
|
# Check for main liblinear source files
|
||||||
@@ -67,33 +79,40 @@ else()
|
|||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Create liblinear library if we have source files
|
# Create liblinear object library if we have source files
|
||||||
if(LIBLINEAR_SOURCES)
|
if(LIBLINEAR_SOURCES)
|
||||||
add_library(liblinear_static STATIC ${LIBLINEAR_SOURCES})
|
add_library(liblinear_objects OBJECT ${LIBLINEAR_SOURCES})
|
||||||
|
|
||||||
target_include_directories(liblinear_static
|
# Set properties for the object library
|
||||||
PUBLIC
|
target_include_directories(liblinear_objects
|
||||||
|
PRIVATE
|
||||||
${liblinear_SOURCE_DIR}
|
${liblinear_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add blas directory if it exists
|
# Add blas directory if it exists
|
||||||
if(EXISTS "${liblinear_SOURCE_DIR}/blas")
|
if(EXISTS "${liblinear_SOURCE_DIR}/blas")
|
||||||
target_include_directories(liblinear_static
|
target_include_directories(liblinear_objects
|
||||||
PUBLIC ${liblinear_SOURCE_DIR}/blas
|
PRIVATE ${liblinear_SOURCE_DIR}/blas
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set C++ standard for liblinear
|
# Set C++ standard for liblinear
|
||||||
target_compile_features(liblinear_static PUBLIC cxx_std_17)
|
target_compile_features(liblinear_objects PRIVATE cxx_std_17)
|
||||||
|
|
||||||
# Compiler specific flags
|
# Compiler specific flags
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
target_compile_options(liblinear_static PRIVATE -w) # Suppress warnings
|
target_compile_options(liblinear_objects PRIVATE -w) # Suppress warnings
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Make the include directories available to parent scope
|
||||||
|
set(LIBLINEAR_INCLUDE_DIR ${liblinear_SOURCE_DIR} PARENT_SCOPE)
|
||||||
|
if(EXISTS "${liblinear_SOURCE_DIR}/blas")
|
||||||
|
set(LIBLINEAR_BLAS_INCLUDE_DIR ${liblinear_SOURCE_DIR}/blas PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "liblinear built with sources: ${LIBLINEAR_SOURCES}")
|
message(STATUS "liblinear built with sources: ${LIBLINEAR_SOURCES}")
|
||||||
else()
|
else()
|
||||||
# Create minimal liblinear implementation
|
# Create minimal liblinear implementation as object library
|
||||||
message(WARNING "liblinear source files not found, creating minimal implementation")
|
message(WARNING "liblinear source files not found, creating minimal implementation")
|
||||||
|
|
||||||
# Create a minimal linear.cpp file
|
# Create a minimal linear.cpp file
|
||||||
@@ -139,12 +158,15 @@ else()
|
|||||||
"}\n"
|
"}\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(liblinear_static STATIC "${MINIMAL_LIBLINEAR_DIR}/linear.cpp")
|
add_library(liblinear_objects OBJECT "${MINIMAL_LIBLINEAR_DIR}/linear.cpp")
|
||||||
target_include_directories(liblinear_static PUBLIC ${MINIMAL_LIBLINEAR_DIR})
|
target_include_directories(liblinear_objects PRIVATE ${MINIMAL_LIBLINEAR_DIR})
|
||||||
target_compile_features(liblinear_static PUBLIC cxx_std_17)
|
target_compile_features(liblinear_objects PRIVATE cxx_std_17)
|
||||||
|
|
||||||
|
set(LIBLINEAR_INCLUDE_DIR ${MINIMAL_LIBLINEAR_DIR} PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Print summary
|
# Print summary
|
||||||
message(STATUS "External libraries configured:")
|
message(STATUS "External libraries configured:")
|
||||||
message(STATUS " - libsvm: ${libsvm_SOURCE_DIR}")
|
message(STATUS " - libsvm: ${libsvm_SOURCE_DIR}")
|
||||||
message(STATUS " - liblinear: ${liblinear_SOURCE_DIR}")
|
message(STATUS " - liblinear: ${liblinear_SOURCE_DIR}")
|
||||||
|
message(STATUS " - Using OBJECT libraries to avoid export issues")
|
@@ -3,6 +3,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
||||||
namespace svm_classifier {
|
namespace svm_classifier {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user