forked from mlpack/mlpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindEnsmallen.cmake
59 lines (48 loc) · 2.33 KB
/
FindEnsmallen.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# - Find Ensmallen
# Find the Ensmallen C++ library
#
# This module sets the following variables:
# ENSMALLEN_FOUND - set to true if the library is found
# ENSMALLEN_INCLUDE_DIR - list of required include directories
# ENSMALLEN_VERSION_MAJOR - major version number
# ENSMALLEN_VERSION_MINOR - minor version number
# ENSMALLEN_VERSION_PATCH - patch version number
# ENSMALLEN_VERSION_STRING - version number as a string (ex: "1.0.4")
# ENSMALLEN_VERSION_NAME - name of the version (ex: "Antipodean Antileech")
file(GLOB ENSMALLEN_SEARCH_PATHS
${CMAKE_BINARY_DIR}/deps/ensmallen-[0-9]*.[0-9]*.[0-9]*)
find_path(ENSMALLEN_INCLUDE_DIR
NAMES ensmallen.hpp
PATHS ${ENSMALLEN_SEARCH_PATHS}/include)
if(ENSMALLEN_INCLUDE_DIR)
# ------------------------------------------------------------------------
# Extract version information from <ensmallen>
# ------------------------------------------------------------------------
set(ENSMALLEN_VERSION_MAJOR 0)
set(ENSMALLEN_VERSION_MINOR 0)
set(ENSMALLEN_VERSION_PATCH 0)
set(ENSMALLEN_VERSION_NAME "unknown")
if(EXISTS "${ENSMALLEN_INCLUDE_DIR}/ensmallen_bits/ens_version.hpp")
set(ENSMALLEN_FOUND YES)
# Read and parse armdillo version header file for version number
file(READ "${ENSMALLEN_INCLUDE_DIR}/ensmallen_bits/ens_version.hpp"
_ensmallen_HEADER_CONTENTS)
string(REGEX REPLACE ".*#define ENS_VERSION_MAJOR ([0-9]+).*" "\\1"
ENSMALLEN_VERSION_MAJOR "${_ensmallen_HEADER_CONTENTS}")
string(REGEX REPLACE ".*#define ENS_VERSION_MINOR ([0-9]+).*" "\\1"
ENSMALLEN_VERSION_MINOR "${_ensmallen_HEADER_CONTENTS}")
string(REGEX REPLACE ".*#define ENS_VERSION_PATCH ([0-9]+).*" "\\1"
ENSMALLEN_VERSION_PATCH "${_ensmallen_HEADER_CONTENTS}")
# WARNING: The number of spaces before the version name is not one.
string(REGEX REPLACE
".*#define ENS_VERSION_NAME\ +\"([0-9a-zA-Z\ _-]+)\".*" "\\1"
ENSMALLEN_VERSION_NAME "${_ensmallen_HEADER_CONTENTS}")
endif()
set(ENSMALLEN_VERSION_STRING "${ENSMALLEN_VERSION_MAJOR}.${ENSMALLEN_VERSION_MINOR}.${ENSMALLEN_VERSION_PATCH}")
endif ()
# Checks 'REQUIRED', 'QUIET' and versions.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ensmallen
REQUIRED_VARS ENSMALLEN_INCLUDE_DIR
VERSION_VAR ENSMALLEN_VERSION_STRING)
mark_as_advanced(ENSMALLEN_INCLUDE_DIR)