blob: 71b5b35c31a75e26924ead564f6e2d895c9af484 [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#
14set(CMAKE_C_STANDARD 11)
15set(CMAKE_C_STANDARD_REQUIRED TRUE)
16set(CMAKE_C_EXTENSIONS TRUE)
17
18add_library(cxx_compiler_flags INTERFACE)
19target_compile_features(cxx_compiler_flags INTERFACE cxx_std_11)
20
21SET(TARGET_GROUP release CACHE STRING "Specify the Build Target [\"release\" by default]")
22
23add_library(tl STATIC "${CMAKE_CURRENT_SOURCE_DIR}/src/transfer_list.c")
24target_include_directories(tl PUBLIC include)
25target_link_libraries(tl PUBLIC cxx_compiler_flags)
26
27if(TARGET_GROUP STREQUAL test)
28 include(CTest)
29
30 # Check if local unity/ directory exists
31 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/unity/CMakeLists.txt")
32 message(STATUS "Using local Unity framework.")
33 add_subdirectory(unity)
34 else()
35 message(STATUS "Fetching Unity framework using FetchContent...")
36 include(FetchContent)
37 FetchContent_Declare(
38 unity
39 GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git
40 GIT_TAG master
41 )
42 FetchContent_MakeAvailable(unity)
43 endif()
44
45 add_subdirectory(test)
46endif()