-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
132 lines (106 loc) · 5.22 KB
/
CMakeLists.txt
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
############################################################################
# Copyright (c) QuantStack #
# #
# Distributed under the terms of the BSD 3-Clause License. #
# #
# The full license is in the file LICENSE, distributed with this software. #
############################################################################
cmake_minimum_required(VERSION 3.5)
project(xtensor-signal)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
set(XTENSOR_SIGNAL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
# Versioning
# ==========
set(XTENSOR_SIGNAL_CONFIG_FILE
"${XTENSOR_SIGNAL_INCLUDE_DIR}/xtensor-signal/xtensor_signal.hpp")
file(STRINGS ${XTENSOR_SIGNAL_CONFIG_FILE} xtensor_signal_version_defines
REGEX "#define XTENSOR_SIGNAL_VERSION_(MAJOR|MINOR|PATCH)")
foreach(ver ${xtensor_signal_version_defines})
if(ver MATCHES "#define XTENSOR_SIGNAL_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
set(XTENSOR_SIGNAL_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "")
endif()
endforeach()
set(${PROJECT_NAME}_VERSION
${XTENSOR_SIGNAL_VERSION_MAJOR}.${XTENSOR_SIGNAL_VERSION_MINOR}.${XTENSOR_SIGNAL_VERSION_PATCH})
message(STATUS "xtensor-signal v${${PROJECT_NAME}_VERSION}")
# Dependencies
# ============
set(xsimd_REQUIRED_VERSION 9.0.1)
if(TARGET xsimd)
set(xsimd_VERSION ${XSIMD_VERSION_MAJOR}.${XSIMD_VERSION_MINOR}.${XSIMD_VERSION_PATCH})
# Note: This is not SEMVER compatible comparison
if(${xsimd_VERSION} VERSION_LESS ${xsimd_REQUIRED_VERSION})
message(ERROR "Mismatch xsimd versions. Found '${xsimd_VERSION}' but requires: '${xsimd_REQUIRED_VERSION}'")
else()
message(STATUS "Found xsimd v${xsimd_VERSION}")
endif()
else()
find_package(xsimd ${xsimd_REQUIRED_VERSION} REQUIRED)
message(STATUS "Found xsimd: ${xsimd_INCLUDE_DIRS}/xsimd")
endif()
set(xtensor_REQUIRED_VERSION 0.24.6)
if(TARGET xtensor)
set(xtensor_VERSION ${XTENSOR_VERSION_MAJOR}.${XTENSOR_VERSION_MINOR}.${XTENSOR_VERSION_PATCH})
# Note: This is not SEMVER compatible comparison
if( NOT ${xtensor_VERSION} VERSION_GREATER_EQUAL ${xtensor_REQUIRED_VERSION})
message(ERROR "Mismatch xtensor versions. Found '${xtensor_VERSION}' but requires: '${xtensor_REQUIRED_VERSION}'")
else()
message(STATUS "Found xtensor v${xtensor_VERSION}")
endif()
else()
find_package(xtensor ${xtensor_REQUIRED_VERSION} REQUIRED)
message(STATUS "Found xtensor: ${xtensor_INCLUDE_DIRS}/xtensor")
endif()
# Build
# =====
set(XTENSOR_SIGNAL_HEADERS
${XTENSOR_SIGNAL_INCLUDE_DIR}/xtensor-signal/xtensor_signal.hpp
${XTENSOR_SIGNAL_INCLUDE_DIR}/xtensor-signal/find_peaks.hpp
${XTENSOR_SIGNAL_INCLUDE_DIR}/xtensor-signal/lfilter.hpp
${XTENSOR_SIGNAL_INCLUDE_DIR}/xtensor-signal/fft.hpp
)
add_library(xtensor-signal INTERFACE)
target_include_directories(xtensor-signal INTERFACE
$<BUILD_INTERFACE:${XTENSOR_SIGNAL_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>)
target_link_libraries(xtensor-signal INTERFACE xtensor xsimd)
OPTION(BUILD_TESTS "xtensor test suite" OFF)
OPTION(XTENSOR_USE_TBB "Use tbb libraries" OFF)
if(BUILD_TESTS)
add_subdirectory(test)
endif()
if(XTENSOR_USE_TBB)
find_package(TBB REQUIRED)
message(STATUS "Found intel TBB: ${TBB_INCLUDE_DIRS}")
endif()
# Installation
# ============
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
install(TARGETS xtensor-signal
EXPORT ${PROJECT_NAME}-targets)
# Makes the project importable from the build directory
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")
install(FILES ${XTENSOR_SIGNAL_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xtensor-signal)
set(XTENSOR_SIGNAL_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE
STRING "install path for xtensor-signalConfig.cmake")
configure_package_config_file(${PROJECT_NAME}Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${XTENSOR_SIGNAL_CMAKECONFIG_INSTALL_DIR})
# xtensor-signal is header-only and does not depend on the architecture.
# Remove CMAKE_SIZEOF_VOID_P from xtensor-signalConfigVersion.cmake so that an xtensor-signalConfig.cmake
# generated for a 64 bit target can be used for 32 bit targets and vice versa.
set(_XTENSOR_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
unset(CMAKE_SIZEOF_VOID_P)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion)
set(CMAKE_SIZEOF_VOID_P ${_XTENSOR_CMAKE_SIZEOF_VOID_P})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${XTENSOR_SIGNAL_CMAKECONFIG_INSTALL_DIR})
install(EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}Targets.cmake
DESTINATION ${XTENSOR_SIGNAL_CMAKECONFIG_INSTALL_DIR})