-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
162 lines (135 loc) · 6.11 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
# SPDX-License-Identifier: BSD-3-Clause
# ndk-sw tools-debug CMake build file
#
# Copyright (c) 2022 CESNET
#
# Author(s):
# Martin Spinler <[email protected]
#
cmake_minimum_required(VERSION 3.15)
cmake_policy(VERSION 3.15)
project(nfb-framework LANGUAGES C)
include(${CMAKE_CURRENT_LIST_DIR}/functions.cmake)
get_git_version()
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "Main")
#check_function_exists(cmake_host_system_information HAVE_HSI)
#cmake_host_system_information(RESULT DISTRIB_ID_LIKE QUERY DISTRIB_ID_LIKE)
set(CPACK_PACKAGING_INSTALL_PREFIX "/usr/")
if (EXISTS "/etc/debian_version")
set(PLATFORM "Debian")
set(CPACK_GENERATOR "DEB" )
elseif (EXISTS "/etc/centos-release" OR EXISTS "/etc/sl-release" OR EXISTS "/etc/redhat-release")
set(PLATFORM "Centos")
set(CPACK_GENERATOR "RPM")
else ()
message(WARNING "Failed to determine platform, using TGZ for packaging")
set(CPACK_GENERATOR "TGZ")
set(CPACK_ARCHIVE_COMPONENT_INSTALL 1)
set(CPACK_SET_DESTDIR "ON")
unset(CPACK_PACKAGING_INSTALL_PREFIX)
endif ()
set(PACKAGE_NAME "${PROJECT_NAME}")
set(PACKAGE_VERSION "${GIT_VERSION}")
set(RELEASE "${GIT_VERSION_RELEASE}")
add_subdirectory(drivers)
add_subdirectory(libnfb)
add_subdirectory(ext)
add_subdirectory(tools)
add_subdirectory(tools-debug)
add_subdirectory(tools-misc)
add_subdirectory(utils)
add_subdirectory(pynfb)
add_subdirectory(python/nfb-tools)
configure_file(package/preinst.in package/preinst @ONLY)
configure_file(package/postinst.in package/postinst @ONLY)
configure_file(package/prerm.in package/prerm @ONLY)
configure_file(package/postrm.in package/postrm @ONLY)
set(RPM_DEP_LIST
dkms gcc kernel-devel libarchive libfdt-devel make numactl ncurses pciutils-libs
)
set(RPM_PYTHON_DEP_LIST
nfb-framework python3-fdt
)
set(DEB_DEP_LIST
dkms gcc libarchive-dev libfdt-dev libncurses-dev libnuma-dev linux-headers make libpci3
)
set(DEB_PYTHON_DEP_LIST
nfb-framework
)
# Common package settings
if(USE_DPDK)
set(CPACK_PACKAGE_NAME "temp-${PROJECT_NAME}+ndp_tools_dpdk")
else()
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
endif()
set(CPACK_PACKAGE_VENDOR "CESNET")
set(CPACK_PACKAGE_VERSION_MAJOR ${GIT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${GIT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${GIT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${GIT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NDK software library")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_RELOCATABLE OFF)
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_LIST_DIR}/package/description.txt")
# RPM (CentOS) package settings
set(CPACK_RPM_FILE_NAME RPM-DEFAULT)
set(CPACK_RPM_Main_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_RPM_DebugTools_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-debug")
set(CPACK_RPM_NfbExtGrpc_PACKAGE_NAME "nfb-ext-grpc")
# FIXME: use real Python version
set(CPACK_RPM_python_PACKAGE_NAME "python3-nfb")
set(CPACK_RPM_SPEC_MORE_DEFINE "%define __python python3")
set(CPACK_RPM_PACKAGE_RELEASE ${GIT_VERSION_RELEASE})
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
set(CPACK_RPM_PACKAGE_LICENSE "BSD and GPLv2")
string(JOIN " " CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEP_LIST})
string(JOIN " " CPACK_RPM_python_PACKAGE_REQUIRES ${RPM_PYTHON_DEP_LIST})
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
/etc/dracut.conf.d
/etc/udev
/etc/udev/rules.d
/usr/include/linux
/usr/lib/tmpfiles.d
/usr/lib64/pkgconfig
/usr/src
)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_LIST_DIR}/Changelog")
set(CPACK_RPM_Main_PACKAGE_OBSOLETES "netcope-common")
set(CPACK_RPM_DebugTools_PACKAGE_OBSOLETES "netcope-common-debug")
set(CPACK_RPM_Main_PACKAGE_PROVIDES "netcope-common")
set(CPACK_RPM_DebugTools_PACKAGE_PROVIDES "netcope-common-debug")
#set(CPACK_RPM_DebugTools_PACKAGE_REQUIRES "${PACKAGE_NAME} = ${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}")
if(USE_DPDK)
set(CPACK_RPM_ndp-tool-dpdk_PACKAGE_NAME "ndp-tool-dpdk")
set(CPACK_RPM_ndp-tool-dpdk_PACKAGE_REQUIRES "nfb-framework, dpdk-nfb, dpdk-nfb-tools")
set (CPACK_RPM_SOURCE_PKG_BUILD_PARAMS "-DUSE_DPDK=true")
endif()
set(CPACK_RPM_Main_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/package/preinst")
set(CPACK_RPM_Main_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/package/prerm")
set(CPACK_RPM_Main_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/package/postinst")
set(CPACK_RPM_Main_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/package/postrm")
# DEB (Ubuntu) package settings
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_DEBIAN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
set(CPACK_DEBIAN_PACKAGE_RELEASE "${GIT_VERSION_DEBRELEASE}")
set(CPACK_DEBIAN_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}.deb")
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_DEBIAN_MAIN_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}")
set(CPACK_DEBIAN_MAIN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
set(CPACK_DEBIAN_MAIN_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}.deb")
set(CPACK_DEBIAN_DEBUGTOOLS_PACKAGE_NAME "nfb-framework-debug")
set(CPACK_DEBIAN_DEBUGTOOLS_FILE_NAME "nfb-framework-debug-${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}.deb")
set(CPACK_DEBIAN_PYTHON_PACKAGE_NAME "python3-nfb")
set(CPACK_DEBIAN_PYTHON_FILE_NAME "python3-nfb-${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}.deb")
string(JOIN ", " CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEP_LIST})
string(JOIN ", " CPACK_DEBIAN_PYTHON_PACKAGE_DEPENDS ${DEB_PYTHON_DEP_LIST})
include(python/nfb-tools/nfb-tools.cmake)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_BINARY_DIR}/package/preinst"
"${CMAKE_CURRENT_BINARY_DIR}/package/postinst"
"${CMAKE_CURRENT_BINARY_DIR}/package/prerm"
)
include(CPack)