mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 08:25:43 +08:00
Treat wall warnings as errors if SPDLOG_BUILD_WARNINGS is ON
This commit is contained in:
parent
3eeced78b5
commit
3315bad009
@ -2,21 +2,21 @@
|
|||||||
function(spdlog_extract_version)
|
function(spdlog_extract_version)
|
||||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/include/spdlog/version.h" file_contents)
|
file(READ "${CMAKE_CURRENT_LIST_DIR}/include/spdlog/version.h" file_contents)
|
||||||
string(REGEX MATCH "SPDLOG_VER_MAJOR ([0-9]+)" _ "${file_contents}")
|
string(REGEX MATCH "SPDLOG_VER_MAJOR ([0-9]+)" _ "${file_contents}")
|
||||||
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
|
if (NOT CMAKE_MATCH_COUNT EQUAL 1)
|
||||||
message(FATAL_ERROR "Could not extract major version number from spdlog/version.h")
|
message(FATAL_ERROR "Could not extract major version number from spdlog/version.h")
|
||||||
endif()
|
endif ()
|
||||||
set(ver_major ${CMAKE_MATCH_1})
|
set(ver_major ${CMAKE_MATCH_1})
|
||||||
|
|
||||||
string(REGEX MATCH "SPDLOG_VER_MINOR ([0-9]+)" _ "${file_contents}")
|
string(REGEX MATCH "SPDLOG_VER_MINOR ([0-9]+)" _ "${file_contents}")
|
||||||
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
|
if (NOT CMAKE_MATCH_COUNT EQUAL 1)
|
||||||
message(FATAL_ERROR "Could not extract minor version number from spdlog/version.h")
|
message(FATAL_ERROR "Could not extract minor version number from spdlog/version.h")
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
set(ver_minor ${CMAKE_MATCH_1})
|
set(ver_minor ${CMAKE_MATCH_1})
|
||||||
string(REGEX MATCH "SPDLOG_VER_PATCH ([0-9]+)" _ "${file_contents}")
|
string(REGEX MATCH "SPDLOG_VER_PATCH ([0-9]+)" _ "${file_contents}")
|
||||||
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
|
if (NOT CMAKE_MATCH_COUNT EQUAL 1)
|
||||||
message(FATAL_ERROR "Could not extract patch version number from spdlog/version.h")
|
message(FATAL_ERROR "Could not extract patch version number from spdlog/version.h")
|
||||||
endif()
|
endif ()
|
||||||
set(ver_patch ${CMAKE_MATCH_1})
|
set(ver_patch ${CMAKE_MATCH_1})
|
||||||
|
|
||||||
set(SPDLOG_VERSION_MAJOR ${ver_major} PARENT_SCOPE)
|
set(SPDLOG_VERSION_MAJOR ${ver_major} PARENT_SCOPE)
|
||||||
@ -27,31 +27,32 @@ endfunction()
|
|||||||
|
|
||||||
# Turn on warnings on the given target
|
# Turn on warnings on the given target
|
||||||
function(spdlog_enable_warnings target_name)
|
function(spdlog_enable_warnings target_name)
|
||||||
if(SPDLOG_BUILD_WARNINGS)
|
if (SPDLOG_BUILD_WARNINGS)
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
list(APPEND MSVC_OPTIONS "/W3")
|
list(APPEND MSVC_OPTIONS "/W3")
|
||||||
if(MSVC_VERSION GREATER 1900) # Allow non fatal security warnings for msvc 2015
|
if (MSVC_VERSION GREATER 1900) # Allow non fatal security warnings for msvc 2015
|
||||||
list(APPEND MSVC_OPTIONS "/WX")
|
list(APPEND MSVC_OPTIONS "/WX")
|
||||||
endif()
|
endif ()
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
target_compile_options(
|
target_compile_options(
|
||||||
${target_name}
|
${target_name}
|
||||||
PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||||
-Wall
|
-Wall
|
||||||
-Wextra
|
-Wextra
|
||||||
-Wconversion
|
-Wconversion
|
||||||
-pedantic
|
-pedantic
|
||||||
-Wfatal-errors>
|
-Werror
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_OPTIONS}>)
|
-Wfatal-errors>
|
||||||
endif()
|
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_OPTIONS}>)
|
||||||
|
endif ()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Enable address sanitizer (gcc/clang only)
|
# Enable address sanitizer (gcc/clang only)
|
||||||
function(spdlog_enable_sanitizer target_name)
|
function(spdlog_enable_sanitizer target_name)
|
||||||
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
|
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
|
||||||
endif()
|
endif ()
|
||||||
message(STATUS "Address sanitizer enabled")
|
message(STATUS "Address sanitizer enabled")
|
||||||
target_compile_options(${target_name} PRIVATE -fsanitize=address,undefined)
|
target_compile_options(${target_name} PRIVATE -fsanitize=address,undefined)
|
||||||
target_compile_options(${target_name} PRIVATE -fno-sanitize=signed-integer-overflow)
|
target_compile_options(${target_name} PRIVATE -fno-sanitize=signed-integer-overflow)
|
||||||
|
Loading…
Reference in New Issue
Block a user