-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
94 lines (78 loc) · 3.18 KB
/
CMakeLists.txt
File metadata and controls
94 lines (78 loc) · 3.18 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
# =====================================================================
# DMOD ENV CMake Configuration
# =====================================================================
cmake_minimum_required(VERSION 3.10)
# ======================================================================
# DMOD ENV
# ======================================================================
project(dmenv
VERSION 1.0
DESCRIPTION "DMOD Environment Variables Manager"
LANGUAGES C CXX)
set(DMENV_DONT_IMPLEMENT_DMOD_API OFF CACHE BOOL "Do not implement DMOD API in dmenv 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()
# ======================================================================
# DMOD ENV Library
# ======================================================================
set(MODULE_NAME dmenv)
add_library(${MODULE_NAME} STATIC
src/dmenv.c
)
target_compile_definitions(${MODULE_NAME}
PRIVATE
$<$<BOOL:${DMENV_DONT_IMPLEMENT_DMOD_API}>:DMENV_DONT_IMPLEMENT_DMOD_API>
DMENV_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 dmenv library if requested
if(ENABLE_COVERAGE)
target_compile_options(${MODULE_NAME} PRIVATE --coverage)
target_link_options(${MODULE_NAME} PRIVATE --coverage)
endif()
# Only run create_library_makefile if not in CI environment
# The memory_analysis.cmake script path has issues in FetchContent context
if(NOT DEFINED ENV{CI} AND COMMAND create_library_makefile)
create_library_makefile(${MODULE_NAME})
endif()
# ======================================================================
# Tests
# ======================================================================
option(DMENV_BUILD_TESTS "Build tests" OFF)
if(DMENV_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()