mirror of
https://github.com/TheLartians/ModernCppStarter.git
synced 2025-08-30 21:51:12 +02:00
use WarningsAsErrors by default while build
This commit is contained in:
parent
f222eb3ce1
commit
46d2235289
6 changed files with 20 additions and 8 deletions
|
@ -26,7 +26,6 @@ include(cmake/options.cmake)
|
|||
# see https://github.com/cpm-cmake/CPM.cmake for more info
|
||||
|
||||
include(cmake/CPM.cmake)
|
||||
CPMUsePackageLock(package-lock.cmake)
|
||||
|
||||
# PackageProject.cmake will be used to make our target installable
|
||||
CPMAddPackage("gh:TheLartians/PackageProject.cmake@1.4.1")
|
||||
|
@ -61,6 +60,11 @@ set_target_properties(
|
|||
CMAKE_VISIBILITY_INLINES_HIDDEN ${BUILD_SHARED_LIBS}
|
||||
)
|
||||
|
||||
option(WarningsAsErrors "Be realy pedantic!" YES)
|
||||
if(WarningsAsErrors)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/WarningsAsErrors.cmake)
|
||||
endif()
|
||||
|
||||
# being a cross-platform target, we enforce standards conformance on MSVC
|
||||
target_compile_options(Greeter PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive>)
|
||||
|
||||
|
|
|
@ -5,8 +5,7 @@ GENERATOR?=Ninja
|
|||
|
||||
STAGE_DIR?=$(CURDIR)/stage
|
||||
BUILD_TYPE?=Debug
|
||||
CMAKE_PRESET:=-G "$(GENERATOR)" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
|
||||
-DCMAKE_PREFIX_PATH=$(STAGE_DIR)
|
||||
CMAKE_PRESET:=-G "$(GENERATOR)" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -DCMAKE_PREFIX_PATH=$(STAGE_DIR)
|
||||
# Note: not needed -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
|
||||
#XXX export CXX=clang++
|
||||
|
@ -22,7 +21,7 @@ BUILD_DIR?=../build-$(PROJECT_NAME)-$(CXX)-$(BUILD_TYPE)
|
|||
test:
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) build-*
|
||||
rm -rf $(BUILD_DIR) build build-*
|
||||
|
||||
distclean: clean
|
||||
rm -rf $(STAGE_DIR)
|
||||
|
@ -30,6 +29,7 @@ distclean: clean
|
|||
# update CPM.cmake
|
||||
update:
|
||||
wget -q -O cmake/CPM.cmake https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
|
||||
wget -q -O cmake/WarningsAsErrors.cmake https://raw.githubusercontent.com/approvals/ApprovalTests.cpp/master/CMake/WarningsAsErrors.cmake
|
||||
|
||||
lock: all standalone doc
|
||||
cmake --build $(BUILD_DIR)/all --target cpm-update-package-lock
|
||||
|
|
12
cmake/WarningsAsErrors.cmake
Normal file
12
cmake/WarningsAsErrors.cmake
Normal file
|
@ -0,0 +1,12 @@
|
|||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror -Wshadow)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 10.0)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wdeprecated-copy-dtor -Wnewline-eof)
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
|
||||
endif()
|
|
@ -5,8 +5,6 @@ project(GreeterDocs)
|
|||
# ---- Dependencies ----
|
||||
|
||||
include(../cmake/CPM.cmake)
|
||||
CPMUsePackageLock(package-lock.cmake)
|
||||
|
||||
include(../cmake/options.cmake)
|
||||
|
||||
CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||
|
|
|
@ -9,7 +9,6 @@ include(../cmake/tools.cmake)
|
|||
# ---- Dependencies ----
|
||||
|
||||
include(../cmake/CPM.cmake)
|
||||
CPMUsePackageLock(package-lock.cmake)
|
||||
|
||||
option(CXXOPTS_BUILD_TESTS "Not needed!" OFF)
|
||||
CPMAddPackage("gh:jarro2783/cxxopts@2.2.0")
|
||||
|
|
|
@ -18,7 +18,6 @@ include(../cmake/tools.cmake)
|
|||
# ---- Dependencies ----
|
||||
|
||||
include(../cmake/CPM.cmake)
|
||||
CPMUsePackageLock(package-lock.cmake)
|
||||
|
||||
CPMAddPackage("gh:onqtam/doctest#2.4.5")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue