Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
88 lines (79 loc) · 4.22 KB
/
Copy pathCMakeLists.txt
File metadata and controls
88 lines (79 loc) · 4.22 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
cmake_minimum_required(VERSION 3.16)
project(ctracker
VERSION 0.1.0
LANGUAGES C
)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
add_compile_options(-Wall -Wextra)
# Sanitizer build (NREQ-003): -DCTK_SANITIZE=address turns on ASan+UBSan for
# every target so `test.sh --asan` can prove the code leak/error-free without
# a separate Valgrind pass. Leave unset for a normal build usable directly
# under Valgrind.
set(CTK_SANITIZE "" CACHE STRING "Sanitizer to build with: empty (default) or 'address' (ASan+UBSan)")
if(CTK_SANITIZE STREQUAL "address")
add_compile_options(-fsanitize=address,undefined -fno-omit-frame-pointer -g)
add_link_options(-fsanitize=address,undefined)
elseif(NOT CTK_SANITIZE STREQUAL "")
message(FATAL_ERROR "Unsupported CTK_SANITIZE value '${CTK_SANITIZE}' (supported: address)")
endif()
# ncursesw via pkg-config (ADR-003); required so the TUI component can link
# against it once it lands (COMP-010/COMP-011). Resolved here so the whole
# tree shares one detection point.
find_package(PkgConfig REQUIRED)
pkg_check_modules(NCURSESW REQUIRED IMPORTED_TARGET ncursesw)
# libopenmpt playback core (REQ-024, ADR-010): link the SYSTEM library via
# pkg-config -- same IMPORTED_TARGET idiom as ncursesw above -- gated on a
# MINIMUM (not exact) version so distro security updates keep flowing
# (RISK-009). 0.3.0 is the version libopenmpt.h documents as having
# introduced the C API as a whole (openmpt_module_create_from_memory2 and
# openmpt_module_set_repeat_count are both tagged "\since 0.3.0"), and every
# IF-011 introspection getter this project uses (get_current_channel_vu_mono,
# get_pattern_row_channel_command, format_pattern_row_channel_command,
# get_current_speed/estimated_bpm, get_current_order/pattern/row,
# get_metadata, get_duration_seconds, get_num_channels,
# get_instrument_name/get_sample_name) carries no later \since tag, unlike
# genuinely newer additions (e.g. the typed ctl_get/set_* accessors,
# \since 0.5.0, or get_current_tempo2, \since 0.7.0) that this project does
# not rely on. Probed without a version bound first so a missing-vs-too-old
# library gets a distinct, actionable error message.
set(CTK_LIBOPENMPT_MIN_VERSION "0.3.0")
pkg_check_modules(LIBOPENMPT QUIET libopenmpt)
if(NOT LIBOPENMPT_FOUND)
message(FATAL_ERROR
"libopenmpt not found via pkg-config (module 'libopenmpt'). Install "
"the libopenmpt development package (e.g. 'libopenmpt-dev' on "
"Debian/Ubuntu -- see sdd-flow/environment/setup-env.sh), then "
"re-run ./build.sh.")
elseif(LIBOPENMPT_VERSION VERSION_LESS CTK_LIBOPENMPT_MIN_VERSION)
message(FATAL_ERROR
"libopenmpt ${LIBOPENMPT_VERSION} found via pkg-config, but "
"ctracker requires >= ${CTK_LIBOPENMPT_MIN_VERSION} (the "
"introspection getters IF-011 relies on are only guaranteed "
"present from that version on). Upgrade the libopenmpt-dev "
"package, then re-run ./build.sh.")
endif()
pkg_check_modules(LIBOPENMPT REQUIRED IMPORTED_TARGET
"libopenmpt>=${CTK_LIBOPENMPT_MIN_VERSION}")
add_subdirectory(third_party/miniaudio)
add_subdirectory(src)
# CTest, with Valgrind wired in as the memcheck driver so `ctest -T memcheck`
# (wrapped by test.sh --valgrind) runs the suite under Valgrind (NREQ-003).
# MEMORYCHECK_SUPPRESSIONS_FILE (COMP-013, ADR-010 decision 6) scopes out
# documented one-time third-party-internal allocations (see the file's own
# header) without masking a ctracker-owned leak.
find_program(MEMORYCHECK_COMMAND valgrind)
set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --show-leak-kinds=all --error-exitcode=1 --track-origins=yes")
# FORCE: CTest.cmake's own include(CTest) below declares this same cache
# variable with an empty default, which would otherwise silently win over a
# plain set() here (setting a CACHE variable clears any same-named normal
# variable already set) since it is a fresh cache entry on a clean checkout.
set(MEMORYCHECK_SUPPRESSIONS_FILE "${CMAKE_SOURCE_DIR}/tests/valgrind.supp"
CACHE FILEPATH "Valgrind suppressions for documented one-time third-party allocations" FORCE)
include(CTest)
add_subdirectory(tests)