From 61cdd170fd029ca77eedf273ede945f6e5f080ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Tue, 22 Nov 2016 10:10:52 +0100 Subject: [PATCH 1/3] cmake: List spdlog's content in IDEs This is a usual CMake way of ensuring that IDEs have a way of showing all source files which comprise this header-only library. It works in the Qt Creator, for example. --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4055eac5..fa1d45a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,3 +78,6 @@ install( NAMESPACE "${namespace}" DESTINATION "${config_install_dir}" ) + +file(GLOB_RECURSE spdlog_include_SRCS "${HEADER_BASE}/*.h") +add_custom_target(spdlog_headers_for_ide SOURCES ${spdlog_include_SRCS}) From 1c31800210e3126c565db1f104e95ad6dfe35a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Tue, 22 Nov 2016 10:20:13 +0100 Subject: [PATCH 2/3] cmake: Use a standard option for controlling the tests As per the docs [1], there's a standard variable for this purpose. This introduces a behavior change, the tests are now being built by default. [1] https://cmake.org/cmake/help/v3.0/module/CTest.html --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa1d45a7..215872ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.1) project(spdlog VERSION 1.0.0) +include(CTest) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -12,7 +13,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) add_library(spdlog INTERFACE) option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF) -option(SPDLOG_BUILD_TESTS "Build tests" OFF) target_include_directories( spdlog @@ -28,7 +28,7 @@ if(SPDLOG_BUILD_EXAMPLES) add_subdirectory(example) endif() -if(SPDLOG_BUILD_TESTS) +if(BUILD_TESTING) add_subdirectory(tests) endif() From f058d3aa7447402128437b11a2f87e08f19e62d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Tue, 22 Nov 2016 10:31:01 +0100 Subject: [PATCH 3/3] cmake: use -Wall on GCC and Clang These checks come from [1]. The `MATCHES` operator is used for clang because of Apple's special string. [1] http://stackoverflow.com/questions/10046114/in-cmake-how-can-i-test-if-the-compiler-is-clang/10055571#10055571 --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 215872ef..3976befc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,10 @@ include(CTest) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}") +endif() + add_library(spdlog INTERFACE) option(SPDLOG_BUILD_EXAMPLES "Build examples" OFF)