forked from Xilinx/aiebu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
112 lines (86 loc) · 3.59 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
# SPDX-License-Identifier: MIT
# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
cmake_minimum_required(VERSION 3.18.0)
project(AIEBU HOMEPAGE_URL https://github.com/Xilinx/aiebu)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(AIEBU_INSTALL_DIR "aiebu")
message("-- CMAKE_SYSTEM=${CMAKE_SYSTEM}")
find_package(Git REQUIRED)
if (DEFINED XRT_SOURCE_DIR)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --show-superproject-working-tree
WORKING_DIRECTORY ${AIEBU_SOURCE_DIR}
OUTPUT_VARIABLE PARENT_PROJECT_ROOT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message("-- Compiling AIEBU as a submodule of: ${PARENT_PROJECT_ROOT}")
# Make AIEBU .clangd configuration for compile_commands.json point back to the compile_commands.json
# in the top level repository
SET(DEBUG_DIR_NAME "Debug")
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
file(CREATE_LINK "${PARENT_PROJECT_ROOT}/build/${DEBUG_DIR_NAME}" "${AIEBU_SOURCE_DIR}/build/${DEBUG_DIR_NAME}" SYMBOLIC)
endif()
else()
# define our own install area when compiling independently
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(CMAKE_INSTALL_PREFIX "/opt/xilinx")
else()
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/xilinx" CACHE PATH "..." FORCE)
endif()
endif()
message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
# If this repository is used as a submodule, the parent repository may set the
# following variables in CMake to make aiebu point to the parents copy of ELFIO
# and/or AIE-RT. e.g, XRT parent repository can set the following in its CMake
# for aiebu to inherit it:
# set(AIEBU_AIE_RT_BIN_DIR ${XRT_BINARY_DIR})
# set(AIEBU_ELFIO_SRC_DIR "${XRT_SOURCE_DIR}/src/runtime_src/core/common/elf")
# These variables may be defined by the parent project as it may also include
# AIE-RT and or ELFIO as a submodule
# AIEBU_AIE_RT_BIN_DIR, AIEBU_AIE_RT_HEADER_DIR and AIEBU_ELFIO_SRC_DIR
if (NOT (DEFINED AIEBU_AIE_RT_BIN_DIR))
set(AIEBU_AIE_RT_BIN_DIR ${AIEBU_BINARY_DIR})
endif()
if (NOT (DEFINED AIEBU_AIE_RT_HEADER_DIR))
set(AIEBU_AIE_RT_HEADER_DIR "${AIEBU_BINARY_DIR}/lib/aie-rt/driver/driver-src/include")
endif()
message("-- Using aie-rt headers from ${AIEBU_AIE_RT_HEADER_DIR}")
message("-- Using aie-rt build from ${AIEBU_AIE_RT_BIN_DIR}")
if (NOT (DEFINED AIEBU_ELFIO_SRC_DIR))
set(AIEBU_ELFIO_SRC_DIR "${AIEBU_SOURCE_DIR}/src/cpp/ELFIO")
endif()
message("-- Using ELFIO from ${AIEBU_ELFIO_SRC_DIR}")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
find_package(OpenSSL REQUIRED)
message("-- OpenSSL path: ${OPENSSL_LIBRARIES}")
endif()
find_package(Python3 COMPONENTS Interpreter REQUIRED)
message("-- Python version: ${Python3_VERSION}")
if (XRT_CLANG_TIDY STREQUAL "ON")
find_program(CLANG_TIDY "clang-tidy")
if(NOT CLANG_TIDY)
message(FATAL_ERROR "clang-tidy not found, cannot enable static analysis")
else()
message("-- Enabling clang-tidy")
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
endif()
endif()
enable_testing()
add_subdirectory(src/cpp/aiebu)
add_subdirectory(lib)
add_subdirectory(test/cpp_test)
add_subdirectory(test)
if (NOT(DEFINED XRT_SOURCE_DIR))
SET(PACKAGE_KIND "TGZ")
SET(CPACK_GENERATOR "TGZ")
message("-- ${CMAKE_BUILD_TYPE} ${PACKAGE_KIND} package")
SET(CPACK_PACKAGE_VENDOR "Advanced Micro Devices Inc.")
SET(CPACK_PACKAGE_CONTACT "[email protected]")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AMD XDNA binutils package")
SET(CPACK_RESOURCE_FILE_LICENSE "${AIEBU_SOURCE_DIR}/LICENSE")
INCLUDE(CPack)
else()
message("-- Skipping private cpack of AIEBU since compiling as a submodule")
endif()