1
1
2
- cmake_minimum_required (VERSION 3.4 )
2
+ cmake_minimum_required (VERSION 3.26 )
3
3
project (LabSoundCDemo)
4
4
5
5
# Don't report that sample file installation up to date
6
6
set (CMAKE_INSTALL_MESSAGE LAZY)
7
7
8
8
set (LABSOUNDCDEMO_ROOT ${CMAKE_CURRENT_SOURCE_DIR} )
9
- configure_file ("${LABSOUNDCDEMO_ROOT} /LabSoundDemo.config.h" "${LABSOUNDCDEMO_ROOT} /LabSoundDemo.h" @ONLY)
9
+ configure_file ("${LABSOUNDCDEMO_ROOT} /LabSoundDemo.config.h"
10
+ "${LABSOUNDCDEMO_ROOT} /LabSoundDemo.h" @ONLY)
10
11
11
- find_package (libnyquist REQUIRED)
12
- find_package (LabSound REQUIRED)
13
- find_package (LabSoundRtAudio REQUIRED)
12
+ # Find LabSound and dependencies
13
+ find_package (LabSound QUIET )
14
14
15
- if (APPLE )
16
- set (PLATFORM_LIBS
15
+ # if LabSound is not found, use FetchContent to download it
16
+ if (NOT LabSound_FOUND)
17
+ include (FetchContent)
18
+ FetchContent_Declare(
19
+ LabSound
20
+ GIT_REPOSITORY "http://github.com/LabSound/LabSound.git"
21
+ GIT_TAG "main"
22
+ )
23
+ message (STATUS "Fetching LabSound from source" )
24
+ FetchContent_MakeAvailable(LabSound)
25
+ message (STATUS "LabSound found at: ${LabSound_SOURCE_DIR} " )
26
+ endif ()
27
+
28
+ if (APPLE )
29
+ set (PLATFORM_LIBS
17
30
"-framework AudioToolbox"
18
31
"-framework AudioUnit"
19
32
"-framework Accelerate"
@@ -25,15 +38,38 @@ if (APPLE)
25
38
)
26
39
endif ()
27
40
28
- add_executable (LabSoundCDemo
29
- labsound-c.h labsound-c.cpp
30
- tinycthread.h tinycthread.c
41
+ add_executable (LabSoundCDemo
42
+ labsound-c.h labsound-c.cpp
43
+ tinycthread.h tinycthread.c
31
44
LabSoundCDemo.c flecs.h flecs.c)
45
+
32
46
set_property (TARGET LabSoundCDemo PROPERTY C_STANDARD 11)
33
47
set_property (TARGET LabSoundCDemo PROPERTY CXX_STANDARD 17)
34
- target_link_libraries (LabSoundCDemo
35
- LabSound::LabSound
48
+ target_link_libraries (LabSoundCDemo
49
+ LabSound::LabSound
36
50
LabSoundRtAudio::LabSoundRtAudio
37
51
${PLATFORM_LIBS} )
38
52
target_include_directories (LabSoundCDemo PRIVATE "${LABSOUNDDEMO_ROOT} " )
39
53
install (TARGETS LabSoundCDemo RUNTIME DESTINATION bin)
54
+
55
+ # Copy the sample files from LabSound sources, src/assets/samples to
56
+ # assets/samples in the run time bin directory
57
+ message (STATUS "Copying sample files from ${LabSound_SOURCE_DIR} /assets/samples" )
58
+ file (GLOB SAMPLES "${LabSound_SOURCE_DIR} /assets/samples/*" )
59
+ foreach (SAMPLE ${SAMPLES} )
60
+ message (STATUS "Copying sample file: ${SAMPLE} " )
61
+ get_filename_component (SAMPLE_NAME ${SAMPLE} NAME )
62
+
63
+ # if the sample is a directory, copy the directory and its contents
64
+ if (IS_DIRECTORY ${SAMPLE} )
65
+ # into the binary dir for easy debugging
66
+ file (COPY ${SAMPLE} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} /assets/samples)
67
+ # if installing, copy the directory and its contents
68
+ install (DIRECTORY ${SAMPLE} DESTINATION bin/assets/samples)
69
+ else ()
70
+ # into the binary dir for easy debugging
71
+ configure_file (${SAMPLE} ${CMAKE_CURRENT_BINARY_DIR} /assets/samples/${SAMPLE_NAME} COPYONLY )
72
+ # if installing, copy the file
73
+ install (FILES ${SAMPLE} DESTINATION bin/assets/samples)
74
+ endif ()
75
+ endforeach ()
0 commit comments