Skip to content

Commit 03cefe2

Browse files
committed
Use CheckCXXCompilerFlag module to disable flags if supported
1 parent be2c68a commit 03cefe2

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

CMakeLists.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.0)
1+
cmake_minimum_required(VERSION 3.0.2)
22
project(Jinja2Cpp VERSION 0.5.0)
33

44
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
@@ -55,10 +55,25 @@ target_link_libraries(${LIB_TARGET_NAME} PUBLIC ThirdParty::nonstd boost_variant
5555
target_include_directories(${LIB_TARGET_NAME}
5656
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
5757

58+
5859
if(NOT MSVC)
59-
target_compile_options(boost_assert INTERFACE -Wno-error=parentheses -Wno-parentheses)
60-
target_compile_options(boost_filesystem PRIVATE -Wno-error=deprecated-declarations -Wno-deprecated-declarations)
61-
target_compile_options(${LIB_TARGET_NAME} PRIVATE -Wall -Werror -Wno-error=maybe-uninitialized)
60+
# Enable -Werror and -Wall on jinja2cpp target, ignoring warning errors from thirdparty libs
61+
include(CheckCXXCompilerFlag)
62+
check_cxx_compiler_flag(-Wno-error=parentheses COMPILER_HAS_WNO_ERROR_PARENTHESES_FLAG)
63+
check_cxx_compiler_flag(-Wno-error=deprecated-declarations COMPILER_HAS_WNO_ERROR_DEPRECATED_DECLARATIONS_FLAG)
64+
check_cxx_compiler_flag(-Wno-error=maybe-uninitialized COMPILER_HAS_WNO_ERROR_MAYBE_UNINITIALIZED_FLAG)
65+
66+
if(COMPILER_HAS_WNO_ERROR_PARENTHESES_FLAG)
67+
target_compile_options(boost_assert INTERFACE -Wno-error=parentheses)
68+
endif()
69+
if(COMPILER_HAS_WNO_ERROR_DEPRECATED_DECLARATIONS_FLAG)
70+
target_compile_options(boost_filesystem PRIVATE -Wno-error=deprecated-declarations)
71+
endif()
72+
if(COMPILER_HAS_WNO_ERROR_MAYBE_UNINITIALIZED_FLAG)
73+
target_compile_options(boost_variant INTERFACE -Wno-error=maybe-uninitialized)
74+
endif()
75+
76+
target_compile_options(${LIB_TARGET_NAME} PRIVATE -Wall -Werror)
6277
endif()
6378

6479
if (JINJA2CPP_BUILD_TESTS)

0 commit comments

Comments
 (0)