Julian Hall | b1d5d5f | 2020-11-23 18:23:48 +0100 | [diff] [blame^] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | #------------------------------------------------------------------------------- |
| 9 | # Import libts into a dependent in-tree deployment build. Where another |
| 10 | # deployment uses libts, including this file in the dependent deployment |
| 11 | # CMake build file allows libts to be built and installed into the binary |
| 12 | # directory of the dependent. |
| 13 | #------------------------------------------------------------------------------- |
| 14 | set(LIBTS_INSTALL_PATH "${CMAKE_CURRENT_BINARY_DIR}/libts_install" CACHE PATH "libts installation directory") |
| 15 | set(LIBTS_PACKAGE_PATH "${LIBTS_INSTALL_PATH}/lib/cmake" CACHE PATH "libts CMake package directory") |
| 16 | set(LIBTS_SOURCE_DIR "${TS_ROOT}/deployments/libts/${TS_ENV}" CACHE PATH "libts source directory") |
| 17 | set(LIBTS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/libts-build" CACHE PATH "libts binary directory") |
| 18 | |
| 19 | file(MAKE_DIRECTORY ${LIBTS_BINARY_DIR}) |
| 20 | |
| 21 | #Configure the library |
| 22 | execute_process(COMMAND |
| 23 | ${CMAKE_COMMAND} |
| 24 | -DCMAKE_INSTALL_PREFIX=${LIBTS_INSTALL_PATH} |
| 25 | -GUnix\ Makefiles |
| 26 | ${LIBTS_SOURCE_DIR} |
| 27 | WORKING_DIRECTORY |
| 28 | ${LIBTS_BINARY_DIR} |
| 29 | ) |
| 30 | |
| 31 | if (_exec_error) |
| 32 | message(FATAL_ERROR "Configuration step of libts failed with ${_exec_error}.") |
| 33 | endif() |
| 34 | |
| 35 | #Build the library |
| 36 | execute_process(COMMAND |
| 37 | ${CMAKE_COMMAND} --build ${LIBTS_BINARY_DIR} -- install -j8 |
| 38 | RESULT_VARIABLE _exec_error |
| 39 | ) |
| 40 | |
| 41 | if (_exec_error) |
| 42 | message(FATAL_ERROR "Build step of libts failed with ${_exec_error}.") |
| 43 | endif() |
| 44 | |
| 45 | # Import the built library |
| 46 | include(${LIBTS_INSTALL_PATH}/lib/cmake/libts_targets.cmake) |
| 47 | add_library(libts SHARED IMPORTED) |
| 48 | set_property(TARGET libts PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LIBTS_INSTALL_PATH}/include") |
| 49 | set_property(TARGET libts PROPERTY IMPORTED_LOCATION "${LIBTS_INSTALL_PATH}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}ts${CMAKE_SHARED_LIBRARY_SUFFIX}") |