-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
76 lines (59 loc) · 1.85 KB
/
CMakeLists.txt
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
# CMakeLists.txt
# Copyright (c) 2014-2020 Arkadiusz Bokowy
#
# This file is a part of SVAR.
#
# This project is licensed under the terms of the MIT license.
cmake_minimum_required(VERSION 3.1)
project(svar
VERSION 1.2.0
DESCRIPTION "Simple Voice Activated Recorder"
LANGUAGES C)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(DEBUG TRUE)
endif()
if(CMAKE_SYSTEM_NAME MATCHES Linux)
option(ENABLE_PORTAUDIO "Use PortAudio as an audio back-end.")
else()
set(ENABLE_PORTAUDIO ON)
endif()
option(ENABLE_MP3LAME "Enable MP3 support.")
option(ENABLE_SNDFILE "Enable WAV support.")
option(ENABLE_VORBIS "Enable OGG support.")
configure_file(
${PROJECT_SOURCE_DIR}/config.h.in
${PROJECT_BINARY_DIR}/config.h)
add_definitions(-DHAVE_CONFIG_H)
include_directories(${PROJECT_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
find_package(PkgConfig REQUIRED)
set(SRCS
src/main.c)
add_executable(svar ${SRCS})
target_link_libraries(svar m)
find_package(Threads REQUIRED)
target_link_libraries(svar Threads::Threads)
if(ENABLE_PORTAUDIO)
pkg_check_modules(PortAudio REQUIRED IMPORTED_TARGET portaudio-2.0)
target_link_libraries(svar PkgConfig::PortAudio)
else()
pkg_check_modules(ALSA REQUIRED IMPORTED_TARGET alsa)
target_link_libraries(svar PkgConfig::ALSA)
endif()
if(ENABLE_SNDFILE)
pkg_check_modules(SNDFile REQUIRED IMPORTED_TARGET sndfile)
target_sources(svar PRIVATE src/writer_sndfile.c)
target_link_libraries(svar PkgConfig::SNDFile)
endif()
if(ENABLE_MP3LAME)
find_package(Mp3Lame REQUIRED)
target_sources(svar PRIVATE src/writer_mp3lame.c)
target_link_libraries(svar Mp3Lame::Mp3Lame)
endif()
if(ENABLE_VORBIS)
pkg_check_modules(VorbisOgg REQUIRED IMPORTED_TARGET vorbis vorbisenc ogg)
target_sources(svar PRIVATE src/writer_vorbis.c)
target_link_libraries(svar PkgConfig::VorbisOgg)
endif()
install(TARGETS svar
RUNTIME DESTINATION bin)