Skip to content

Commit

Permalink
build: build test and examples in their own directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-LZW committed May 2, 2023
1 parent ea6267b commit a64cb84
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ Testing
/.vs
/build

*.swp

compile_commands.json
22 changes: 10 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ include(CheckIncludeFileCXX)

set(CMAKE_CXX_STANDARD 23)

option(AUDIO_ENABLE_TESTS "Enable tests." ON)
option(AUDIO_ENABLE_EXAMPLES "Build examples." ON)

if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX")
else ()
Expand Down Expand Up @@ -70,18 +73,13 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/audioConfig.cmake ${CMAKE_CURRENT_BINA
)

###################################################
# Test and Examples, move into their own directory
# Test and Examples
###################################################

include_directories(include)

add_executable(white_noise examples/white_noise.cpp)
add_executable(print_devices examples/print_devices.cpp)
add_executable(sine_wave examples/sine_wave.cpp)
add_executable(melody examples/melody.cpp)
add_executable(level_meter examples/level_meter.cpp)
if (AUDIO_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()

add_executable(test
test/test_main.cpp
test/audio_buffer_test.cpp
test/audio_device_test.cpp)
if (AUDIO_ENABLE_TESTS)
add_subdirectory(test)
endif()
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']}
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
foreach(example white_noise print_devices sine_wave melody level_meter)
add_executable("${example}" "${example}.cpp")
target_link_libraries("${example}" PRIVATE std::audio)
endforeach()
6 changes: 6 additions & 0 deletions include/experimental/__p1386/audio_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
#include <chrono>
#include <optional>

#if __cpp_lib_mdspan >= 202207L
#include <mdspan>
#else
#include <experimental/mdspan>
#endif

#include "experimental/__p1386/config.h"

_LIBSTDAUDIO_NAMESPACE_BEGIN
Expand Down
5 changes: 5 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_executable(test
test_main.cpp
audio_buffer_test.cpp
audio_device_test.cpp)
target_link_libraries(test PRIVATE std::audio)

0 comments on commit a64cb84

Please sign in to comment.