blob: 8b58ec9d8afcd4e7d098eae75f6ec3de5ad02612 [file] [log] [blame]
Julian Hallb1d5d5f2020-11-23 18:23:48 +01001#-------------------------------------------------------------------------------
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#-------------------------------------------------------------------------------
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
46include(${LIBTS_INSTALL_PATH}/lib/cmake/libts_targets.cmake)
47add_library(libts SHARED IMPORTED)
48set_property(TARGET libts PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LIBTS_INSTALL_PATH}/include")
49set_property(TARGET libts PROPERTY IMPORTED_LOCATION "${LIBTS_INSTALL_PATH}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}ts${CMAKE_SHARED_LIBRARY_SUFFIX}")