Move debug compiler flags into CMake module.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
cada434f2b
commit
6b5a6c4b85
|
@ -11,6 +11,8 @@ project(remwharead
|
||||||
DESCRIPTION "Saves URIs of things you want to remember in a database."
|
DESCRIPTION "Saves URIs of things you want to remember in a database."
|
||||||
LANGUAGES CXX)
|
LANGUAGES CXX)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# All custom build switches.
|
# All custom build switches.
|
||||||
|
@ -26,57 +28,7 @@ set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
set(DEBUG_CXXFLAGS "")
|
include(debug_flags)
|
||||||
# GCC >= 5.0 or Clang >= 5.0 is assumed.
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
list(APPEND DEBUG_CXXFLAGS
|
|
||||||
"-Wall"
|
|
||||||
"-Wextra"
|
|
||||||
"-Wpedantic"
|
|
||||||
"-Wuninitialized"
|
|
||||||
"-Wshadow"
|
|
||||||
"-Wnon-virtual-dtor"
|
|
||||||
"-Wconversion"
|
|
||||||
"-Wsign-conversion"
|
|
||||||
"-Wold-style-cast"
|
|
||||||
"-Wzero-as-null-pointer-constant"
|
|
||||||
# "-Wmissing-declarations"
|
|
||||||
"-Wcast-align"
|
|
||||||
"-Wunused"
|
|
||||||
"-Woverloaded-virtual"
|
|
||||||
"-Wdouble-promotion"
|
|
||||||
"-Wformat=2"
|
|
||||||
"-ftrapv"
|
|
||||||
"-fsanitize=undefined"
|
|
||||||
"-g"
|
|
||||||
"-Og"
|
|
||||||
"-fno-omit-frame-pointer")
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
||||||
list(APPEND DEBUG_CXXFLAGS
|
|
||||||
"-Wlogical-op"
|
|
||||||
"-Wuseless-cast")
|
|
||||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6")
|
|
||||||
list(APPEND DEBUG_CXXFLAGS
|
|
||||||
"-Wmisleading-indentation"
|
|
||||||
"-Wduplicated-cond"
|
|
||||||
"-Wnull-dereference")
|
|
||||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7")
|
|
||||||
list(APPEND DEBUG_CXXFLAGS
|
|
||||||
"-Wduplicated-branches")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(DEBUG_LDFLAGS
|
|
||||||
"-fsanitize=undefined")
|
|
||||||
add_compile_options("$<$<CONFIG:Debug>:${DEBUG_CXXFLAGS}>")
|
|
||||||
# add_link_options was introduced in version 3.13.
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS 3.13)
|
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${DEBUG_LDFLAGS}")
|
|
||||||
else()
|
|
||||||
add_link_options("$<$<CONFIG:Debug>:${DEBUG_LDFLAGS}>")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_subdirectory(src/lib)
|
add_subdirectory(src/lib)
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
# Set compiler flags for Debug builds.
|
||||||
|
# Only has an effect on GCC/Clang >= 5.0.
|
||||||
|
|
||||||
|
set(DEBUG_CXXFLAGS "")
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
|
||||||
|
AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5")
|
||||||
|
list(APPEND DEBUG_CXXFLAGS
|
||||||
|
"-Wall"
|
||||||
|
"-Wextra"
|
||||||
|
"-Wpedantic"
|
||||||
|
"-Wuninitialized"
|
||||||
|
"-Wshadow"
|
||||||
|
"-Wnon-virtual-dtor"
|
||||||
|
"-Wconversion"
|
||||||
|
"-Wsign-conversion"
|
||||||
|
"-Wold-style-cast"
|
||||||
|
"-Wzero-as-null-pointer-constant"
|
||||||
|
# "-Wmissing-declarations"
|
||||||
|
"-Wcast-align"
|
||||||
|
"-Wunused"
|
||||||
|
"-Woverloaded-virtual"
|
||||||
|
"-Wdouble-promotion"
|
||||||
|
"-Wformat=2"
|
||||||
|
"-ftrapv"
|
||||||
|
"-fsanitize=undefined"
|
||||||
|
"-g"
|
||||||
|
"-Og"
|
||||||
|
"-fno-omit-frame-pointer")
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
|
list(APPEND DEBUG_CXXFLAGS
|
||||||
|
"-Wlogical-op"
|
||||||
|
"-Wuseless-cast")
|
||||||
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6")
|
||||||
|
list(APPEND DEBUG_CXXFLAGS
|
||||||
|
"-Wmisleading-indentation"
|
||||||
|
"-Wduplicated-cond"
|
||||||
|
"-Wnull-dereference")
|
||||||
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7")
|
||||||
|
list(APPEND DEBUG_CXXFLAGS
|
||||||
|
"-Wduplicated-branches")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
add_compile_options("$<$<CONFIG:Debug>:${DEBUG_CXXFLAGS}>")
|
||||||
|
|
||||||
|
set(DEBUG_LDFLAGS
|
||||||
|
"-fsanitize=undefined")
|
||||||
|
# add_link_options was introduced in version 3.13.
|
||||||
|
if(${CMAKE_VERSION} VERSION_LESS 3.13)
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${DEBUG_LDFLAGS}")
|
||||||
|
else()
|
||||||
|
add_link_options("$<$<CONFIG:Debug>:${DEBUG_LDFLAGS}>")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(STATUS
|
||||||
|
"No additional compiler flags were set, "
|
||||||
|
"because your compiler was not anticipated.")
|
||||||
|
endif()
|
Loading…
Reference in New Issue