blob: 42bc3aaddd92400d19a2b9d604ab6fa5b5b7057a [file] [log] [blame]
Julian Hallb1d5d5f2020-11-23 18:23:48 +01001#-------------------------------------------------------------------------------
Gyorgy Szingc31afbf2021-02-12 01:51:55 +01002# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
Julian Hallb1d5d5f2020-11-23 18:23:48 +01003#
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#-------------------------------------------------------------------------------
14set(LIBTS_INSTALL_PATH "${CMAKE_CURRENT_BINARY_DIR}/libts_install" CACHE PATH "libts installation directory")
15set(LIBTS_PACKAGE_PATH "${LIBTS_INSTALL_PATH}/lib/cmake" CACHE PATH "libts CMake package directory")
16set(LIBTS_SOURCE_DIR "${TS_ROOT}/deployments/libts/${TS_ENV}" CACHE PATH "libts source directory")
17set(LIBTS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/libts-build" CACHE PATH "libts binary directory")
18
19file(MAKE_DIRECTORY ${LIBTS_BINARY_DIR})
20
21#Configure the library
22execute_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
31if (_exec_error)
32 message(FATAL_ERROR "Configuration step of libts failed with ${_exec_error}.")
33endif()
34
35#Build the library
36execute_process(COMMAND
37 ${CMAKE_COMMAND} --build ${LIBTS_BINARY_DIR} -- install -j8
38 RESULT_VARIABLE _exec_error
39)
40
41if (_exec_error)
42 message(FATAL_ERROR "Build step of libts failed with ${_exec_error}.")
43endif()
44
45# Import the built library
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010046include(${LIBTS_INSTALL_PATH}/${TS_ENV}/lib/cmake/libts_targets.cmake)
Julian Hallb1d5d5f2020-11-23 18:23:48 +010047add_library(libts SHARED IMPORTED)
Gyorgy Szingc31afbf2021-02-12 01:51:55 +010048set_property(TARGET libts PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LIBTS_INSTALL_PATH}/${TS_ENV}/include")
49set_property(TARGET libts PROPERTY IMPORTED_LOCATION "${LIBTS_INSTALL_PATH}/${TS_ENV}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}ts${CMAKE_SHARED_LIBRARY_SUFFIX}")