diff --git a/.travis.yml b/.travis.yml index 3067c322..80c30db9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -93,7 +93,7 @@ install: -DCMAKE_CXX_STANDARD=$CPP \ -DSPDLOG_BUILD_EXAMPLES=ON \ -DSPDLOG_SANITIZE_ADDRESS=$ASAN - - VERBOSE=1 make -j2 + - make VERBOSE=1-j2 script: - if [ "$ASAN" != "On" ]; then CTEST_FLAGS="-DExperimentalMemCheck"; fi diff --git a/CMakeLists.txt b/CMakeLists.txt index a5cceb70..5166d39f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,17 @@ include(CTest) include(CMakeDependentOption) include(GNUInstallDirs) +#--------------------------------------------------------------------------------------- +# set default build to release +#--------------------------------------------------------------------------------------- +if (NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE) +endif() + +message("Build type: " ${CMAKE_BUILD_TYPE}) + + + #--------------------------------------------------------------------------------------- # compiler config #--------------------------------------------------------------------------------------- @@ -17,9 +28,13 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "-Wall -O3 ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}") endif() + +#--------------------------------------------------------------------------------------- +# address sanitizers check +#--------------------------------------------------------------------------------------- include(cmake/sanitizers.cmake) #--------------------------------------------------------------------------------------- @@ -28,7 +43,9 @@ include(cmake/sanitizers.cmake) add_library(spdlog INTERFACE) add_library(spdlog::spdlog ALIAS spdlog) -option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF) +option(SPDLOG_BUILD_EXAMPLES "Build examples" ON) +option(SPDLOG_BUILD_BENCH "Build benchmarks" ON) + cmake_dependent_option(SPDLOG_BUILD_TESTING "Build spdlog tests" ON "BUILD_TESTING" OFF @@ -51,6 +68,10 @@ if(SPDLOG_BUILD_TESTING) add_subdirectory(tests) endif() +if(SPDLOG_BUILD_BENCH) + add_subdirectory(bench) +endif() + #--------------------------------------------------------------------------------------- # Install/export targets and files #--------------------------------------------------------------------------------------- diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt new file mode 100644 index 00000000..9f596d27 --- /dev/null +++ b/bench/CMakeLists.txt @@ -0,0 +1,44 @@ +# *************************************************************************/ +# * Copyright (c) 2015 Ruslan Baratov. */ +# * */ +# * Permission is hereby granted, free of charge, to any person obtaining */ +# * a copy of this software and associated documentation files (the */ +# * "Software"), to deal in the Software without restriction, including */ +# * without limitation the rights to use, copy, modify, merge, publish, */ +# * distribute, sublicense, and/or sell copies of the Software, and to */ +# * permit persons to whom the Software is furnished to do so, subject to */ +# * the following conditions: */ +# * */ +# * The above copyright notice and this permission notice shall be */ +# * included in all copies or substantial portions of the Software. */ +# * */ +# * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +# * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +# * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +# * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +# * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +# * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +# * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +# *************************************************************************/ + +cmake_minimum_required(VERSION 3.1) +project(SpdlogBench CXX) + +if(NOT TARGET spdlog) + # Stand-alone build + find_package(spdlog CONFIG REQUIRED) +endif() + +find_package(Threads REQUIRED) + +add_executable(bench bench.cpp) +target_link_libraries(bench spdlog::spdlog Threads::Threads) + +add_executable(async_bench async_bench.cpp) +target_link_libraries(async_bench spdlog::spdlog Threads::Threads) + +add_executable(latency latency.cpp) +target_link_libraries(latency spdlog::spdlog Threads::Threads) + +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs") + diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 11dc2d98..69eb374e 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -40,4 +40,3 @@ target_link_libraries(multisink spdlog::spdlog Threads::Threads) enable_testing() file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs") add_test(NAME example COMMAND example) -add_test(NAME multisink COMMAND multisink)