-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCMakeLists.txt
114 lines (95 loc) · 3.52 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
cmake_minimum_required (VERSION 3.0)
project (qmkl)
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_CONTACT "Sugizaki Yukimasa <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Math Kernel Library for VideoCore IV QPU")
# See https://semver.org/
set(CPACK_PACKAGE_VERSION_MAJOR 1)
set(CPACK_PACKAGE_VERSION_MINOR 0)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
include(CPack)
find_package(PkgConfig)
find_package(OpenMP)
find_program (QASM2 qasm2)
if (NOT QASM2)
message (FATAL_ERROR "qasm2 not found. Install it from https://github.com/Terminus-IMRC/qpu-assembler2")
endif ()
find_program (QBIN2HEX qbin2hex)
if (NOT QBIN2HEX)
message (FATAL_ERROR "qbin2hex not found. Install it from https://github.com/Terminus-IMRC/qpu-bin-to-hex")
endif ()
find_program (M4 m4)
if (NOT M4)
message (FATAL_ERROR "m4 not found.")
endif ()
find_package(PythonInterp)
if (NOT PYTHONINTERP_FOUND)
message (FATAL_ERROR "Python is required to assemble QPU codes")
endif ()
pkg_check_modules(VCSM vcsm)
if (NOT VCSM_FOUND)
message(STATUS "Adding /opt/vc/lib/pkgconfig to PKG_CONFIG_PATH")
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/opt/vc/lib/pkgconfig")
pkg_check_modules(VCSM vcsm)
if (NOT VCSM_FOUND)
message (FATAL_ERROR "vcsm not found even in /opt/vc/lib. "
"Building on non-RPi host? "
"Please specify PKG_CONFIG_PATH.")
endif ()
endif ()
pkg_check_modules(MAILBOX REQUIRED libmailbox>=2.0.0)
# librpimemmgr needs bcm_host and vcsm, which may be in /opt/vc...
pkg_check_modules(RPIMEMMGR librpimemmgr>=2.0.1)
if (NOT RPIMEMMGR_FOUND)
message(STATUS "Adding /opt/vc/lib/pkgconfig to PKG_CONFIG_PATH")
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/opt/vc/lib/pkgconfig")
pkg_check_modules(RPIMEMMGR librpimemmgr>=2.0.1)
if (NOT RPIMEMMGR_FOUND)
message (FATAL_ERROR "librpimemmgr not found even in /opt/vc/lib. "
"Building on non-RPi host? "
"Please specify PKG_CONFIG_PATH.")
endif ()
endif ()
if (DEFINED ENV{RPIVER})
if ("$ENV{RPIVER}" STREQUAL "1")
set (RPIVER 1)
elseif ("$ENV{RPIVER}" STREQUAL "2")
set (RPIVER 2)
elseif ("$ENV{RPIVER}" STREQUAL "3")
set (RPIVER 3)
else ()
message (FATAL_ERROR "Invalid RPIVER specified: $ENV{RPIVER}")
endif ()
else ()
message(WARNING "RPIVER is not specified; using default: 1")
set (RPIVER 1)
endif ()
if (RPIVER EQUAL 1)
message (STATUS "Building for Raspberry Pi 1 / Zero")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=arm1176jzf-s \
-mtune=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp")
elseif (RPIVER EQUAL 2)
message (STATUS "Building for Raspberry Pi 2")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-a7 -mtune=cortex-a7 \
-mfloat-abi=hard -mfpu=neon-vfpv4")
elseif (RPIVER EQUAL 3)
message (STATUS "Building for Raspberry Pi 3")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-a53 -mtune=cortex-a53 \
-mfloat-abi=hard -mfpu=neon-vfpv4")
endif ()
add_subdirectory (src)
add_subdirectory (test)
enable_testing()
include (cmake/FindCUnit.cmake)
if(CUNIT_FOUND)
add_test(sgemm_spec sudo ./test/sgemm_spec)
add_custom_target(
check
COMMAND ${CMAKE_CTEST_COMMAND}
DEPENDS sgemm_spec
)
endif(CUNIT_FOUND)
configure_file(qmkl.pc.in qmkl.pc @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/qmkl.pc"
DESTINATION lib/pkgconfig)