Skip to content

Commit 5fcc26f

Browse files
authored
Merge pull request #11 from CESNET/deps
CMake - Introduce mlpack dependency
2 parents 44322b9 + bae05bb commit 5fcc26f

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

cmake/dependencies.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Project dependencies
22
find_package(Armadillo REQUIRED)
33
find_package(Boost REQUIRED COMPONENTS regex serialization)
4+
find_package(MLPACK REQUIRED)
45
find_package(OpenMP REQUIRED)
56
find_package(Python3 REQUIRED COMPONENTS Development NumPy)
67

cmake/modules/FindMLPACK.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Find the mlpack includes and library
2+
#
3+
# This module defines the following IMPORTED targets:
4+
#
5+
# mlpack::mlpack - The "mlpack" library, if found.
6+
#
7+
# This module will set the following variables in your project:
8+
#
9+
# MLPACK_INCLUDE_DIRS - where to find <mlpack/core.hpp>, etc.
10+
# MLPACK_FOUND - True if the mlpack library has been found.
11+
12+
# Use pkg-config (if available) to get the library directories and then use
13+
# these values as hints for find_path() and find_library() functions.
14+
find_package(PkgConfig QUIET)
15+
if (PKG_CONFIG_FOUND)
16+
pkg_check_modules(PC_MLPACK QUIET mlpack)
17+
endif()
18+
19+
find_path(
20+
MLPACK_INCLUDE_DIR mlpack
21+
HINTS ${PC_MLPACK_INCLUDEDIR} ${PC_MLPACK_INCLUDE_DIRS}
22+
PATH_SUFFIXES include
23+
)
24+
25+
if (PC_MLPACK_VERSION)
26+
# Version extracted from pkg-config
27+
set(MLPACK_VERSION_STRING ${PC_MLPACK_VERSION})
28+
endif()
29+
30+
# Handle find_package() arguments (i.e. QUIETLY and REQUIRED) and set
31+
# MLPACK_FOUND to TRUE if all listed variables are filled.
32+
include(FindPackageHandleStandardArgs)
33+
find_package_handle_standard_args(
34+
MLPACK
35+
REQUIRED_VARS MLPACK_INCLUDE_DIR
36+
VERSION_VAR MLPACK_VERSION_STRING
37+
)
38+
39+
set(MLPACK_INCLUDE_DIRS ${MLPACK_INCLUDE_DIR})
40+
mark_as_advanced(MLPACK_INCLUDE_DIR)

0 commit comments

Comments
 (0)