-
Notifications
You must be signed in to change notification settings - Fork 193
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
188 lines (178 loc) · 5.65 KB
/
Copy pathCMakeLists.txt
File metadata and controls
188 lines (178 loc) · 5.65 KB
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
# Copyright (C) 2022 Xilinx, Inc.
# Copyright (C) 2024-2026 Advanced Micro Devices, Inc.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
set(BOOTGEN_SOURCE ${PROJECT_SOURCE_DIR}/third_party/bootgen)
set(libsources
cdo-alloc.c
cdo-binary.c
cdo-command.c
cdo-load.c
cdo-metadata.c
cdo-npi.c
cdo-overlay.c
cdo-raw.c
cdo-source.c
cJSON.c
authentication.cpp
authentication-versal.cpp
authentication-zynq.cpp
authentication-zynqmp.cpp
authkeys.cpp
authkeys-versal.cpp
bifoptions.cpp
bif.tab.cpp
bif.yy.cpp
binary.cpp
binary-versal.cpp
binfile.cpp
bitutils.cpp
bitutils-versal.cpp
bootheader.cpp
bootheader-versal.cpp
bootheader-zynq.cpp
bootheader-zynqmp.cpp
bootimage.cpp
bootimage-versal.cpp
bootimage-zynq.cpp
bootimage-zynqmp.cpp
checksum.cpp
checksum-versal.cpp
cmdoptions.tab.cpp
cmdoptions.yy.cpp
elftools.cpp
encryption.cpp
encryption-versal.cpp
encryption-versalnet.cpp
encryption-zynq.cpp
encryption-zynqmp.cpp
encryptutils.cpp
hash.cpp
imageheadertable.cpp
imageheadertable-versal.cpp
imageheadertable-zynq.cpp
imageheadertable-zynqmp.cpp
kdf.cpp
Keccak-compact.cpp
Keccak-compact-versal.cpp
logger.cpp
# main.cpp
mcsfile.cpp
options.cpp
outputfile.cpp
outputfile-versal.cpp
parsing.cpp
partition.cpp
partitionheadertable.cpp
partitionheadertable-versal.cpp
partitionheadertable-zynq.cpp
partitionheadertable-zynqmp.cpp
partition-versal.cpp
postprocess.cpp
readimage.cpp
readimage-versal.cpp
readimage-zynq.cpp
readimage-zynqmp.cpp
reginit.cpp
reginit.tab.cpp
reginit.yy.cpp
verifyimage-versal.cpp
verifyimage-zynqmp.cpp
bootgen_c_api.cpp)
list(TRANSFORM libsources PREPEND ${BOOTGEN_SOURCE}/)
# malloc.h is deprecated and should not be used
# https://stackoverflow.com/a/56463133
# If you want to use malloc, then include stdlib.h
file(READ ${BOOTGEN_SOURCE}/cdo-npi.c FILE_CONTENTS)
string(REPLACE "#include <malloc.h>" "" FILE_CONTENTS "${FILE_CONTENTS}")
file(WRITE ${BOOTGEN_SOURCE}/cdo-npi.c "${FILE_CONTENTS}")
file(READ ${BOOTGEN_SOURCE}/cdo-alloc.c FILE_CONTENTS)
string(REPLACE "#include <malloc.h>" "" FILE_CONTENTS "${FILE_CONTENTS}")
file(WRITE ${BOOTGEN_SOURCE}/cdo-alloc.c "${FILE_CONTENTS}")
find_package(OpenSSL REQUIRED)
if (OPENSSL_FOUND)
message (STATUS "OpenSSL found")
message (STATUS "OpenSSL include directories:" ${OPENSSL_INCLUDE_DIR})
else()
message (FATAL_ERROR "OpenSSL Not found.")
endif()
# since we explicitly link OpenSSL::applink
file(READ ${BOOTGEN_SOURCE}/main.cpp FILE_CONTENTS)
string(REPLACE "#include \"openssl/ms/applink.c\"" "" FILE_CONTENTS "${FILE_CONTENTS}")
file(WRITE ${BOOTGEN_SOURCE}/main.cpp "${FILE_CONTENTS}")
add_library(bootgen-lib STATIC ${libsources})
# bootgen must be compiled with PIE/PIC, irrespective of the remainder of
# the project, because auditwheel repair's patchelf-based RPATH rewrite
# corrupts the non-PIE binary
set_target_properties(bootgen-lib PROPERTIES POSITION_INDEPENDENT_CODE ON)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
set(bootgen_warning_ignores
-Wno-cast-qual
-Wno-covered-switch-default
-Wno-date-time
-Wno-deprecated-copy
-Wno-deprecated-declarations
-Wno-deprecated-register
-Wno-dynamic-class-memaccess
-Wno-implicit-fallthrough
-Wno-incompatible-pointer-types-discards-qualifiers
-Wno-misleading-indentation
-Wno-non-virtual-dtor
-Wno-overloaded-virtual
-Wno-pointer-bool-conversion
-Wno-register
-Wno-reorder
-Wno-sign-compare
-Wno-suggest-override
-Wno-tautological-overlap-compare
-Wno-unused
)
else()
set(bootgen_warning_ignores)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_definitions(bootgen-lib PRIVATE YY_NO_UNISTD_H)
# Enable correct unwind semantics on MSVC
target_compile_options(bootgen-lib PRIVATE /EHsc)
# Suppress MSVC warning noise
target_compile_options(bootgen-lib PRIVATE /wd4996 /wd4840 /wd4005 /wd5033)
endif()
target_compile_options(bootgen-lib PRIVATE ${bootgen_warning_ignores})
target_include_directories(bootgen-lib PRIVATE ${BOOTGEN_SOURCE} ${OPENSSL_INCLUDE_DIR})
# Make C API header available publicly
target_include_directories(bootgen-lib PUBLIC
$<BUILD_INTERFACE:${BOOTGEN_SOURCE}>
$<INSTALL_INTERFACE:include>)
install(
TARGETS bootgen-lib
DESTINATION lib
EXPORT bootgen-lib)
install(
FILES ${BOOTGEN_SOURCE}/bootgen_c_api.h
DESTINATION include)
add_executable(bootgen ${BOOTGEN_SOURCE}/main.cpp)
set_target_properties(bootgen PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(bootgen PUBLIC ${BOOTGEN_SOURCE} ${OPENSSL_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/include)
target_compile_options(bootgen PRIVATE ${bootgen_warning_ignores})
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(bootgen PRIVATE /EHsc)
target_compile_options(bootgen PRIVATE /wd4996 /wd4840 /wd4005 /wd5033)
endif()
target_compile_definitions(bootgen PRIVATE OPENSSL_USE_APPLINK)
target_link_libraries(bootgen PRIVATE bootgen-lib OpenSSL::SSL OpenSSL::applink)
install(TARGETS bootgen)
add_library(cdo_driver_mlir_aie STATIC ${BOOTGEN_SOURCE}/cdo-driver/cdo_driver.c)
target_include_directories(
cdo_driver_mlir_aie PUBLIC $<BUILD_INTERFACE:${BOOTGEN_SOURCE}/cdo-driver>
$<INSTALL_INTERFACE:include/cdo_driver>)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(cdo_driver_mlir_aie PRIVATE -Wno-cast-qual -Wno-sign-compare)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(cdo_driver_mlir_aie PRIVATE /wd4996 /wd4840 /wd4005 /wd5033)
endif()
install(
TARGETS cdo_driver_mlir_aie
DESTINATION lib
EXPORT cdo_driver_mlir_aie)
install(EXPORT cdo_driver_mlir_aie DESTINATION lib/cmake/aie)