Some checks failed
CI/CD Pipeline / Code Linting (push) Failing after 22s
CI/CD Pipeline / Build and Test (Debug, clang, ubuntu-latest) (push) Failing after 5m44s
CI/CD Pipeline / Build and Test (Debug, gcc, ubuntu-latest) (push) Failing after 5m33s
CI/CD Pipeline / Build and Test (Release, clang, ubuntu-20.04) (push) Failing after 6m12s
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 5m30s
CI/CD Pipeline / Build and Test (Release, gcc, ubuntu-latest) (push) Failing after 5m33s
CI/CD Pipeline / Docker Build Test (push) Failing after 13s
CI/CD Pipeline / Performance Benchmarks (push) Has been skipped
CI/CD Pipeline / Build Documentation (push) Successful in 31s
CI/CD Pipeline / Create Release Package (push) Has been skipped
60 lines
1.8 KiB
CMake
60 lines
1.8 KiB
CMake
# External dependencies CMakeLists.txt
|
|
|
|
include(FetchContent)
|
|
|
|
# Fetch libsvm
|
|
FetchContent_Declare(
|
|
libsvm
|
|
GIT_REPOSITORY https://github.com/cjlin1/libsvm.git
|
|
GIT_TAG v332
|
|
)
|
|
FetchContent_MakeAvailable(libsvm)
|
|
|
|
# Fetch liblinear
|
|
FetchContent_Declare(
|
|
liblinear
|
|
GIT_REPOSITORY https://github.com/cjlin1/liblinear.git
|
|
GIT_TAG v249
|
|
)
|
|
FetchContent_MakeAvailable(liblinear)
|
|
|
|
# Build libsvm as static library
|
|
set(LIBSVM_SOURCES
|
|
${libsvm_SOURCE_DIR}/svm.cpp
|
|
)
|
|
|
|
add_library(libsvm_static STATIC ${LIBSVM_SOURCES})
|
|
target_include_directories(libsvm_static PUBLIC ${libsvm_SOURCE_DIR})
|
|
target_compile_definitions(libsvm_static PRIVATE -DLIBSVM_VERSION=332)
|
|
|
|
# Build liblinear as static library
|
|
set(LIBLINEAR_SOURCES
|
|
${liblinear_SOURCE_DIR}/linear.cpp
|
|
${liblinear_SOURCE_DIR}/tron.cpp
|
|
${liblinear_SOURCE_DIR}/blas/daxpy.c
|
|
${liblinear_SOURCE_DIR}/blas/ddot.c
|
|
${liblinear_SOURCE_DIR}/blas/dnrm2.c
|
|
${liblinear_SOURCE_DIR}/blas/dscal.c
|
|
)
|
|
|
|
add_library(liblinear_static STATIC ${LIBLINEAR_SOURCES})
|
|
target_include_directories(liblinear_static
|
|
PUBLIC
|
|
${liblinear_SOURCE_DIR}
|
|
${liblinear_SOURCE_DIR}/blas
|
|
)
|
|
target_compile_definitions(liblinear_static PRIVATE -DLIBLINEAR_VERSION=249)
|
|
|
|
# Set C++ standard for the libraries
|
|
set_property(TARGET libsvm_static PROPERTY CXX_STANDARD 17)
|
|
set_property(TARGET liblinear_static PROPERTY CXX_STANDARD 17)
|
|
|
|
# Handle platform-specific compilation
|
|
if(WIN32)
|
|
target_compile_definitions(libsvm_static PRIVATE -D_CRT_SECURE_NO_WARNINGS)
|
|
target_compile_definitions(liblinear_static PRIVATE -D_CRT_SECURE_NO_WARNINGS)
|
|
endif()
|
|
|
|
# Export the source directories for use in main project
|
|
set(LIBSVM_INCLUDE_DIR ${libsvm_SOURCE_DIR} PARENT_SCOPE)
|
|
set(LIBLINEAR_INCLUDE_DIR ${liblinear_SOURCE_DIR} PARENT_SCOPE) |