Skip to content

Commit 8d9771c

Browse files
committed
cmake cleanup
1 parent 697a2ca commit 8d9771c

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

CMakeLists.txt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,42 @@ cmake_minimum_required(VERSION 3.16)
33
# set the project name
44
project(snapclient)
55

6+
# we use FetchContent to install
7+
include(FetchContent)
8+
69
set(CMAKE_CXX_STANDARD 17)
710

8-
# lots of warnings and all warnings as errors
11+
# Disable Portaudio
12+
option(ADD_PORTAUDIO "Do not use Portaudio" OFF)
13+
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
14+
15+
16+
# lots of warnings and all warnings as errors ?
917
## add_compile_options(-Wall -Wextra )
1018

19+
# audio tools
20+
FetchContent_Declare(arduino-audio-tools GIT_REPOSITORY https://github.com/pschatzmann/arduino-audio-tools.git GIT_TAG main )
21+
FetchContent_GetProperties(arduino-audio-tools)
22+
if(NOT arduino-audio-tools_POPULATED)
23+
FetchContent_Populate(arduino-audio-tools)
24+
add_subdirectory(${arduino-audio-tools_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/arduino-audio-tools)
25+
endif()
26+
27+
# opus
28+
FetchContent_Declare(arduino_libopus GIT_REPOSITORY https://github.com/pschatzmann/arduino-libopus.git GIT_TAG main )
29+
FetchContent_GetProperties(arduino_libopus)
30+
if(NOT arduino_libopus_POPULATED)
31+
FetchContent_Populate(arduino_libopus)
32+
add_subdirectory(${arduino_libopus_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/arduino_libopus)
33+
endif()
34+
1135
add_library(snapclient INTERFACE)
1236

1337
# define location for header files
1438
target_include_directories(snapclient INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src )
1539

40+
# specify libraries
41+
target_link_libraries(snapclient INTERFACE arduino-audio-tools arduino_emulator arduino_libopus)
42+
1643

1744

desktop-client/CMakeLists.txt

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,8 @@ cmake_minimum_required(VERSION 2.34)
44
project(desktop-client)
55
set (CMAKE_CXX_STANDARD 11)
66
set (DCMAKE_CXX_FLAGS "-Werror")
7-
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
8-
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
9-
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
10-
endif()
117
include(FetchContent)
128

13-
# Disable Portaudio
14-
option(ADD_PORTAUDIO "Do not use Portaudio" OFF)
15-
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
16-
179
# Download miniaudio.h
1810
file(DOWNLOAD https://raw.githubusercontent.com/mackron/miniaudio/master/miniaudio.h
1911
${CMAKE_CURRENT_SOURCE_DIR}/miniaudio.h)
@@ -23,31 +15,14 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
2315
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/snapclient )
2416
endif()
2517

26-
# audio tools
27-
FetchContent_Declare(arduino-audio-tools GIT_REPOSITORY https://github.com/pschatzmann/arduino-audio-tools.git GIT_TAG main )
28-
FetchContent_GetProperties(arduino-audio-tools)
29-
if(NOT arduino-audio-tools_POPULATED)
30-
FetchContent_Populate(arduino-audio-tools)
31-
add_subdirectory(${arduino-audio-tools_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/arduino-audio-tools)
32-
endif()
33-
34-
# opus
35-
FetchContent_Declare(arduino_libopus GIT_REPOSITORY https://github.com/pschatzmann/arduino-libopus.git GIT_TAG main )
36-
FetchContent_GetProperties(arduino_libopus)
37-
if(NOT arduino_libopus_POPULATED)
38-
FetchContent_Populate(arduino_libopus)
39-
add_subdirectory(${arduino_libopus_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/arduino_libopus)
40-
endif()
41-
42-
4318
# build sketch as executable
4419
add_executable (desktop-client SnapClient.cpp)
4520

4621
# set preprocessor defines
4722
target_compile_definitions(desktop-client PUBLIC -DARDUINO -DEXIT_ON_STOP -DIS_DESKTOP -DCONFIG_USE_RTOS=0 -DCONFIG_USE_PSRAM=0 -DCONFIG_SNAPCLIENT_SNTP_ENABLE=0 -DCONFIG_SNAPCLIENT_USE_MDNS=0)
4823

4924
# specify libraries
50-
target_link_libraries(desktop-client snapclient arduino_emulator arduino_libopus arduino-audio-tools)
25+
target_link_libraries(desktop-client snapclient)
5126

5227
# to find include for miniaudio
5328
target_include_directories(desktop-client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

0 commit comments

Comments
 (0)