CMake changes...

This commit is contained in:
paulfd 2019-08-30 15:28:30 +02:00
parent 3098ca3b69
commit 1df16518c1
60 changed files with 180 additions and 144 deletions

View file

@ -13,8 +13,6 @@ endif()
if (UNIX)
add_compile_options(-Wall)
add_compile_options(-Wextra)
# add_compile_options(-fno-exceptions)
# add_compile_options(-fno-rtti)
add_compile_options(-ffast-math)
add_compile_options(-fno-omit-frame-pointer)
endif()
@ -30,21 +28,27 @@ endif()
message("Cmake flags: ${CMAKE_CXX_FLAGS}")
# Check SIMD
set(USE_SIMD OFF)
include(CheckIncludeFiles)
CHECK_INCLUDE_FILES(x86intrin.h HAVE_X86INTRIN_H)
CHECK_INCLUDE_FILES(intrin.h HAVE_INTRIN_H)
CHECK_INCLUDE_FILES(arm_neon.h HAVE_ARM_NEON_H)
# Export the compile_commands.json file
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
# Build options and includes
set(BUILD_TESTING OFF CACHE BOOL "Disable Abseil's tests")
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable Google Benchmark tests")
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Disable Google Benchmark install")
add_subdirectory(external/abseil-cpp EXCLUDE_FROM_ALL)
add_subdirectory(external/Catch2 EXCLUDE_FROM_ALL)
add_subdirectory(external/benchmark EXCLUDE_FROM_ALL)
add_subdirectory(external/cnpy EXCLUDE_FROM_ALL)
# Download libsndfile
if (WIN32)
@ -64,120 +68,16 @@ endif()
add_library(readerwriterqueue INTERFACE)
target_include_directories(readerwriterqueue INTERFACE "external/readerwriterqueue")
# Export the compile_commands.json file
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory(sfizz)
add_subdirectory(clients)
set(COMMON_SOURCES
sources/Opcode.cpp
sources/Synth.cpp
sources/FilePool.cpp
sources/Region.cpp
sources/Voice.cpp
sources/ScopedFTZ.cpp
sources/SfzHelpers.cpp
sources/FloatEnvelopes.cpp
sources/Parser.cpp
)
# Tests
add_subdirectory(external/Catch2 EXCLUDE_FROM_ALL)
add_subdirectory(external/cnpy EXCLUDE_FROM_ALL)
add_subdirectory(tests)
set(SSE_SOURCES
)
if (HAVE_X86INTRIN_H AND UNIX)
add_compile_options(-DHAVE_X86INTRIN_H)
add_compile_options(-DUSE_SIMD)
set(COMMON_SOURCES ${COMMON_SOURCES} sources/SIMDSSE.cpp)
elseif (HAVE_INTRIN_H AND WIN32)
add_compile_options(/DHAVE_INTRIN_H)
add_compile_options(/DUSE_SIMD)
set(COMMON_SOURCES ${COMMON_SOURCES} sources/SIMDSSE.cpp)
elseif (HAVE_ARM_NEON_H AND UNIX)
add_compile_options(-DUSE_SIMD)
add_compile_options(-DHAVE_ARM_NEON_H)
set(COMMON_SOURCES ${COMMON_SOURCES} sources/SIMDDummy.cpp)
else()
set(COMMON_SOURCES ${COMMON_SOURCES} sources/SIMDDummy.cpp)
endif()
set(TEST_SOURCES
tests/RegexT.cpp
tests/HelpersT.cpp
tests/RegionT.cpp
tests/RangeT.cpp
tests/OpcodeT.cpp
tests/BufferT.cpp
tests/StereoBufferT.cpp
tests/SIMDHelpersT.cpp
tests/FilesT.cpp
tests/OnePoleFilterT.cpp
tests/RegionActivationT.cpp
tests/RegionCrossfadesT.cpp
tests/ADSREnvelopeT.cpp
tests/LinearEnvelopeT.cpp
tests/MainT.cpp
tests/RegionTriggersT.cpp
)
###############################
add_executable(sfzprint sources/ParserMain.cpp sources/Opcode.cpp sources/Parser.cpp)
# Per OS properties
if(UNIX)
target_link_libraries(sfzprint stdc++fs)
endif(UNIX)
target_link_libraries(sfzprint absl::strings absl::flags_parse)
###############################
# Basic command line program
add_executable(sfizz sources/Main.cpp ${COMMON_SOURCES})
# Per OS properties
if(UNIX)
target_compile_options(sfizz PRIVATE -fno-rtti -fno-exceptions)
target_link_libraries(sfizz stdc++fs)
endif(UNIX)
target_link_libraries(sfizz jack absl::strings sndfile absl::flat_hash_map readerwriterqueue absl::flags_parse)
###############################
# Test application
add_executable(sfizz_tests ${TEST_SOURCES} ${COMMON_SOURCES})
# Per OS properties
if(UNIX)
target_link_libraries(sfizz_tests stdc++fs)
endif(UNIX)
target_link_libraries(sfizz_tests Catch2::Catch2 absl::strings absl::str_format absl::flat_hash_map sndfile readerwriterqueue cnpy-static absl::span absl::algorithm)
target_include_directories(sfizz_tests SYSTEM PRIVATE sources)
file(COPY "tests" DESTINATION ${CMAKE_BINARY_DIR})
###############################
add_executable(bm_opf_high_vs_low benchmarks/BM_OPF_high_vs_low.cpp)
target_link_libraries(bm_opf_high_vs_low benchmark absl::span)
add_executable(bm_write benchmarks/BM_writeInterleaved.cpp sources/SIMDSSE.cpp)
target_link_libraries(bm_write benchmark absl::span)
add_executable(bm_read benchmarks/BM_readInterleaved.cpp sources/SIMDSSE.cpp)
target_link_libraries(bm_read benchmark absl::span)
add_executable(bm_fill benchmarks/BM_fill.cpp sources/SIMDSSE.cpp)
target_link_libraries(bm_fill benchmark absl::span)
add_executable(bm_mathfuns benchmarks/BM_mathfuns.cpp sources/SIMDSSE.cpp)
target_link_libraries(bm_mathfuns benchmark absl::span)
add_executable(bm_gain benchmarks/BM_gain.cpp sources/SIMDSSE.cpp)
target_link_libraries(bm_gain benchmark absl::span)
add_executable(bm_looping benchmarks/BM_looping.cpp sources/SIMDSSE.cpp)
target_link_libraries(bm_looping benchmark absl::span absl::algorithm)
add_executable(bm_saturating benchmarks/BM_saturating.cpp sources/SIMDSSE.cpp)
target_link_libraries(bm_saturating benchmark absl::span absl::algorithm)
add_executable(bm_ramp benchmarks/BM_ramp.cpp sources/SIMDSSE.cpp)
target_link_libraries(bm_ramp benchmark absl::span absl::algorithm)
add_executable(bm_ADSR benchmarks/BM_ADSR.cpp sources/SIMDSSE.cpp)
target_link_libraries(bm_ADSR benchmark absl::span absl::algorithm)
add_executable(bm_add benchmarks/BM_add.cpp sources/SIMDSSE.cpp)
target_link_libraries(bm_add benchmark absl::span absl::algorithm)
# Benchmarks
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable Google Benchmark tests")
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Disable Google Benchmark install")
add_subdirectory(external/benchmark EXCLUDE_FROM_ALL)
add_subdirectory(benchmarks)

34
benchmarks/CMakeLists.txt Normal file
View file

@ -0,0 +1,34 @@
project(sfizz)
add_executable(bm_opf_high_vs_low BM_OPF_high_vs_low.cpp)
target_link_libraries(bm_opf_high_vs_low benchmark absl::span)
add_executable(bm_write BM_writeInterleaved.cpp ${SFIZZ_SIMD_SOURCES})
target_link_libraries(bm_write benchmark absl::span)
add_executable(bm_read BM_readInterleaved.cpp ${SFIZZ_SIMD_SOURCES})
target_link_libraries(bm_read benchmark absl::span)
add_executable(bm_fill BM_fill.cpp ${SFIZZ_SIMD_SOURCES})
target_link_libraries(bm_fill benchmark absl::span)
add_executable(bm_mathfuns BM_mathfuns.cpp ${SFIZZ_SIMD_SOURCES})
target_link_libraries(bm_mathfuns benchmark absl::span)
add_executable(bm_gain BM_gain.cpp ${SFIZZ_SIMD_SOURCES})
target_link_libraries(bm_gain benchmark absl::span)
add_executable(bm_looping BM_looping.cpp ${SFIZZ_SIMD_SOURCES})
target_link_libraries(bm_looping benchmark absl::span absl::algorithm)
add_executable(bm_saturating BM_saturating.cpp ${SFIZZ_SIMD_SOURCES})
target_link_libraries(bm_saturating benchmark absl::span absl::algorithm)
add_executable(bm_ramp BM_ramp.cpp ${SFIZZ_SIMD_SOURCES})
target_link_libraries(bm_ramp benchmark absl::span absl::algorithm)
add_executable(bm_ADSR BM_ADSR.cpp ${SFIZZ_SIMD_SOURCES})
target_link_libraries(bm_ADSR benchmark absl::span absl::algorithm)
add_executable(bm_add BM_add.cpp ${SFIZZ_SIMD_SOURCES})
target_link_libraries(bm_add benchmark absl::span absl::algorithm)

10
clients/CMakeLists.txt Normal file
View file

@ -0,0 +1,10 @@
project(sfizz)
###############################
add_executable(sfzprint sfzprint.cpp)
target_link_libraries(sfzprint sfizz::parser absl::flags_parse)
###############################
# Basic command line program
add_executable(sfizz_jack jack_client.cpp)
target_link_libraries(sfizz_jack sfizz::sfizz jack absl::flags_parse)

View file

@ -22,6 +22,7 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Parser.h"
#include "StringViewHelpers.h"
#include <iostream>
#include <filesystem>
#include <string_view>

57
sfizz/CMakeLists.txt Normal file
View file

@ -0,0 +1,57 @@
project(sfizz)
set(SFIZZ_SOURCES
Synth.cpp
FilePool.cpp
Region.cpp
Voice.cpp
ScopedFTZ.cpp
SfzHelpers.cpp
FloatEnvelopes.cpp
)
# Check SIMD
include(CheckIncludeFiles)
CHECK_INCLUDE_FILES(x86intrin.h HAVE_X86INTRIN_H)
CHECK_INCLUDE_FILES(intrin.h HAVE_INTRIN_H)
CHECK_INCLUDE_FILES(arm_neon.h HAVE_ARM_NEON_H)
# SIMD checks
if (HAVE_X86INTRIN_H AND UNIX)
add_compile_options(-DHAVE_X86INTRIN_H)
set(SFIZZ_SIMD_SOURCES SIMDSSE.cpp)
elseif (HAVE_INTRIN_H AND WIN32)
add_compile_options(/DHAVE_INTRIN_H)
set(SFIZZ_SIMD_SOURCES SIMDSSE.cpp)
elseif (HAVE_ARM_NEON_H AND UNIX)
add_compile_options(-DHAVE_ARM_NEON_H)
add_compile_options(-mfpu=neon-fp-armv8)
add_compile_options(-march=native)
add_compile_options(-mtune=cortex-a53)
add_compile_options(-funsafe-math-optimizations)
set(SFIZZ_SIMD_SOURCES SIMDNEON.cpp)
else()
set(SFIZZ_SIMD_SOURCES SIMDDummy.cpp)
endif()
set(SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES})
add_library(sfizz_parser STATIC)
target_sources(sfizz_parser PUBLIC Parser.cpp Opcode.cpp)
target_include_directories(sfizz_parser PUBLIC .)
if(UNIX)
target_link_libraries(sfizz_parser PUBLIC stdc++fs)
endif(UNIX)
target_link_libraries(sfizz_parser PRIVATE absl::strings)
add_library(sfizz STATIC ${SFIZZ_SOURCES})
target_link_libraries(sfizz PRIVATE sfizz_parser)
target_include_directories(sfizz PUBLIC .)
if(UNIX)
target_link_libraries(sfizz PUBLIC stdc++fs atomic)
target_compile_options(sfizz PRIVATE -fno-rtti -fno-exceptions)
endif(UNIX)
target_link_libraries(sfizz PUBLIC readerwriterqueue)
target_link_libraries(sfizz PRIVATE absl::strings sndfile absl::flat_hash_map)
add_library(sfizz::parser ALIAS sfizz_parser)
add_library(sfizz::sfizz ALIAS sfizz)

View file

@ -28,7 +28,7 @@ namespace sfz {
namespace config {
constexpr float defaultSampleRate { 48000 };
constexpr int defaultSamplesPerBlock { 1024 };
constexpr int preloadSize { 8192 * 4 };
constexpr int preloadSize { 8192 * 2 };
constexpr int numChannels { 2 };
constexpr int numVoices { 64 };
constexpr int numLoadingThreads { 4 };

View file

@ -52,7 +52,6 @@ public:
void setSamplesPerBlock(int samplesPerBlock) noexcept;
void setSampleRate(float sampleRate) noexcept;
void renderBlock(StereoSpan<float> buffer) noexcept;
void noteOn(int delay, int channel, int noteNumber, uint8_t velocity) noexcept;
void noteOff(int delay, int channel, int noteNumber, uint8_t velocity) noexcept;
void cc(int delay, int channel, int ccNumber, uint8_t ccValue) noexcept;

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/ADSREnvelope.h"
#include "ADSREnvelope.h"
#include "catch2/catch.hpp"
#include <absl/algorithm/container.h>
#include <absl/types/span.h>

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/Buffer.h"
#include "Buffer.h"
#include "catch2/catch.hpp"
#include <algorithm>
using namespace Catch::literals;

35
tests/CMakeLists.txt Normal file
View file

@ -0,0 +1,35 @@
###############################
# Test application
project(sfizz)
set(SFIZZ_TEST_SOURCES
RegexT.cpp
HelpersT.cpp
RegionT.cpp
RangeT.cpp
OpcodeT.cpp
BufferT.cpp
StereoBufferT.cpp
SIMDHelpersT.cpp
FilesT.cpp
OnePoleFilterT.cpp
RegionActivationT.cpp
RegionCrossfadesT.cpp
ADSREnvelopeT.cpp
LinearEnvelopeT.cpp
MainT.cpp
RegionTriggersT.cpp
)
add_executable(sfizz_tests ${SFIZZ_TEST_SOURCES})
target_link_libraries(sfizz_tests PRIVATE sfizz)
# Per OS properties
if(UNIX)
target_link_libraries(sfizz_tests PRIVATE stdc++fs atomic)
endif(UNIX)
target_link_libraries(sfizz_tests PRIVATE Catch2::Catch2 absl::strings absl::str_format absl::flat_hash_map sndfile readerwriterqueue cnpy-static absl::span absl::algorithm)
target_include_directories(sfizz_tests SYSTEM PRIVATE sources)
file(COPY "." DESTINATION ${CMAKE_BINARY_DIR}/tests)

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/Synth.h"
#include "Synth.h"
#include "catch2/catch.hpp"
#include <filesystem>
using namespace Catch::literals;

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/StringViewHelpers.h"
#include "StringViewHelpers.h"
#include "catch2/catch.hpp"
#include <string_view>
using namespace Catch::literals;

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/LinearEnvelope.h"
#include "LinearEnvelope.h"
#include "catch2/catch.hpp"
#include <absl/algorithm/container.h>
#include <absl/types/span.h>

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/OnePoleFilter.h"
#include "OnePoleFilter.h"
#include "catch2/catch.hpp"
#include "cnpy.h"
#include <absl/types/span.h>

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/Region.h"
#include "Region.h"
#include "catch2/catch.hpp"
using namespace Catch::literals;

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/Parser.h"
#include "Parser.h"
#include "catch2/catch.hpp"
using namespace Catch::literals;

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/Region.h"
#include "Region.h"
#include "catch2/catch.hpp"
using namespace Catch::literals;

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/Region.h"
#include "Region.h"
#include "catch2/catch.hpp"
#include <SfzHelpers.h>
using namespace Catch::literals;

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/Region.h"
#include "Region.h"
#include "catch2/catch.hpp"
using namespace Catch::literals;

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/Region.h"
#include "Region.h"
#include "catch2/catch.hpp"
using namespace Catch::literals;

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/SIMDHelpers.h"
#include "SIMDHelpers.h"
#include "catch2/catch.hpp"
#include <absl/algorithm/container.h>
#include <absl/types/span.h>

View file

@ -21,7 +21,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../sources/StereoBuffer.h"
#include "StereoBuffer.h"
#include "catch2/catch.hpp"
#include <algorithm>
using namespace Catch::literals;