-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
112 lines (93 loc) · 4.25 KB
/
CMakeLists.txt
File metadata and controls
112 lines (93 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# =====================================================================
# DMOD OSI CMake Configuration
# =====================================================================
cmake_minimum_required(VERSION 3.10)
# ======================================================================
# DMOD OSI
# ======================================================================
project(dmosi
VERSION 1.0
DESCRIPTION "DMOD Operating System Interface"
LANGUAGES C CXX)
set(DMOSI_DONT_IMPLEMENT_DMOD_API OFF CACHE BOOL "Do not implement DMOD API in dmosi library")
set(DMOSI_DONT_IMPLEMENT_DMOD_API_MUTEX OFF CACHE BOOL "Do not implement DMOD Mutex API in dmosi library")
set(DMOSI_DONT_IMPLEMENT_DMOD_API_ENV OFF CACHE BOOL "Do not implement DMOD Environment API in dmosi library")
set(DMOSI_DONT_IMPLEMENT_DMOD_API_PROC OFF CACHE BOOL "Do not implement DMOD Process API in dmosi library")
set(DMOSI_DONT_IMPLEMENT_DMOD_API_TIME OFF CACHE BOOL "Do not implement DMOD Time API in dmosi library")
# ======================================================================
# Fetch DMOD repository
# ======================================================================
include(FetchContent)
# Only fetch and build dmod if it's not already available as a target
if(NOT TARGET dmod_inc)
FetchContent_Declare(
dmod
GIT_REPOSITORY https://github.com/choco-technologies/dmod.git
GIT_TAG develop
)
# ======================================================================
# DMOD Configuration
# ======================================================================
set(DMOD_MODE "DMOD_SYSTEM" CACHE STRING "DMOD build mode")
set(DMOD_BUILD_TESTS OFF CACHE BOOL "Build tests")
set(DMOD_BUILD_EXAMPLES OFF CACHE BOOL "Build examples")
set(DMOD_BUILD_TOOLS OFF CACHE BOOL "Build tools")
set(DMOD_BUILD_TEMPLATES OFF CACHE BOOL "Build templates")
# Pass coverage flags to DMOD if enabled
if(ENABLE_COVERAGE)
set(DMOD_ENABLE_COVERAGE ON CACHE BOOL "Enable DMOD coverage")
endif()
FetchContent_MakeAvailable(dmod)
set(DMOD_DIR ${dmod_SOURCE_DIR} CACHE PATH "DMOD source directory" FORCE)
else()
message(STATUS "dmod target already exists, skipping FetchContent")
endif()
include(${DMOD_DIR}/paths.cmake)
# ======================================================================
# DMOD OSI Interface Library
# ======================================================================
set(MODULE_NAME dmosi)
add_library(dmosi_if INTERFACE)
target_include_directories(dmosi_if
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/include
)
# ======================================================================
# DMOD OSI Library (system mode only)
# ======================================================================
if(DMOD_SYSTEM)
add_library(${MODULE_NAME} STATIC
src/dmosi.c
)
target_compile_definitions(${MODULE_NAME}
PRIVATE
$<$<BOOL:${DMOSI_DONT_IMPLEMENT_DMOD_API}>:DMOSI_DONT_IMPLEMENT_DMOD_API>
$<$<BOOL:${DMOSI_DONT_IMPLEMENT_DMOD_API_MUTEX}>:DMOSI_DONT_IMPLEMENT_DMOD_API_MUTEX>
$<$<BOOL:${DMOSI_DONT_IMPLEMENT_DMOD_API_ENV}>:DMOSI_DONT_IMPLEMENT_DMOD_API_ENV>
$<$<BOOL:${DMOSI_DONT_IMPLEMENT_DMOD_API_PROC}>:DMOSI_DONT_IMPLEMENT_DMOD_API_PROC>
$<$<BOOL:${DMOSI_DONT_IMPLEMENT_DMOD_API_TIME}>:DMOSI_DONT_IMPLEMENT_DMOD_API_TIME>
DMOSI_VERSION="${PROJECT_VERSION}"
)
target_include_directories(${MODULE_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(${MODULE_NAME}
PRIVATE
dmod_inc
)
# Enable coverage for dmosi library if requested
if(ENABLE_COVERAGE)
target_compile_options(${MODULE_NAME} PRIVATE --coverage)
target_link_options(${MODULE_NAME} PRIVATE --coverage)
endif()
create_library_makefile(${MODULE_NAME})
endif()
# ======================================================================
# Tests
# ======================================================================
option(DMOSI_BUILD_TESTS "Build tests" OFF)
if(DMOSI_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()