From 52308936caa320f55d647d7ee6d4638aa9cdd209 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 10 Sep 2019 20:29:55 +0100 Subject: [PATCH 1/3] Fix build with gcc-7 on linux (WIP) Not very clean, needs improvement --- CMakeLists.txt | 2 ++ clients/sfzprint.cpp | 4 ++-- sfizz/FilePool.h | 4 ++-- sfizz/Parser.h | 4 ++-- sfizz/filesystem.h | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 sfizz/filesystem.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ae9e4769..d42c1a5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID) add_compile_options(-stdlib=libc++) # Presumably need the above for linking too, maybe other options missing as well add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release +else() + add_link_options(-lstdc++fs) endif() if (UNIX) diff --git a/clients/sfzprint.cpp b/clients/sfzprint.cpp index 3e07f383..41e87b06 100644 --- a/clients/sfzprint.cpp +++ b/clients/sfzprint.cpp @@ -23,8 +23,8 @@ #include "Parser.h" #include "StringViewHelpers.h" +#include "filesystem.h" #include -#include #include #include #include @@ -92,4 +92,4 @@ int main(int argc, char** argv) std::cout << '\t' << define.first << '=' << define.second << '\n'; // spdlog::info("Done!"); return 0; -} \ No newline at end of file +} diff --git a/sfizz/FilePool.h b/sfizz/FilePool.h index a6295fd2..3dbd9458 100644 --- a/sfizz/FilePool.h +++ b/sfizz/FilePool.h @@ -27,9 +27,9 @@ #include "LeakDetector.h" #include "AudioBuffer.h" #include "Voice.h" +#include "filesystem.h" #include "readerwriterqueue.h" #include -#include #include #include #include @@ -75,4 +75,4 @@ private: absl::flat_hash_map>> preloadedData; LEAK_DETECTOR(FilePool); }; -} \ No newline at end of file +} diff --git a/sfizz/Parser.h b/sfizz/Parser.h index 56375c47..05c832d5 100644 --- a/sfizz/Parser.h +++ b/sfizz/Parser.h @@ -23,7 +23,7 @@ #pragma once #include "Opcode.h" -#include +#include "filesystem.h" #include #include #include @@ -59,4 +59,4 @@ private: void readSfzFile(const std::filesystem::path& fileName, std::vector& lines) noexcept; }; -} // namespace sfz \ No newline at end of file +} // namespace sfz diff --git a/sfizz/filesystem.h b/sfizz/filesystem.h new file mode 100644 index 00000000..d5f8dd81 --- /dev/null +++ b/sfizz/filesystem.h @@ -0,0 +1,33 @@ +// Copyright (c) 2019, Paul Ferrand +// All rights reserved. + +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: + +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. + +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#pragma once + +#ifdef __linux__ +#include +namespace std { + namespace filesystem = std::experimental::filesystem; +} +#else +#include +#endif From 484b204401b1a4ae7d0aedc156a2b8466844f8c5 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 10 Sep 2019 20:30:19 +0100 Subject: [PATCH 2/3] Update gitignore --- .gitignore | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1836d360..65edb0cb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,14 @@ build-release build-debug .vscode perf.data -perf.data.old \ No newline at end of file +perf.data.old + +Makefile +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake +compile_commands.json +*.a + +clients/sfizz_jack +clients/sfzprint From 7f26b53cb3878065e83f424001be8b2ded3c5306 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 10 Sep 2019 21:13:09 +0100 Subject: [PATCH 3/3] Make filesystem.h more broad --- sfizz/filesystem.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sfizz/filesystem.h b/sfizz/filesystem.h index d5f8dd81..3ad22a65 100644 --- a/sfizz/filesystem.h +++ b/sfizz/filesystem.h @@ -23,11 +23,13 @@ #pragma once -#ifdef __linux__ +#if defined(__cpp_lib_filesystem) || (defined(__has_include) && __has_include()) +#include +#elif defined(__cpp_lib_experimental_filesystem) || (defined(__has_include) && __has_include()) #include namespace std { namespace filesystem = std::experimental::filesystem; } #else -#include +#error no filesystem support #endif