Skip to content

Commit 508e5f3

Browse files
committed
Initial release v1.5.5
0 parents  commit 508e5f3

49 files changed

Lines changed: 46906 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: [ubuntu-latest, macos-latest]
14+
runs-on: ${{ matrix.os }}
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install libcurl (Ubuntu)
19+
if: matrix.os == 'ubuntu-latest'
20+
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
21+
22+
- name: Install libcurl (macOS)
23+
if: matrix.os == 'macos-latest'
24+
run: brew install curl
25+
26+
- name: Configure
27+
run: |
28+
mkdir -p build
29+
cd build
30+
cmake .. -DAUDD_BUILD_TESTS=ON -DAUDD_BUILD_EXAMPLES=ON
31+
32+
- name: Build
33+
run: cmake --build build -j
34+
35+
- name: Test
36+
run: ctest --test-dir build --output-on-failure
37+
38+
build-cxx20:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
- run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
43+
- run: |
44+
mkdir -p build && cd build
45+
cmake .. -DAUDD_CXX20=ON -DAUDD_BUILD_TESTS=ON -DAUDD_BUILD_EXAMPLES=ON
46+
- run: cmake --build build -j
47+
- run: ctest --test-dir build --output-on-failure

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
build/
2+
build-*/
3+
*.o
4+
*.obj
5+
*.a
6+
*.so
7+
*.so.*
8+
*.dylib
9+
*.dll
10+
*.exe
11+
CMakeCache.txt
12+
CMakeFiles/
13+
cmake_install.cmake
14+
Makefile
15+
compile_commands.json
16+
.cache/
17+
.vscode/
18+
.idea/
19+
.DS_Store

CMakeLists.txt

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(audd-cpp VERSION 1.5.5 LANGUAGES CXX)
3+
4+
# ---------- options ----------
5+
option(AUDD_CXX20 "Build with C++20 instead of C++17" OFF)
6+
option(AUDD_BUILD_SHARED "Build the shared (libaudd.so) target" ON)
7+
option(AUDD_BUILD_STATIC "Build the static (libaudd.a) target" ON)
8+
option(AUDD_BUILD_EXAMPLES "Build runnable examples" OFF)
9+
option(AUDD_BUILD_TESTS "Build the doctest-based test suite" OFF)
10+
option(AUDD_INSTALL "Generate install + CMake config rules" ON)
11+
12+
if(AUDD_CXX20)
13+
set(CMAKE_CXX_STANDARD 20)
14+
else()
15+
set(CMAKE_CXX_STANDARD 17)
16+
endif()
17+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
18+
set(CMAKE_CXX_EXTENSIONS OFF)
19+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
20+
21+
# ---------- dependencies ----------
22+
find_package(CURL REQUIRED)
23+
24+
# Threads (libpthread) — used by std::thread / std::async.
25+
set(THREADS_PREFER_PTHREAD_FLAG ON)
26+
find_package(Threads REQUIRED)
27+
28+
# Vendored headers.
29+
set(AUDD_VENDOR_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/vendor")
30+
31+
# ---------- public sources ----------
32+
set(AUDD_SOURCES
33+
src/client.cpp
34+
src/streams.cpp
35+
src/custom_catalog.cpp
36+
src/advanced.cpp
37+
src/callback.cpp
38+
src/longpoll.cpp
39+
src/json_parse.cpp
40+
src/http_client.cpp
41+
src/md5.cpp
42+
)
43+
44+
set(AUDD_PUBLIC_HEADERS
45+
include/audd/audd.hpp
46+
include/audd/client.hpp
47+
include/audd/recognition.hpp
48+
include/audd/streams.hpp
49+
include/audd/custom_catalog.hpp
50+
include/audd/advanced.hpp
51+
include/audd/callback.hpp
52+
include/audd/longpoll.hpp
53+
include/audd/error.hpp
54+
include/audd/source.hpp
55+
include/audd/version.hpp
56+
)
57+
58+
# Internal target with shared compile flags / includes.
59+
function(audd_apply_target tgt)
60+
target_include_directories(${tgt}
61+
PUBLIC
62+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
63+
$<BUILD_INTERFACE:${AUDD_VENDOR_INCLUDE}>
64+
$<INSTALL_INTERFACE:include>
65+
PRIVATE
66+
${CMAKE_CURRENT_SOURCE_DIR}/src
67+
)
68+
target_link_libraries(${tgt} PUBLIC CURL::libcurl Threads::Threads)
69+
target_compile_features(${tgt} PUBLIC
70+
$<IF:$<BOOL:${AUDD_CXX20}>,cxx_std_20,cxx_std_17>)
71+
if(MSVC)
72+
target_compile_options(${tgt} PRIVATE /W4)
73+
else()
74+
target_compile_options(${tgt} PRIVATE -Wall -Wextra -Wpedantic)
75+
endif()
76+
endfunction()
77+
78+
# ---------- shared library ----------
79+
if(AUDD_BUILD_SHARED)
80+
add_library(audd SHARED ${AUDD_SOURCES})
81+
set_target_properties(audd PROPERTIES
82+
OUTPUT_NAME "audd"
83+
VERSION ${PROJECT_VERSION}
84+
SOVERSION ${PROJECT_VERSION_MAJOR}
85+
EXPORT_NAME audd
86+
)
87+
audd_apply_target(audd)
88+
add_library(audd::audd ALIAS audd)
89+
endif()
90+
91+
# ---------- static library ----------
92+
if(AUDD_BUILD_STATIC)
93+
add_library(audd_static STATIC ${AUDD_SOURCES})
94+
set_target_properties(audd_static PROPERTIES
95+
OUTPUT_NAME "audd"
96+
EXPORT_NAME audd_static
97+
)
98+
audd_apply_target(audd_static)
99+
add_library(audd::audd_static ALIAS audd_static)
100+
endif()
101+
102+
# Pick a default for downstream consumers.
103+
if(AUDD_BUILD_SHARED)
104+
set(AUDD_DEFAULT_TARGET audd)
105+
elseif(AUDD_BUILD_STATIC)
106+
set(AUDD_DEFAULT_TARGET audd_static)
107+
else()
108+
message(FATAL_ERROR "audd-cpp: enable at least one of AUDD_BUILD_SHARED / AUDD_BUILD_STATIC")
109+
endif()
110+
111+
# ---------- examples ----------
112+
if(AUDD_BUILD_EXAMPLES)
113+
file(GLOB AUDD_EXAMPLE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/examples/*.cpp")
114+
foreach(src ${AUDD_EXAMPLE_SOURCES})
115+
get_filename_component(ex_name ${src} NAME_WE)
116+
add_executable(${ex_name} ${src})
117+
target_link_libraries(${ex_name} PRIVATE ${AUDD_DEFAULT_TARGET})
118+
# cpp-httplib is in vendor/cpp-httplib; expose it to examples that
119+
# use a callback-receiving HTTP server.
120+
target_include_directories(${ex_name} PRIVATE
121+
${AUDD_VENDOR_INCLUDE}/cpp-httplib)
122+
endforeach()
123+
endif()
124+
125+
# ---------- tests ----------
126+
if(AUDD_BUILD_TESTS)
127+
enable_testing()
128+
file(GLOB AUDD_TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp")
129+
add_executable(audd_tests ${AUDD_TEST_SOURCES})
130+
target_link_libraries(audd_tests PRIVATE ${AUDD_DEFAULT_TARGET})
131+
target_include_directories(audd_tests PRIVATE
132+
${AUDD_VENDOR_INCLUDE}/doctest
133+
${CMAKE_CURRENT_SOURCE_DIR}/src)
134+
add_test(NAME audd_tests COMMAND audd_tests)
135+
endif()
136+
137+
# ---------- install + CMake config ----------
138+
if(AUDD_INSTALL)
139+
include(GNUInstallDirs)
140+
include(CMakePackageConfigHelpers)
141+
142+
install(DIRECTORY include/audd DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
143+
install(DIRECTORY vendor/nlohmann DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
144+
145+
set(AUDD_INSTALL_TARGETS)
146+
if(AUDD_BUILD_SHARED)
147+
list(APPEND AUDD_INSTALL_TARGETS audd)
148+
endif()
149+
if(AUDD_BUILD_STATIC)
150+
list(APPEND AUDD_INSTALL_TARGETS audd_static)
151+
endif()
152+
153+
install(TARGETS ${AUDD_INSTALL_TARGETS}
154+
EXPORT auddTargets
155+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
156+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
157+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
158+
)
159+
160+
install(EXPORT auddTargets
161+
FILE auddTargets.cmake
162+
NAMESPACE audd::
163+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/audd
164+
)
165+
166+
set(_cfg "${CMAKE_CURRENT_BINARY_DIR}/auddConfig.cmake")
167+
file(WRITE ${_cfg} "
168+
include(CMakeFindDependencyMacro)
169+
find_dependency(CURL)
170+
find_dependency(Threads)
171+
include(\${CMAKE_CURRENT_LIST_DIR}/auddTargets.cmake)
172+
")
173+
write_basic_package_version_file(
174+
"${CMAKE_CURRENT_BINARY_DIR}/auddConfigVersion.cmake"
175+
VERSION ${PROJECT_VERSION}
176+
COMPATIBILITY SameMajorVersion)
177+
178+
install(FILES
179+
${_cfg}
180+
"${CMAKE_CURRENT_BINARY_DIR}/auddConfigVersion.cmake"
181+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/audd)
182+
endif()

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 AudD, LLC (https://audd.io)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)