forked from OFS/opae-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
375 lines (323 loc) · 13.3 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
## Copyright(c) 2017, Intel Corporation
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
##
## * Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright notice,
## this list of conditions and the following disclaimer in the documentation
## and/or other materials provided with the distribution.
## * Neither the name of Intel Corporation nor the names of its contributors
## may be used to endorse or promote products derived from this software
## without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
## POSSIBILITY OF SUCH DAMAGE.
cmake_minimum_required(VERSION 2.8.12)
project(opae)
############################################################################
## Get git hash info, if available #########################################
############################################################################
find_program(GIT_EXECUTABLE git)
if(EXISTS ${GIT_EXECUTABLE})
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
RESULT_VARIABLE GIT_LOG_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${GIT_LOG_RESULT} EQUAL 0)
set(GIT_COMMIT_HASH unknown)
endif(NOT ${GIT_LOG_RESULT} EQUAL 0)
else(EXISTS ${GIT_EXECUTABLE})
set(GIT_COMMIT_HASH unknown)
endif(EXISTS ${GIT_EXECUTABLE})
############################################################################
## Add 'versioning' library ################################################
############################################################################
set(INTEL_FPGA_API_VER_MAJOR 0 CACHE STRING "Intel FPGA API major version")
set(INTEL_FPGA_API_VER_MINOR 13 CACHE STRING "Intel FPGA API minor version")
set(INTEL_FPGA_API_VER_REV 0 CACHE STRING "Intel FPGA API revision version")
set(INTEL_FPGA_API_VERSION ${INTEL_FPGA_API_VER_MAJOR}.${INTEL_FPGA_API_VER_MINOR}.${INTEL_FPGA_API_VER_REV})
set(INTEL_FPGA_API_HASH ${GIT_COMMIT_HASH})
############################################################################
## Compilation configuration ###############################################
############################################################################
set(OPAE_SDK_SOURCE ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Root directory of opae-sdk project" FORCE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OPAE_SDK_SOURCE}/cmake/modules")
include(compiler_config)
include(libraries_config)
include(fpga_functions)
############################################################################
## Target configuration ####################################################
############################################################################
# Place all executables and libraries under same directories
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE PATH "Build directory" FORCE)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE PATH "Build directory" FORCE)
############################################################################
## Compilation configuration ###############################################
############################################################################
set(COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/common)
set(OPAE_INCLUDE_DIR ${COMMON_DIR}/include CACHE PATH "Path to include directory" FORCE)
add_custom_target(copy-common-opae-header-files ALL
COMMAND cmake -E copy_directory ${OPAE_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/include)
# Install common header files
install(DIRECTORY common/include/opae
DESTINATION include
COMPONENT libopaeheaders)
install(DIRECTORY common/include/safe_string
DESTINATION include
COMPONENT safestrheaders)
############################################################################
## Add 'documentation' target ##############################################
############################################################################
option(BUILD_SPHINX_DOC "Enable building of Sphinx documentation." OFF)
mark_as_advanced(BUILD_SPHINX_DOC)
find_package(Doxygen)
if (DOXYGEN_FOUND)
add_subdirectory(doc)
endif()
############################################################################
## Sub-projects ############################################################
############################################################################
add_subdirectory(safe_string)
option(BUILD_LIBOPAE_C "Enable building of libopae-c. This is the default OPAE API implementation." ON)
mark_as_advanced(BUILD_LIBOPAE_C)
if(BUILD_LIBOPAE_C)
add_subdirectory(libopae)
endif()
add_subdirectory(platforms)
add_subdirectory(tools/userclk)
add_subdirectory(tools/fpgad)
add_subdirectory(tools/ras)
add_subdirectory(tools/mmlink)
add_subdirectory(tools/coreidle)
add_subdirectory(tools/fpgaconf)
add_subdirectory(tools/fpgabist)
add_subdirectory(tools/fpgaflash)
add_subdirectory(tools/fpgainfo)
add_subdirectory(tools/c++utils)
add_subdirectory(tools/libopae++)
add_subdirectory(tools/fpgadiag)
add_subdirectory(tools/fpgaport)
add_subdirectory(tools/hssi)
add_subdirectory(tools/packager)
option(BUILD_ASE "Enable ASE compilation" ON)
mark_as_advanced(BUILD_ASE)
if(BUILD_ASE)
add_subdirectory(ase/api)
add_subdirectory(ase)
endif()
if (NOT BUILD_ASE AND NOT BUILD_LIBOPAE_C)
message(FATAL_ERROR "Not building any OPAE libraries")
endif()
find_package(Threads REQUIRED)
############################################################################
## Add 'samples' ###########################################################
############################################################################
add_subdirectory(samples)
############################################################################
## Add 'tests' #############################################################
############################################################################
option(BUILD_TESTS "Enable tests compilation" OFF)
mark_as_advanced(BUILD_TESTS)
if(BUILD_TESTS)
enable_testing()
include(CTest)
add_subdirectory(tests)
endif()
############################################################################
## RPATH Handling ##########################################################
############################################################################
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
############################################################################
## Packaging ###############################################################
############################################################################
option(HASH_ARCHIVES "Add git commit hash to archive names" OFF)
mark_as_advanced(HASH_ARCHIVES)
include(packaging)
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Programmable Acceleration Engine")
SET(CPACK_PACKAGE_VENDOR "Intel Corporation")
set(CPACK_PACKAGE_VERSION_MAJOR "${INTEL_FPGA_API_VER_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${INTEL_FPGA_API_VER_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${INTEL_FPGA_API_VER_REV}")
set(CPACK_PACKAGE_VERSION ${INTEL_FPGA_API_VERSION})
set(CPACK_PACKAGE_RELEASE 1)
# Component definition
define_pkg(libs
COMPONENTS
opaeclib
GROUP "libs"
DISPLAY_NAME "opae-libs"
DESCRIPTION "OPAE runtime"
RPM_REQUIRES "uuid , json-c , boost")
define_pkg(devel
COMPONENTS
libopaeheaders
dochtml
doclatex
docrtf
docman
docxml
platform
samplesrc
safestrlib
safestrheaders
GROUP "devel"
DISPLAY_NAME "opae-devel"
DESCRIPTION "OPAE headers, sample source, and documentation"
DEPENDS "libs"
RPM_REQUIRES "libuuid-devel , json-c-devel , boost-devel , opae-libs")
define_pkg(tools
COMPONENTS
tooluserclk
toolfpgad
toolras
toolmmlink
toolcoreidle
toolfpgaconf
toolfpgadiag
toolfpgabist
toolfpga_dma_test
toolbist_app
toolfpgadiagapps
toolfpgaflash
toolfpgainfo
toolfpgaport
toolpackager
opaecxxutils
opaecxxlib
opaecxxnlb
hssiiolib
hssiprograms
GROUP "tools"
DISPLAY_NAME "opae-tools"
DESCRIPTION "OPAE tool binaries"
DEPENDS "libs"
RPM_REQUIRES "boost-devel, opae-libs , opae-devel")
define_pkg(ase
COMPONENTS
opaecase
asertl
asescripts
aseextra
asesw
GROUP "ase"
DISPLAY_NAME "opae-ase"
DESCRIPTION "OPAE AFU Simulation Environment"
DEPENDS "devel"
RPM_REQUIRES "boost , opae-libs , opae-devel")
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
set(CPACK_COMPONENT_GROUPS_ALL libs devel tools ase all)
# Hashing the package components
if(HASH_ARCHIVES)
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}-git${GIT_COMMIT_HASH}")
else()
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
endif()
# Binary packaging target
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_RPM_PACKAGE_COMPONENT ON)
set(CPACK_DEB_PACKAGE_COMPONENT ON)
set(CPACK_RPM_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE})
set(CPACK_RPM_PACKAGE_LICENSE "BSD 3.0")
# Run ldconfig after installation
option(RUN_LDCONFIG "Enable execution of ldconfig after installation" ON)
mark_as_advanced(RUN_LDCONFIG)
if (RUN_LDCONFIG)
if (NOT CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR "lib")
endif()
set(LDCONFIG_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
file(WRITE ${PROJECT_BINARY_DIR}/scripts/postinst "
mkdir -p /etc/ld.so.conf.d
echo \"${LDCONFIG_DIR}\" > /etc/ld.so.conf.d/opae-c.conf
ldconfig
")
file(WRITE ${PROJECT_BINARY_DIR}/scripts/prerm "
rm -f -- /etc/ld.so.conf.d/opae-c.conf
ldconfig
")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/scripts/postinst;${PROJECT_BINARY_DIR}/scripts/prerm")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/scripts/postinst")
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/scripts/prerm")
endif(RUN_LDCONFIG)
# /usr, /usr/lib are already present in CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST,
# but some Linux distributions complain without this explicit suppression
set(CPACK_RPM_SPEC_MORE_DEFINE "%define ignore \#")
set(CPACK_RPM_USER_FILELIST
"%ignore /"
"%ignore /usr"
"%ignore /usr/bin"
"%ignore /usr/lib"
"%ignore /usr/share"
"%ignore /usr/include"
"%ignore /usr/src"
"%ignore /usr/doc")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST
"/"
"/usr"
"/usr/bin"
"/usr/lib"
"/usr/share"
"/usr/include"
"/usr/src"
"/usr/doc")
# Source code packaging target
set(CPACK_SOURCE_GENERATOR "TGZ")
if (HASH_ARCHIVES)
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_PACKAGE_RELEASE}_git${GIT_COMMIT_HASH}")
set(DEFINE_RPM_NAME "%define _rpmfilename %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}_git${GIT_COMMIT_HASH}.%%{ARCH}.rpm")
else()
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_PACKAGE_RELEASE}")
set(DEFINE_RPM_NAME "")
endif()
# Ignore following files in the final package
set(CPACK_SOURCE_IGNORE_FILES
"coverage.cmake"
"/mybuild/"
"/build/"
"/.git"
"~$"
${CPACK_SOURCE_IGNORE_FILES})
include(CPack)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
############################################################################
## Meta Package RPM ########################################################
############################################################################
set(MODULE_NAME libopae-all)
set(PACKAGE_PACKAGER_NAME "The OPAE Development Team")
set(PACKAGE_PACKAGER_EMAIL ${CPACK_PACKAGE_CONTACT})
set(PACKAGE_NAME opae-all)
set(PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
set(PACKAGE_SUMMARY "OPAE meta-package")
set(PACKAGE_DESCRIPTION "OPAE meta-package")
set(PACKAGE_VENDOR "Intel Corporation")
set(PACKAGE_URL http://www.intel.com)
set(PACKAGE_SRC_TAR_NAME ${CPACK_SOURCE_PACKAGE_FILE_NAME})
set(CONFIG_TEMPLATE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/config")
configure_file(${CONFIG_TEMPLATE_PATH}/libopae-all.spec.in
${CMAKE_CURRENT_BINARY_DIR}/libopae-all.spec @ONLY)
find_program(RPMBUILD_EXECUTABLE rpmbuild)
if(EXISTS ${RPMBUILD_EXECUTABLE})
add_custom_target(metarpm
COMMAND ${RPMBUILD_EXECUTABLE} -bb libopae-all.spec
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif(EXISTS ${RPMBUILD_EXECUTABLE})