-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
135 lines (122 loc) · 5.09 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
133
134
135
########################################################################
# Project setup
########################################################################
cmake_minimum_required(VERSION 2.8.9)
project(PothosNumPy CXX)
find_package(Pothos 0.7 CONFIG REQUIRED)
include(PothosPythonUtil)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
########################################################################
# json.hpp header
########################################################################
find_path(JSON_HPP_INCLUDE_DIR NAMES json.hpp PATH_SUFFIXES nlohmann)
if (NOT JSON_HPP_INCLUDE_DIR)
message(WARNING "Pothos NumPy toolkit requires json.hpp, skipping...")
endif (NOT JSON_HPP_INCLUDE_DIR)
########################################################################
# Find Python modules used to implement blocks
########################################################################
include(FindPythonModule)
find_python_module(numpy REQUIRED)
find_python_module(mako REQUIRED)
find_python_module(yaml REQUIRED)
########################################################################
# Get NumPy version to store with installation
########################################################################
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.__version__)"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE NUMPY_VERSION)
########################################################################
# Auto-generate the majority of blocks
########################################################################
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/BlockGen)
set(autogenDeps
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Arithmetic.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Binary.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Complex.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/FactoryOnly.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Exponential.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Random.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Rounding.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Sources.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Special.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Stats.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Stream.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Blocks/Trig.yaml
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/Factory.mako.cpp
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/BlockExecutionTest.mako.cpp
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/PythonFactoryFunction.mako.py
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/PythonSubclass.mako.py
${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/GenBlocks.py)
set(autogenOutputs
${CMAKE_CURRENT_BINARY_DIR}/BlockGen/BlockEntryPoints.py
${CMAKE_CURRENT_BINARY_DIR}/BlockGen/BlockExecutionTestAuto.cpp
${CMAKE_CURRENT_BINARY_DIR}/BlockGen/Factory.cpp)
add_custom_command(
OUTPUT ${autogenOutputs}
DEPENDS ${autogenDeps}
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/BlockGen/GenBlocks.py" "${CMAKE_CURRENT_BINARY_DIR}/BlockGen"
COMMENT "Generating C++ factories and Python entry points")
add_custom_target(
autogen_files ALL
DEPENDS ${autogenOutputs})
########################################################################
# Build the module
########################################################################
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${JSON_HPP_INCLUDE_DIR})
configure_file(
Python/BaseBlock.py.in
${CMAKE_CURRENT_BINARY_DIR}/Python/BaseBlock.py)
include(BuildPythonModule)
BUILD_PYTHON_MODULE(
TARGET NumPyBlocks
DESTINATION PothosNumPy
SOURCES
Python/__init__.py
Python/FFT.py
Python/ForwardAndPostLabelBlock.py
Python/FileSink.py
Python/FileSource.py
Python/NToOneBlock.py
Python/OneToOneBlock.py
Python/Random.py
Python/RegisteredCallHelpers.py
Python/Source.py
Python/TestFuncs.py
Python/TwoToOneBlock.py
Python/Utility.py
Python/Window.py
${CMAKE_CURRENT_BINARY_DIR}/Python/BaseBlock.py
${CMAKE_CURRENT_BINARY_DIR}/BlockGen/BlockEntryPoints.py
CPP_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/BlockGen/Factory.cpp
${CMAKE_CURRENT_BINARY_DIR}/BlockGen/BlockExecutionTestAuto.cpp
Cpp/NumericInfo.cpp
Cpp/RegisteredCalls.cpp
Testing/BlockExecutionTest.cpp
Testing/BlockExecutionTestManual.cpp
Testing/TestArithmeticBlocks.cpp
Testing/TestBitwise.cpp
Testing/TestConjugate.cpp
Testing/TestFFT.cpp
Testing/TestLabels.cpp
Testing/TestLog.cpp
Testing/TestNaNToNum.cpp
Testing/TestNumPyFileIO.cpp
Testing/TestPowRoot.cpp
Testing/TestRegisteredCalls.cpp
Testing/TestStreamManipBlocks.cpp
Testing/TestTrigonometric.cpp
Testing/TestUnion1D.cpp
Testing/TestUnique.cpp
Testing/TestUtility.cpp
DOC_SOURCES
Python/FFT.py
Python/FileSink.py
Python/FileSource.py
Python/Window.py
)
add_dependencies(NumPyBlocks autogen_files)