Skip to content

Commit fcb5f58

Browse files
committedJan 19, 2024
test: simplify error flags
Aggregate Jamfile error flags per compiler and update CI compiler versions with warnings-as-errors based on new cpp-actions entry flags.
1 parent 8b566c1 commit fcb5f58

File tree

6 files changed

+43
-54
lines changed

6 files changed

+43
-54
lines changed
 

‎CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ option(BOOST_URL_BUILD_TESTS "Build boost::url tests even if BUILD_TESTING is OF
3535
option(BOOST_URL_BUILD_FUZZERS "Build boost::url fuzzers" OFF)
3636
option(BOOST_URL_BUILD_EXAMPLES "Build boost::url examples" ${BOOST_URL_IS_ROOT})
3737
option(BOOST_URL_DISABLE_THREADS "Disable threads" OFF)
38+
option(BOOST_URL_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
3839
set(BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE STRING "Boost source dir to use when running CMake from this directory")
3940

4041
#-------------------------------------------------
@@ -138,6 +139,7 @@ function(boost_url_setup_properties target)
138139
target_link_libraries(${target} PUBLIC ${BOOST_URL_DEPENDENCIES})
139140
target_compile_definitions(${target} PUBLIC $<IF:$<BOOL:${BUILD_SHARED_LIBS}>,BOOST_URL_DYN_LINK=1,BOOST_URL_STATIC_LINK=1>)
140141
target_compile_definitions(${target} PRIVATE BOOST_URL_SOURCE)
142+
target_compile_options(${target} PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/EHsc>)
141143
endfunction()
142144
add_library(boost_url ${BOOST_URL_HEADERS} ${BOOST_URL_SOURCES})
143145
add_library(Boost::url ALIAS boost_url)

‎build/Jamfile

+1-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ project boost/url
1414
<define>BOOST_URL_SOURCE
1515
<toolset>msvc-14.0:<build>no
1616
# Warnings in dependencies
17-
<toolset>gcc-7:<cxxflags>"-Wno-maybe-uninitialized"
18-
<toolset>gcc-8:<cxxflags>"-Wno-maybe-uninitialized"
19-
<toolset>gcc-9:<cxxflags>"-Wno-maybe-uninitialized"
20-
<toolset>gcc-10:<cxxflags>"-Wno-maybe-uninitialized"
21-
<toolset>gcc-11:<cxxflags>"-Wno-maybe-uninitialized"
22-
<toolset>gcc-12:<cxxflags>"-Wno-maybe-uninitialized"
23-
<toolset>gcc-13:<cxxflags>"-Wno-maybe-uninitialized"
17+
<toolset>gcc:<cxxflags>"-Wno-maybe-uninitialized"
2418
<toolset>gcc,<target-os>windows:<cxxflags>"-Wno-error=array-bounds"
2519
: common-requirements
2620
<link>shared:<define>BOOST_URL_DYN_LINK=1

‎test/CMakeLists.txt

+27-25
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,39 @@ if(NOT TARGET tests)
1515
endif()
1616

1717
# Replicate error flags from Jamfile
18-
set(BOOST_URL_TEST_FLAGS " ")
19-
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
20-
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7)
21-
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable -Wno-maybe-uninitialized")
22-
else()
23-
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable")
24-
endif()
25-
elseif (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
26-
set(BOOST_URL_TEST_FLAGS "-Wall -Werror")
27-
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
28-
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13)
29-
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable")
30-
else()
18+
if (BOOST_URL_WARNINGS_AS_ERRORS)
19+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
20+
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7)
21+
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable -Wno-maybe-uninitialized")
22+
else()
23+
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable")
24+
endif()
25+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
3126
set(BOOST_URL_TEST_FLAGS "-Wall -Werror")
27+
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
28+
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13)
29+
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable")
30+
else()
31+
set(BOOST_URL_TEST_FLAGS "-Wall -Werror")
32+
endif()
33+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
34+
set(BOOST_URL_TEST_FLAGS "/W4 /WX")
3235
endif()
33-
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
34-
set(BOOST_URL_TEST_FLAGS "/W4 /WX")
35-
endif()
3636

37-
# Print test configuration if running in CI
38-
# This is useful for debugging CI failures related to warnings which might be false positives
39-
if (DEFINED ENV{CI})
40-
message(STATUS "Boost.URL Tests - Compiler ID: ${CMAKE_CXX_COMPILER_ID} / ${CMAKE_CXX_COMPILER_VERSION}")
41-
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT)
42-
message(STATUS "Boost.URL Tests - Compiler Frontend: ${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}")
37+
# Print test configuration if running in CI
38+
# This is useful for debugging CI failures related to warnings which might be false positives
39+
if (DEFINED ENV{CI})
40+
message(STATUS "Boost.URL Tests - Compiler ID: ${CMAKE_CXX_COMPILER_ID} / ${CMAKE_CXX_COMPILER_VERSION}")
41+
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT)
42+
message(STATUS "Boost.URL Tests - Compiler Frontend: ${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}")
43+
endif()
44+
message(STATUS "Boost.URL Tests - Platform: ${CMAKE_SYSTEM_NAME} / ${CMAKE_SYSTEM_VERSION}")
45+
message(STATUS "Boost.URL Tests - C++ standard: ${CMAKE_CXX_STANDARD}")
46+
message(STATUS "Boost.URL Tests - Test error flags: ${BOOST_URL_TEST_FLAGS}")
4347
endif()
44-
message(STATUS "Boost.URL Tests - Platform: ${CMAKE_SYSTEM_NAME} / ${CMAKE_SYSTEM_VERSION}")
45-
message(STATUS "Boost.URL Tests - C++ standard: ${CMAKE_CXX_STANDARD}")
46-
message(STATUS "Boost.URL Tests - Test error flags: ${BOOST_URL_TEST_FLAGS}")
4748
endif()
4849

50+
4951
set(SUITE_FILES
5052
${CMAKE_CURRENT_SOURCE_DIR}/../extra/test_main.cpp
5153
${CMAKE_CURRENT_SOURCE_DIR}/../extra/test_suite.hpp)

‎test/Jamfile

+5-20
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,16 @@ project
1414

1515
: requirements
1616

17-
<toolset>msvc:<warnings-as-errors>on
18-
<toolset>gcc:<warnings-as-errors>on
19-
<toolset>clang:<warnings-as-errors>on
2017
# Extra errors that are disabled by default
2118
<toolset>msvc:<cxxflags>"/we4265"
19+
2220
# Warnings in dependencies
2321
<toolset>gcc:<cxxflags>"-Wno-unused-but-set-variable"
24-
<toolset>gcc-7:<cxxflags>"-Wno-maybe-uninitialized"
25-
<toolset>gcc-8:<cxxflags>"-Wno-maybe-uninitialized"
26-
<toolset>gcc-9:<cxxflags>"-Wno-maybe-uninitialized"
27-
<toolset>gcc-10:<cxxflags>"-Wno-maybe-uninitialized"
28-
<toolset>gcc-11:<cxxflags>"-Wno-maybe-uninitialized"
29-
<toolset>gcc-12:<cxxflags>"-Wno-maybe-uninitialized"
30-
<toolset>gcc-13:<cxxflags>"-Wno-maybe-uninitialized"
31-
<toolset>clang-4:<cxxflags>"-Wno-unused-but-set-variable"
32-
<toolset>clang-5:<cxxflags>"-Wno-unused-but-set-variable"
33-
<toolset>clang-6:<cxxflags>"-Wno-unused-but-set-variable"
34-
<toolset>clang-13:<cxxflags>"-Wno-unused-but-set-variable"
35-
<toolset>clang-14:<cxxflags>"-Wno-unused-but-set-variable"
36-
<toolset>clang-15:<cxxflags>"-Wno-unused-but-set-variable"
22+
<toolset>gcc:<cxxflags>"-Wno-maybe-uninitialized"
23+
<toolset>clang:<cxxflags>"-Wno-unused-but-set-variable"
3724
<toolset>gcc,<target-os>windows:<cxxflags>"-Wno-error=array-bounds"
38-
# different typeinfos confuse ubsan
25+
26+
# Different typeinfos confuse ubsan
3927
<undefined-sanitizer>norecover:<link>static
4028
<undefined-sanitizer>norecover:<visibility>global
4129
;
@@ -47,9 +35,6 @@ project
4735

4836
: requirements
4937

50-
<toolset>msvc:<warnings-as-errors>on
51-
<toolset>gcc:<warnings-as-errors>on
52-
<toolset>clang:<warnings-as-errors>on
5338
<toolset>gcc:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies
5439
<toolset>clang:<cxxflags>"-Wno-unknown-warning-option"
5540
<toolset>clang-13:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies

‎test/limits/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ target_compile_definitions(boost_url_small_limits PUBLIC BOOST_URL_MAX_SIZE=16 B
1616
add_executable(boost_url_limits limits.cpp Jamfile ${SUITE_FILES})
1717
target_include_directories(boost_url_limits PRIVATE ../../include ../../extra ../../..)
1818
target_link_libraries(boost_url_limits PRIVATE boost_url_small_limits)
19-
set_source_files_properties(limits.cpp PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
19+
if (DEFINED BOOST_URL_TEST_FLAGS AND NOT BOOST_URL_TEST_FLAGS STREQUAL "")
20+
set_source_files_properties(limits.cpp PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
21+
set_target_properties(boost_url_small_limits PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
22+
endif ()
2023

2124
# Folders
2225
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES limits.cpp Jamfile)

‎test/unit/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010

1111
# Files
1212
file(GLOB_RECURSE BOOST_URL_TESTS_FILES CONFIGURE_DEPENDS *.cpp *.hpp)
13-
set_source_files_properties(${BOOST_URL_TESTS_FILES} PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
13+
if (DEFINED BOOST_URL_TEST_FLAGS AND NOT BOOST_URL_TEST_FLAGS STREQUAL "")
14+
set_source_files_properties(${BOOST_URL_TESTS_FILES} PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
15+
set_target_properties(boost_url PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
16+
endif()
1417
set_property(SOURCE doc_grammar.cpp PROPERTY COMPILE_FLAGS "")
1518
set_property(SOURCE doc_3_urls.cpp PROPERTY COMPILE_FLAGS "")
1619
list(APPEND BOOST_URL_TESTS_FILES CMakeLists.txt Jamfile)

0 commit comments

Comments
 (0)