From eb3e1748776c23ae8943df928abe2e9b90996cde Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 12 Jul 2020 15:06:20 +0200 Subject: [PATCH] Reset to before c++20 features that required clang. --- .drone.yml | 11 ++++++++--- CMakeLists.txt | 31 ++++++++++++++----------------- conanfile.py | 5 ----- src/String/StringViewLiteral.hpp | 8 ++++---- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/.drone.yml b/.drone.yml index c6b18af..fe7a14f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -18,7 +18,7 @@ steps: CC: /usr/bin/clang CXX: /usr/bin/clang++ commands: - - cmake -DCMAKE_BUILD_TYPE=Release . -B build-release + - cmake -DCMAKE_BUILD_TYPE=Release . -B build-release -DSTATICC=ON - cmake --build build-release --target all -- -j 4 - build-release/ArbutilsTests -s --durations yes --use-colour yes - valgrind --tool=memcheck --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no --error-exitcode=1 build-release/ArbutilsTests @@ -30,9 +30,14 @@ steps: - name: test-release-windows image: deukhoofd/windowsbuilder commands: - - cmake -DCMAKE_BUILD_TYPE=Release . -B build-release-windows -D CMAKE_C_COMPILER=/home/wclang/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-clang -D CMAKE_CXX_COMPILER=/home/wclang/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-clang++ -DWINDOWS=ON -DSTATICC=ON + - update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix + - update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix + - update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix + - update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix + - cmake -DCMAKE_BUILD_TYPE=Release . -B build-release-windows -D CMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc -D CMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DWINDOWS=ON -DSTATICC=ON - cmake --build build-release-windows --target all -- -j 4 - export WINEARCH=win64 + - cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /drone/src/build-release-windows/ - wine build-release-windows/ArbutilsTests.exe -s - name: conan-deploy image: deukhoofd/linux64builder @@ -45,7 +50,7 @@ steps: - rm -rf build-debug - rm -rf build-release-windows - cmake -DCMAKE_BUILD_TYPE=Release . -B build-conan -D CMAKE_C_COMPILER=/usr/bin/clang -D CMAKE_CXX_COMPILER=clang++ -DWINDOWS=0 - - conan export-pkg . $DRONE_COMMIT@epsilon/$DRONE_BRANCH --build-folder build-conan -s compiler='clang' -s compiler.version=10 -s compiler.libcxx='libstdc++11' + - conan export-pkg . $DRONE_COMMIT@epsilon/$DRONE_BRANCH --build-folder build-conan -s compiler='clang' -s compiler.version=8 -s compiler.libcxx='libstdc++11' - conan alias Arbutils/latest@epsilon/$DRONE_BRANCH Arbutils/$DRONE_COMMIT@epsilon/$DRONE_BRANCH - conan remote add epsilon-public https://packages.p-epsilon.com/ - conan user -p -r=epsilon-public diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c863c5..2473c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,39 +3,36 @@ project(Arbutils) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") set(CMAKE_CXX_STANDARD 20) -find_package(Threads) if (WINDOWS) ADD_DEFINITIONS(-D WINDOWS=1) - set(CMAKE_POSITION_INDEPENDENT_CODE 0) endif (WINDOWS) file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.hpp" "CInterface/*.cpp") set(LIBTYPE STATIC) if (SHARED) - set(LIBTYPE SHARED) -endif (SHARED) + set(LIBTYPE SHARED src/StringView.hpp src/String/BasicStringView.hpp src/String/StringViewLiteral.hpp CInterface/Random.cpp) +endif(SHARED) add_library(Arbutils ${LIBTYPE} ${SRC_FILES}) + +file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") +if (NOT DEFINED CONAN_EXPORTED) + add_executable(ArbutilsTests ${TEST_FILES} extern/catch.hpp) + target_link_libraries(ArbutilsTests Arbutils) +endif() + if (WINDOWS) MESSAGE(WARNING, "Using Windows Build.") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -pthread") - set_target_properties(Arbutils PROPERTIES SUFFIX ".dll") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -Wl,-allow-multiple-definition") endif (WINDOWS) if (STATICC) target_link_libraries(Arbutils -static-libgcc -static-libstdc++) -endif (STATICC) - -if (NOT DEFINED CONAN_EXPORTED) - file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") - add_executable(ArbutilsTests ${TEST_FILES} extern/catch.hpp) - if (WINDOWS) - set_target_properties(ArbutilsTests PROPERTIES SUFFIX ".exe") - endif () - target_link_libraries(ArbutilsTests Arbutils) -endif () - + if (NOT DEFINED CONAN_EXPORTED) + target_link_libraries(ArbutilsTests -static-libgcc -static-libstdc++) + endif() +endif(STATICC) if (NOT DEFINED CONAN_EXPORTED) target_compile_definitions(ArbutilsTests PRIVATE TESTS_BUILD) diff --git a/conanfile.py b/conanfile.py index ecaf7a2..97acb03 100644 --- a/conanfile.py +++ b/conanfile.py @@ -29,12 +29,7 @@ class ArbutilsConan(ConanFile): self.output.info("Linking C libraries statically.") cmake.definitions["STATICC"] = "On" - if self.settings.compiler == "wclang": - cmake.definitions["CMAKE_C_COMPILER"] = "/home/wclang/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-clang" - cmake.definitions["CMAKE_CXX_COMPILER"] = "/home/wclang/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-clang++" - cmake.configure() - self.output.info("running `cmake " + cmake.command_line + "`") cmake.build() def package(self): diff --git a/src/String/StringViewLiteral.hpp b/src/String/StringViewLiteral.hpp index d8f9cd1..7031504 100644 --- a/src/String/StringViewLiteral.hpp +++ b/src/String/StringViewLiteral.hpp @@ -11,9 +11,9 @@ namespace ArbUt { const char* _str; public: - consteval StringViewLiteral(const char* str, size_t size) noexcept + constexpr StringViewLiteral(const char* str, size_t size) noexcept : BasicStringView(size, Hash(str)), _str(str) {} - consteval StringViewLiteral(const char* str) noexcept : StringViewLiteral(str, CalcLength(str)){}; + constexpr StringViewLiteral(const char* str) noexcept : StringViewLiteral(str, CalcLength(str)){}; [[nodiscard]] inline constexpr const char* c_str() const noexcept { return _str; } constexpr std::string_view std_str() const noexcept { return std::string_view(_str, _length); } constexpr std::size_t operator()(StringViewLiteral const& s) const noexcept { return s.GetHash(); } @@ -36,10 +36,10 @@ namespace std { }; } -inline consteval ArbUt::StringViewLiteral operator"" _const_nocase(const char* c, size_t l) { +inline constexpr ArbUt::StringViewLiteral operator"" _const_nocase(const char* c, size_t l) { return ArbUt::StringViewLiteral(c, l); } -inline consteval ArbUt::StringViewLiteral operator"" _cnc(const char* c, size_t l) { +inline constexpr ArbUt::StringViewLiteral operator"" _cnc(const char* c, size_t l) { return ArbUt::StringViewLiteral(c, l); }