From e0d5ab6a275279ec4335400c404828dbc6b232a1 Mon Sep 17 00:00:00 2001 From: Jessica James Date: Tue, 21 Jan 2020 18:25:41 -0600 Subject: [PATCH] Various bits of cleanup --- CMakeLists.txt | 3 +++ build/CMakeLists.txt | 4 ++-- build/Clang/CMakeLists.txt | 13 +++++++++++++ src/include/object.hpp | 2 +- src/include/parser.hpp | 2 ++ src/test/CMakeLists.txt | 2 -- src/test/thread_pool.cpp | 2 +- 7 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 build/Clang/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ade743..a5ac526 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,11 @@ cmake_minimum_required(VERSION 3.8) project(jessilib) +# Set common constants set(CMAKE_CXX_STANDARD 17) +set(JESSILIB_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) +# Include compiler-specific build configuration include(build/CMakeLists.txt) # Setup source files diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index a840d28..8c86006 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -1,6 +1,6 @@ # Include any compiler-specifc settings -if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/build/${CMAKE_CXX_COMPILER_ID}") - include("${CMAKE_CURRENT_SOURCE_DIR}/build/${CMAKE_CXX_COMPILER_ID}/CMakeLists.txt") +if (EXISTS "${JESSILIB_ROOT}/build/${CMAKE_CXX_COMPILER_ID}") + include("${JESSILIB_ROOT}/build/${CMAKE_CXX_COMPILER_ID}/CMakeLists.txt") else() message(STATUS "No compiler-specific settings set; CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}") endif() diff --git a/build/Clang/CMakeLists.txt b/build/Clang/CMakeLists.txt new file mode 100644 index 0000000..57bf94e --- /dev/null +++ b/build/Clang/CMakeLists.txt @@ -0,0 +1,13 @@ +# Clang-specific compiler settings + +# Enable all/extra warnings +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") + +# Treat all warnings as errors +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + +# Enable address sanitizer on debug +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address") + +# Enable std::filesystem +set(JESSILIB_ADDITOINAL_LIBS "stdc++fs") diff --git a/src/include/object.hpp b/src/include/object.hpp index 3992d03..70453be 100644 --- a/src/include/object.hpp +++ b/src/include/object.hpp @@ -402,7 +402,7 @@ public: } size_t hash() const { - return std::visit([this](auto&& value) -> size_t { + return std::visit([](auto&& value) -> size_t { using T = typename std::decay::type; if constexpr (std::is_same::value) { diff --git a/src/include/parser.hpp b/src/include/parser.hpp index a32b8ca..87dbd84 100644 --- a/src/include/parser.hpp +++ b/src/include/parser.hpp @@ -26,6 +26,8 @@ namespace jessilib { class parser { public: + virtual ~parser() = default; + /** Interface methods */ /** diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index a5c8cb1..4b83aee 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.8) - # Setup source files set(SOURCE_FILES timer.cpp thread_pool.cpp util.cpp object.cpp parser.cpp config.cpp parsers/json.cpp unicode.cpp) diff --git a/src/test/thread_pool.cpp b/src/test/thread_pool.cpp index ceede8a..36ae8fd 100644 --- a/src/test/thread_pool.cpp +++ b/src/test/thread_pool.cpp @@ -57,7 +57,7 @@ TEST(ThreadPoolTest, push) { thread_pool pool; repeat (total_iterations) { - pool.push([&iterations, &pool]() { + pool.push([&iterations]() { ++iterations; }); }