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