-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
117 lines (103 loc) · 3.63 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
########################################################################
# Project setup
########################################################################
cmake_minimum_required(VERSION 3.3)
project(PothosVOLK CXX)
find_package(Pothos 0.7 CONFIG REQUIRED)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
########################################################################
# Find VOLK
########################################################################
find_package(Volk)
if(NOT VOLK_FOUND)
message(WARNING "Could not find VOLK. Skipping.")
return()
else()
# VOLK's find_package behavior is non-standard, so we need this check.
set(VOLK_MIN_VERSION "020000") # v2.0.0
file(READ "${VOLK_INCLUDE_DIRS}/volk/volk_version.h" volk_version_h)
string(REGEX REPLACE "\\#define VOLK_VERSION (([0-9])+)\n" "\\1" VOLK_VERSION_MATCHES "${volk_version_h}")
set(VOLK_VERSION "${CMAKE_MATCH_1}")
if("${VOLK_VERSION}" STRLESS "${VOLK_MIN_VERSION}")
message(WARNING "VOLK version must be >= ${VOLK_MIN_VERSION}. Found ${VOLK_VERSION}. Skipping.")
return()
endif()
endif()
########################################################################
# Build module
########################################################################
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/source
${CMAKE_CURRENT_SOURCE_DIR}/tests
${VOLK_INCLUDE_DIRS})
set(sources
source/Accumulator.cpp
source/AddQuad.cpp
source/BlockFactories.cpp
source/Byteswap.cpp
source/ModRange.cpp
source/Module.cpp
source/Normalize.cpp
source/PopCnt.cpp
source/PowerSpectralDensity.cpp
source/QuadMaxStar.cpp
source/SharedBufferAllocator.cpp
source/SquareDist.cpp
tests/BlockTests.cpp)
include(PothosUtil)
POTHOS_MODULE_UTIL(
TARGET VOLKBlocks
SOURCES ${sources}
LIBRARIES ${VOLK_LIBRARIES}
DESTINATION volk
ENABLE_DOCS ON
)
if(POTHOS_ABI_VERSION STRGREATER_EQUAL "0.7-2")
add_definitions(-DPOTHOSVOLK_CUSTOM_BUFFER_ALLOCATOR)
endif()
########################################################################
# Search for VOLK kernels added after minimum versions so we know to
# compile in fallback versions if needed.
########################################################################
include(CheckCXXSymbolExists)
set(CMAKE_REQUIRED_INCLUDES ${VOLK_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${VOLK_LIBRARIES})
function(CheckSymbolAndSetDefine symbol header variable)
check_cxx_symbol_exists(${symbol} ${header} ${variable})
if(${${variable}})
target_compile_definitions(VOLKBlocks PRIVATE -D${variable})
endif()
endfunction()
CheckSymbolAndSetDefine(
"volk_32fc_accumulator_s32fc"
"volk/volk.h"
HAVE_32FC_ACCUMULATOR)
CheckSymbolAndSetDefine(
"volk_32f_s32f_add_32f"
"volk/volk.h"
HAVE_32F_S32F_ADD)
CheckSymbolAndSetDefine(
"volk_32f_exp_32f"
"volk/volk.h"
HAVE_32F_EXP)
CheckSymbolAndSetDefine(
"volk_32fc_x2_s32fc_multiply_conjugate_add_32fc"
"volk/volk.h"
HAVE_32FC_X2_S32FC_MULTIPLY_CONJUGATE_ADD)
########################################################################
# Search for VOLK kernels deprecated at some point so we know to
# compile in fallback versions if needed.
########################################################################
CheckSymbolAndSetDefine(
"volk_16i_max_star_16i"
"volk/volk.h"
HAVE_16I_MAX_STAR)
CheckSymbolAndSetDefine(
"volk_16i_x4_quad_max_star_16i"
"volk/volk.h"
HAVE_16I_X4_QUAD_MAX_STAR)
CheckSymbolAndSetDefine(
"volk_16i_x5_add_quad_16i_x4"
"volk/volk.h"
HAVE_16I_X5_ADD_QUAD)