forked from bws/xdd
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
142 lines (119 loc) · 4.25 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
cmake_minimum_required(VERSION 3.12.0)
project(xdd VERSION 2.0 LANGUAGES C)
if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
message(FATAL_ERROR "Unsupported Build Platform ${CMAKE_SYSTEM_NAME}")
endif()
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# package properties
set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set(PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}")
set(PACKAGE_STRING "${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_VERSION}")
set(PACKAGE_URL "")
set(PACKAGE_BUGREPORT "[email protected]")
set(PACKAGE_TARNAME "${CMAKE_PROJECT_NAME}")
# Threads are required
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# for finding packages with pkg-config
find_package(PkgConfig REQUIRED)
include(CheckIncludeFiles)
include(CheckSymbolExists)
# find libibverbs
option(WITH_VERBS "Build with verbs" ON)
if (WITH_VERBS)
find_library(IBVERBS ibverbs)
if (IBVERBS)
message(STATUS "libibverbs: ${IBVERBS}")
check_include_files(infiniband/verbs.h HAVE_INFINIBAND_VERBS_H)
list(APPEND CMAKE_REQUIRED_FLAGS -Wno-pedantic)
list(APPEND CMAKE_REQUIRED_LIBRARIES -libverbs) # CMP0075, requires CMake 3.12
check_symbol_exists(ibv_get_device_list "infiniband/verbs.h" IBV_GET_DEVICE_LIST)
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES -libverbs)
list(REMOVE_ITEM CMAKE_REQUIRED_FLAGS -Wno-pedantic)
if (IBV_GET_DEVICE_LIST)
set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, libibverbs")
list(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libibverbs1")
set(HAVE_ENABLE_IB 1)
else()
message(STATUS "libibverbs found but missing symbol ibv_get_device_list")
endif()
else()
message(STATUS "libibverbs not found.")
endif()
endif()
# libnuma is optional
option(WITH_NUMA "Build with libnuma" ON)
if (WITH_NUMA)
pkg_search_module(NUMA numa)
if (NUMA_FOUND)
message(STATUS "libnuma CFLAGS: ${NUMA_CFLAGS}")
message(STATUS "libnuma LDFLAGS: ${NUMA_LDFLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NUMA_CFLAGS}")
set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, numactl-libs")
list(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS "libnuma1")
set(HAVE_ENABLE_NUMA 1)
else()
message(STATUS "libnuma not found")
endif()
endif()
# optionally build for flamegraph analysis
option(WITH_FLAMEGRAPH "Build for flamegraph analysis" ON)
if (WITH_FLAMEGRAPH)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer")
endif()
# build library and executables
add_subdirectory(src)
# set up tests
enable_testing()
add_subdirectory(tests)
# set up extra files
add_subdirectory(contrib)
# optionally build docs
find_package(Doxygen COMPONENTS dot)
if (DOXYGEN_FOUND)
option(WITH_DOXYGEN "Build doxygen documentation" ON)
if (WITH_DOXYGEN)
set(DOXYGEN_GENERATE_HTML ON)
set(DOXYGEN_GENERATE_MAN ON)
set(DOXYGEN_GENERATE_LATEX ON)
set(DOXYGEN_PDF_HYPERLINKS ON)
doxygen_add_docs(doxygen
"${CMAKE_SOURCE_DIR}/doc"
)
endif()
endif()
# build RPM
find_program(RPMBUILD rpmbuild)
if (RPMBUILD)
message(STATUS "rpmbuild: ${RPMBUILD}")
option(RPM "Build RPM" ON)
if (RPM)
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set(CPACK_RPM_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}")
set(CPACK_RPM_PACKAGE_SUMMARY "IO performace Test Tool dd with an X factor")
set(CPACK_RPM_PACKAGE_LICENSE "GPL-2.0")
set(CPACK_RPM_PACKAGE_GROUP "Benchmarking")
set(CPACK_RPM_PACKAGE_URL "https://github.com/MigeljanImeri/xdd")
set(CPACK_RPM_PACKAGE_DESCRIPTION "IO Test tool that can do so much more.")
endif()
endif()
# build DEB
find_program(DPKGBUILD dpkg-buildpackage)
if (DPKGBUILD)
message(STATUS "dpkg-buildpackage: ${DPKGBUILD}")
option(DPKG "Build DEB" ON)
if (DPKG)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set(CPACK_DEBIAN_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}")
set(CPACK_DEBIAN_PACKAGE_SUMMARY "IO performace Test Tool dd with an X factor")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/MigeljanImeri/xdd")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "XDD Developers")
string(REPLACE ";" ", " CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}")
endif()
endif()
if ((RPMBUILD AND RPM) OR
(DPKGBUILD AND DPKG))
include(CPack)
endif()