-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
106 lines (94 loc) · 4.72 KB
/
CMakeLists.txt
File metadata and controls
106 lines (94 loc) · 4.72 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
95
96
97
98
99
100
101
102
103
104
105
106
# MIT Licence
# MicrophoneLoopback
# Copyright © 2022 Erwan Saclier de la Bâtie (BlueDragon28)
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cmake_minimum_required(VERSION 3.16.0)
cmake_policy(SET CMP0091 NEW)
project(MicrophoneLoopback LANGUAGES CXX)
# Set C++11 has default
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(include/)
if (WIN32)
# Check if portaudio library is located in dependencies folder
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/portaudio/include/portaudio.h")
message (FATAL_ERROR "Failed to find PortAudio include file.")
endif ()
if (CMAKE_CL_64)
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/portaudio/lib/portaudio_static_x64.lib")
message (FATAL_ERROR "Failed to find PortAudio .lib file.")
endif ()
else ()
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/portaudio/lib/portaudio_static.lib")
message (FATAL_ERROR "Failed to find PortAudio .lib file.")
endif ()
endif ()
include_directories("${CMAKE_SOURCE_DIR}/dependencies/portaudio/include")
# Check if cxxopts library is located in dependencies folder.
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/cxxopts/include/cxxopts.hpp")
message(FATAL_ERROR "Failed to find cxxopts include file.")
endif()
include_directories("${CMAKE_SOURCE_DIR}/dependencies/cxxopts/include")
if ((NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/ini_parser/include/ini_parser.h") OR
(NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/ini_parser/src/ini_parser.cpp"))
message(FATAL_ERROR "Failed to find the ini_parser library files")
endif()
include_directories("${CMAKE_SOURCE_DIR}/dependencies/ini_parser/include/")
elseif(UNIX AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(PULSE REQUIRED libpulse-simple)
pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)
pkg_check_modules(INI_PARSER REQUIRED ini_parser_static)
include_directories(${INI_PARSER_INCLUDE_DIRS})
link_directories("${INI_PARSER_LIBRARY_DIRS}")
endif()
if (WIN32)
add_executable(MicrophoneLoopback
"src/main.cpp"
"include/LoopbackStream.h"
"include/StreamApplication.h"
"include/CMDParser.h"
"src/LoopbackStream.cpp"
"src/StreamApplication.cpp"
"src/CMDParser.cpp"
"${CMAKE_SOURCE_DIR}/dependencies/ini_parser/src/ini_parser.cpp")
else()
add_executable(MicrophoneLoopback
"src/main.cpp"
"include/LoopbackStream.h"
"include/StreamApplication.h"
"include/CMDParser.h"
"src/LoopbackStream.cpp"
"src/StreamApplication.cpp"
"src/CMDParser.cpp")
endif()
if(WIN32)
if (CMAKE_CL_64)
target_link_libraries(MicrophoneLoopback "${CMAKE_SOURCE_DIR}/dependencies/portaudio/lib/portaudio_static_x64.lib")
else()
target_link_libraries(MicrophoneLoopback "${CMAKE_SOURCE_DIR}/dependencies/portaudio/lib/portaudio_static.lib")
endif()
set_property(TARGET MicrophoneLoopback PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
elseif(UNIX AND NOT APPLE)
if (${PORTAUDIO_STATIC_BUILD})
target_link_libraries(MicrophoneLoopback
${CMAKE_SOURCE_DIR}/dependencies/portaudio/lib/libportaudio.a
${PULSE_LIBRARIES}
${INI_PARSER_LIBRARIES}
-ljack
-lasound
-lm
-lpthread)
message("-- Compiling MicorphoneLoopback statically with user portaudio.")
else()
target_link_libraries(MicrophoneLoopback ${PULSE_LIBRARIES} ${PORTAUDIO_LIBRARIES} ${INI_PARSER_LIBRARIES} -lpthread)
endif()
endif()
set_target_properties(MicrophoneLoopback PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)