Rui Miguel Silva | 427e820 | 2021-12-03 16:36:51 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2022 Linaro Limited |
Gyorgy Szing | c9b6b63 | 2023-02-15 10:45:26 +0100 | [diff] [blame] | 3 | # Copyright (c) 2022-2023, Arm Limited. All rights reserved. |
Rui Miguel Silva | 427e820 | 2021-12-03 16:36:51 +0000 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | #------------------------------------------------------------------------------- |
| 8 | |
| 9 | set (OPENAMP_URL "https://github.com/OpenAMP/open-amp.git" |
Gyorgy Szing | c9b6b63 | 2023-02-15 10:45:26 +0100 | [diff] [blame] | 10 | CACHE STRING "OpenAMP repository URL") |
Rui Miguel Silva | 427e820 | 2021-12-03 16:36:51 +0000 | [diff] [blame] | 11 | set (OPENAMP_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/openamp_install" |
Gyorgy Szing | c9b6b63 | 2023-02-15 10:45:26 +0100 | [diff] [blame] | 12 | CACHE PATH "OpenAMP installation directory") |
Rui Miguel Silva | 427e820 | 2021-12-03 16:36:51 +0000 | [diff] [blame] | 13 | set (OPENAMP_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/openamp" |
Gyorgy Szing | c9b6b63 | 2023-02-15 10:45:26 +0100 | [diff] [blame] | 14 | CACHE PATH "OpenAMP source code directory") |
Rui Miguel Silva | 427e820 | 2021-12-03 16:36:51 +0000 | [diff] [blame] | 15 | set (OPENAMP_PACKAGE_DIR "${OPENAMP_INSTALL_DIR}/openamp/cmake" |
Gyorgy Szing | c9b6b63 | 2023-02-15 10:45:26 +0100 | [diff] [blame] | 16 | CACHE PATH "OpenAMP CMake package directory") |
Rui Miguel Silva | 427e820 | 2021-12-03 16:36:51 +0000 | [diff] [blame] | 17 | set (OPENAMP_REFSPEC "347397decaa43372fc4d00f965640ebde042966d" |
Gyorgy Szing | c9b6b63 | 2023-02-15 10:45:26 +0100 | [diff] [blame] | 18 | CACHE STRING "The version of openamp to use") |
Rui Miguel Silva | 427e820 | 2021-12-03 16:36:51 +0000 | [diff] [blame] | 19 | |
Gyorgy Szing | c9b6b63 | 2023-02-15 10:45:26 +0100 | [diff] [blame] | 20 | set(GIT_OPTIONS_OPENAMP |
Rui Miguel Silva | 427e820 | 2021-12-03 16:36:51 +0000 | [diff] [blame] | 21 | GIT_REPOSITORY ${OPENAMP_URL} |
| 22 | GIT_TAG ${OPENAMP_REFSPEC} |
| 23 | GIT_SHALLOW FALSE |
| 24 | ) |
| 25 | |
| 26 | if(NOT OPENAMP_DEBUG) |
| 27 | set(OPENAMP_BUILD_TYPE "Release") |
| 28 | else() |
| 29 | set(OPENAMP_BUILD_TYPE "Debug") |
| 30 | endif() |
| 31 | |
Gyorgy Szing | c9b6b63 | 2023-02-15 10:45:26 +0100 | [diff] [blame] | 32 | # Add libmetal dependency |
| 33 | include(${TS_ROOT}/external/openamp/libmetal.cmake) |
| 34 | |
Rui Miguel Silva | 427e820 | 2021-12-03 16:36:51 +0000 | [diff] [blame] | 35 | include(FetchContent) |
| 36 | |
| 37 | # Checking git |
| 38 | find_program(GIT_COMMAND "git") |
| 39 | if (NOT GIT_COMMAND) |
| 40 | message(FATAL_ERROR "Please install git") |
| 41 | endif() |
| 42 | |
| 43 | # Only pass libc settings to openamp if needed. For environments where the |
| 44 | # standard library is not overridden, this is not needed. |
| 45 | if(TARGET stdlib::c) |
| 46 | include(${TS_ROOT}/tools/cmake/common/PropertyCopy.cmake) |
| 47 | |
| 48 | # Save libc settings |
| 49 | save_interface_target_properties(TGT stdlib::c PREFIX LIBC) |
| 50 | # Translate libc settings to cmake code fragment. Will be inserted into |
| 51 | # libmetal-init-cache.cmake.in when LazyFetch configures the file. |
| 52 | translate_interface_target_properties(PREFIX LIBC RES _cmake_fragment) |
| 53 | unset_saved_properties(LIBC) |
| 54 | endif() |
| 55 | |
| 56 | include(${TS_ROOT}/tools/cmake/common/LazyFetch.cmake REQUIRED) |
| 57 | LazyFetch_MakeAvailable(DEP_NAME openamp |
Gyorgy Szing | c9b6b63 | 2023-02-15 10:45:26 +0100 | [diff] [blame] | 58 | FETCH_OPTIONS "${GIT_OPTIONS_OPENAMP}" |
Rui Miguel Silva | 427e820 | 2021-12-03 16:36:51 +0000 | [diff] [blame] | 59 | INSTALL_DIR "${OPENAMP_INSTALL_DIR}" |
| 60 | CACHE_FILE "${TS_ROOT}/external/openamp/openamp-init-cache.cmake.in" |
| 61 | SOURCE_DIR "${OPENAMP_SOURCE_DIR}" |
| 62 | ) |
| 63 | unset(_cmake_fragment) |
| 64 | |
| 65 | #Create an imported target to have clean abstraction in the build-system. |
| 66 | add_library(openamp STATIC IMPORTED) |
| 67 | set_property(TARGET openamp PROPERTY IMPORTED_LOCATION "${OPENAMP_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}open_amp${CMAKE_STATIC_LIBRARY_SUFFIX}") |
| 68 | set_property(TARGET openamp PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${OPENAMP_INSTALL_DIR}/include") |
Gyorgy Szing | c9b6b63 | 2023-02-15 10:45:26 +0100 | [diff] [blame] | 69 | target_link_libraries(openamp INTERFACE libmetal) |