blob: d5a9f12390660f165386a52f75bcd96af2ae278a [file] [log] [blame]
Manish Pandey65fe3642025-03-21 12:44:42 +00001#
2# Copyright The Transfer List Library Contributors
3#
4# SPDX-License-Identifier: MIT OR GPL-2.0-or-later
5#
6
7cmake_minimum_required(VERSION 3.15)
8
9project(libtl VERSION 0.9 LANGUAGES C CXX ASM)
10
11#
12# Set global flags.
13#
Manish Pandey65fe3642025-03-21 12:44:42 +000014set(CMAKE_C_STANDARD_REQUIRED TRUE)
15set(CMAKE_C_EXTENSIONS TRUE)
16
17add_library(cxx_compiler_flags INTERFACE)
18target_compile_features(cxx_compiler_flags INTERFACE cxx_std_11)
19
20SET(TARGET_GROUP release CACHE STRING "Specify the Build Target [\"release\" by default]")
21
Harrison Mutaie0bc2c82025-05-08 15:36:08 +000022
23add_library(tl
24 STATIC
25 ${PROJECT_SOURCE_DIR}/src/generic/transfer_list.c
Harrison Mutai022175f2025-05-13 16:15:57 +000026 ${PROJECT_SOURCE_DIR}/src/generic/tpm_event_log.c
Harrison Mutai789db582025-04-28 14:46:49 +000027 ${PROJECT_SOURCE_DIR}/src/generic/logging.c
Harrison Mutaie0bc2c82025-05-08 15:36:08 +000028)
29
Harrison Mutaibd05e572025-04-16 14:20:35 +000030target_include_directories(tl
31 PUBLIC
32 ${PROJECT_SOURCE_DIR}/include
33)
Manish Pandey65fe3642025-03-21 12:44:42 +000034target_link_libraries(tl PUBLIC cxx_compiler_flags)
35
Harrison Mutaie0bc2c82025-05-08 15:36:08 +000036if(PROJECT_API)
37 include(${PROJECT_SOURCE_DIR}/cmake/ProjectApi.cmake)
38endif()
39
Manish Pandey65fe3642025-03-21 12:44:42 +000040if(TARGET_GROUP STREQUAL test)
41 include(CTest)
42
43 # Check if local unity/ directory exists
44 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/unity/CMakeLists.txt")
45 message(STATUS "Using local Unity framework.")
46 add_subdirectory(unity)
47 else()
48 message(STATUS "Fetching Unity framework using FetchContent...")
49 include(FetchContent)
50 FetchContent_Declare(
51 unity
52 GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git
53 GIT_TAG master
54 )
55 FetchContent_MakeAvailable(unity)
56 endif()
57
58 add_subdirectory(test)
59endif()