Skip to content

Commit 7beadf4

Browse files
committed
CMake: Add option "OPTIONAL_WERROR"
1 parent 5c48760 commit 7beadf4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.11)
33
project(tl-optional VERSION 1.0.0 LANGUAGES CXX)
44

55
option(OPTIONAL_ENABLE_TESTS "Enable tests." ON)
6+
option(OPTIONAL_WERROR "Turn compiler warnings into errors" OFF)
67

78
include(FetchContent)
89
FetchContent_Declare(
@@ -50,3 +51,10 @@ if(OPTIONAL_ENABLE_TESTS)
5051
set_property(TARGET tests PROPERTY CXX_STANDARD ${CXXSTD})
5152
endif()
5253

54+
if(OPTIONAL_WERROR)
55+
if(MSVC)
56+
target_compile_options(optional INTERFACE /W3 /WX)
57+
else()
58+
target_compile_options(optional INTERFACE -Wall -Wextra -pedantic -Werror)
59+
endif()
60+
endif()

0 commit comments

Comments
 (0)