blob: 35c83796e8be570902ebbe40a68bd3787c57a29e [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
22add_library(tl STATIC "${CMAKE_CURRENT_SOURCE_DIR}/src/transfer_list.c")
Harrison Mutaibd05e572025-04-16 14:20:35 +000023target_include_directories(tl
24 PUBLIC
25 ${PROJECT_SOURCE_DIR}/include
26)
27
Manish Pandey65fe3642025-03-21 12:44:42 +000028target_link_libraries(tl PUBLIC cxx_compiler_flags)
29
30if(TARGET_GROUP STREQUAL test)
31 include(CTest)
32
33 # Check if local unity/ directory exists
34 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/unity/CMakeLists.txt")
35 message(STATUS "Using local Unity framework.")
36 add_subdirectory(unity)
37 else()
38 message(STATUS "Fetching Unity framework using FetchContent...")
39 include(FetchContent)
40 FetchContent_Declare(
41 unity
42 GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git
43 GIT_TAG master
44 )
45 FetchContent_MakeAvailable(unity)
46 endif()
47
48 add_subdirectory(test)
49endif()