-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
168 lines (139 loc) · 5.61 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# Copyright 2018 Oxford Nanopore Technologies, Ltd
# This Source Code Form is subject to the terms of the Oxford Nanopore
# Technologies, Ltd. Public License, v. 1.0. If a copy of the License
# was not distributed with this file, You can obtain one at
# http://nanoporetech.cppom
cmake_minimum_required (VERSION 2.8.12)
project (flappie C CXX)
option (BUILD_SHARED_LIB "Build a shared library" OFF)
set(CMAKE_CONFIGURATION_TYPES "Debug;Chaos;Release")
if(NOT CMAKE_BUILD_TYPE)
message("Defaulting to release build")
set(CMAKE_BUILD_TYPE Release)
endif()
include (InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Scrappie is the technology demonstration platform for the Research algorithms' group.")
set (CPACK_PACKAGE_VENDOR "Oxford Nanopore Technologies")
set (CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md")
#set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.md")
set (CPACK_PACKAGE_VERSION_MAJOR 1)
set (CPACK_PACKAGE_VERSION_MINOR 1)
set (CPACK_PACKAGE_VERSION_PATCH 0)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set (CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${GIT_COMMIT_HASH}")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
set (CPACK_PACKAGE_NAME "ont-${PROJECT_NAME}")
set (CPACK_DEBIAN_PACKAGE_MAINTAINER "Tim Massingham <[email protected]>")
set (CPACK_DEBIAN_PACKAGE_SECTION "base")
set (CPACK_DEBIAN_PACKAGE_DEPENDS "libopenblas-base, libhdf5-7, libcunit1")
set (CPACK_DEBIAN_BUILD_DEPENDS "libopenblas-base, libopenblas-dev, libhdf5-7, libhdf5-dev, cmake, libcunit1-dev")
set (CPACK_PACKAGING_INSTALL_PREFIX "/opt/flappie")
set (CPACK_GENERATOR "TGZ;DEB")
include (CPack)
configure_file (
"${PROJECT_SOURCE_DIR}/src/version.h.in"
"${PROJECT_BINARY_DIR}/include/version.h"
)
##
# Set up include directories
##
link_directories ("./arm-lib")
include_directories(src)
include_directories ("${PROJECT_BINARY_DIR}/include")
if (OPENBLAS_ROOT)
include_directories ("${OPENBLAS_ROOT}/include")
link_directories ("${OPENBLAS_ROOT}/lib")
set (BLAS "openblas")
else ()
set (BLAS "blas")
endif ()
if (HDF5_ROOT)
include_directories ("${HDF5_ROOT}/include")
link_directories ("${HDF5_ROOT}/lib")
set (CMAKE_REQUIRED_INCLUDES ${HDF5_ROOT}/include)
endif()
set(CMAKE_ARM_FLAGS "-mfloat-abi=hard -mfpu=neon")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -g -Wfatal-errors -DUSE_SSE2 -mfloat-abi=softfp -mfpu=neon -Wunused-function -Wunused-value -Wunused-parameter -fstack-protector-all -O3 -D__USE_MISC -D_POSIX_SOURCE -DNDEBUG")
##
# Set up what is to be built
##
add_library (flappie_objects OBJECT
src/decode.cpp
src/layers.cpp
src/networks.cpp
src/nnfeatures.cpp
src/flappie_common.cpp
src/flappie_matrix.cpp
src/flappie_output.cpp
src/flappie_structures.cpp
# src/ref_model/ekf_sw.cpp
# src/stimuli_gen/matrix_generation.cpp
# src/hw/ekf_hw.cpp
# src/hw/vio.cpp
# src/hw/vio_priv.cpp
src/util.cpp)
set_property(TARGET flappie_objects PROPERTY POSITION_INDEPENDENT_CODE 1)
add_library (flappie_static STATIC $<TARGET_OBJECTS:flappie_objects>)
set_target_properties(flappie_static PROPERTIES OUTPUT_NAME flappie CLEAN_DIRECT_OUTPUT 1 COMPILE_FLAGS "${CMAKE_ARM_FLAGS} -DENABLE_DMA=1")
set_target_properties(flappie_objects PROPERTIES COMPILE_FLAGS "${CMAKE_ARM_FLAGS} -DENABLE_DMA=1")
add_executable (flappie
src/fast5_interface.cpp
src/flappie.cpp)
set_target_properties(flappie PROPERTIES COMPILE_FLAGS "${CMAKE_ARM_FLAGS} -DENABLE_DMA=1")
add_executable (testf
repro/2test.cpp
src/ref_model/ekf_sw.cpp
src/stimuli_gen/matrix_generation.cpp
src/hw/ekf_hw.cpp
src/hw/vio.cpp
src/hw/vio_priv.cpp)
set_target_properties(testf PROPERTIES COMPILE_FLAGS "${CMAKE_ARM_FLAGS} -DENABLE_DMA=1")
if (BUILD_SHARED_LIB)
if (APPLE)
message (SEND_ERROR "Building shared library on OSX not yet supported")
endif (APPLE)
add_library (flappie_shared SHARED $<TARGET_OBJECTS:flappie_objects>)
set_target_properties(flappie_shared PROPERTIES OUTPUT_NAME flappie CLEAN_DIRECT_OUTPUT 1)
install (TARGETS flappie_shared LIBRARY DESTINATION lib)
endif (BUILD_SHARED_LIB)
if (NOT DEFINED CHAOSMONKEY)
set(CHAOSMONKEY 0.1)
endif ()
# Find right hdf5 file
include (CheckIncludeFile)
check_include_file ("hdf5.h" HDF5_STANDARD)
if (HDF5_STANDARD)
set (HDF5 "hdf5")
else (HDF5_STANDARD)
check_include_file ("hdf5/serial/hdf5.h" HDF5_SERIAL)
if (HDF5_SERIAL)
set (HDF5 "hdf5_serial")
include_directories ("/usr/include/hdf5/serial")
endif (HDF5_SERIAL)
endif (HDF5_STANDARD)
target_link_libraries (flappie flappie_static ${BLAS} ${HDF5} m)
target_link_libraries (testf ${BLAS} ${HDF5} m)
if (APPLE)
target_link_libraries (flappie argp)
endif (APPLE)
install (TARGETS flappie flappie_static RUNTIME DESTINATION bin ARCHIVE DESTINATION lib)
enable_testing()
add_executable(flappie_unittest
src/test/flappie_test_runner.cpp
src/test/flappie_util.cpp
src/test/test_flappie_convolution.cpp
src/test/test_flappie_elu.cpp
src/test/test_flappie_matrix.cpp
src/test/test_flappie_signal.cpp
src/test/test_flappie_util.cpp
src/test/test_skeleton.cpp
src/test/test_util.cpp)
target_include_directories(flappie_unittest PUBLIC "src/test" "src")
target_link_libraries(flappie_unittest flappie_static ${BLAS} ${HDF5} m cunit)
add_custom_target(test-verbose COMMAND ${CMAKE_CTEST_COMMAND} --verbose)