diff --git a/CMakeLists.txt b/CMakeLists.txt index e5de902f..9ca5cb4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,4 +44,8 @@ endif() if (SFIZZ_BENCHMARKS) add_subdirectory(benchmarks) +endif() + +if (SFIZZ_TESTS) +add_subdirectory(tests) endif() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3a26fda2..fe37b34b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -63,16 +63,18 @@ add_library(sfizz::sfizz ALIAS sfizz) # Shared library and installation target -add_library(sfizz_shared SHARED sfizz/sfizz_wrapper.cpp) -set_target_properties(sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h) -target_link_libraries(sfizz_shared sfizz::sfizz) -configure_file(${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) -if(UNIX) - include(GNUInstallDirs) - install(TARGETS sfizz_shared - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - install(FILES - ${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) -endif() \ No newline at end of file +if (SFIZZ_SHARED) + add_library(sfizz_shared SHARED sfizz/sfizz_wrapper.cpp) + set_target_properties(sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h) + target_link_libraries(sfizz_shared sfizz::sfizz) + configure_file(${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) + if(UNIX) + include(GNUInstallDirs) + install(TARGETS sfizz_shared + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(FILES + ${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) + endif() +endif(SFIZZ_SHARED) \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 00000000..ab383ecd --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,41 @@ +############################### +# Test application + +project(sfizz) + +set(SFIZZ_TEST_SOURCES + RegionT.cpp + RegexT.cpp + HelpersT.cpp + HelpersT.cpp + AudioBufferT.cpp + RangeT.cpp + OpcodeT.cpp + BufferT.cpp + SIMDHelpersT.cpp + FilesT.cpp + OnePoleFilterT.cpp + RegionActivationT.cpp + RegionCrossfadesT.cpp + ADSREnvelopeT.cpp + LinearEnvelopeT.cpp + MainT.cpp + RegionTriggersT.cpp +) + +find_package(ZLIB REQUIRED) +add_library(cnpy cnpy/cnpy.cpp) +target_link_libraries(cnpy PRIVATE ZLIB::ZLIB) +target_include_directories(cnpy PUBLIC cnpy) + +add_executable(sfizz_tests ${SFIZZ_TEST_SOURCES}) +target_link_libraries(sfizz_tests PRIVATE sfizz::sfizz) + +# Per OS properties +if(UNIX) + target_link_libraries(sfizz_tests PRIVATE atomic) +endif(UNIX) +target_link_libraries(sfizz_tests PRIVATE absl::strings absl::str_format absl::flat_hash_map sndfile cnpy absl::span absl::algorithm) +target_include_directories(sfizz_tests SYSTEM PRIVATE sources) + +file(COPY "." DESTINATION ${CMAKE_BINARY_DIR}/tests) \ No newline at end of file diff --git a/tests/FilesT.cpp b/tests/FilesT.cpp index 06a65b63..3dd5a1cd 100644 --- a/tests/FilesT.cpp +++ b/tests/FilesT.cpp @@ -23,7 +23,7 @@ #include "Synth.h" #include "catch2/catch.hpp" -#include "../sfizz/ghc/fs_std.hpp" +#include "ghc/fs_std.hpp" using namespace Catch::literals; TEST_CASE("[Files] Single region (regions_one.sfz)") diff --git a/tests/OnePoleFilterT.cpp b/tests/OnePoleFilterT.cpp index 6df0b485..378271db 100644 --- a/tests/OnePoleFilterT.cpp +++ b/tests/OnePoleFilterT.cpp @@ -24,7 +24,7 @@ #include "OnePoleFilter.h" #include "catch2/catch.hpp" #include "cnpy.h" -#include "../sfizz/ghc/fs_std.hpp" +#include "ghc/fs_std.hpp" #include #include #include