mirror of
https://github.com/boostorg/url.git
synced 2026-01-19 04:42:15 +00:00
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.
This commit is contained in:
committed by
Alan de Freitas
parent
8b566c1935
commit
fcb5f58b0e
@@ -35,6 +35,7 @@ option(BOOST_URL_BUILD_TESTS "Build boost::url tests even if BUILD_TESTING is OF
|
||||
option(BOOST_URL_BUILD_FUZZERS "Build boost::url fuzzers" OFF)
|
||||
option(BOOST_URL_BUILD_EXAMPLES "Build boost::url examples" ${BOOST_URL_IS_ROOT})
|
||||
option(BOOST_URL_DISABLE_THREADS "Disable threads" OFF)
|
||||
option(BOOST_URL_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
|
||||
set(BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE STRING "Boost source dir to use when running CMake from this directory")
|
||||
|
||||
#-------------------------------------------------
|
||||
@@ -138,6 +139,7 @@ function(boost_url_setup_properties target)
|
||||
target_link_libraries(${target} PUBLIC ${BOOST_URL_DEPENDENCIES})
|
||||
target_compile_definitions(${target} PUBLIC $<IF:$<BOOL:${BUILD_SHARED_LIBS}>,BOOST_URL_DYN_LINK=1,BOOST_URL_STATIC_LINK=1>)
|
||||
target_compile_definitions(${target} PRIVATE BOOST_URL_SOURCE)
|
||||
target_compile_options(${target} PUBLIC $<$<CXX_COMPILER_ID:MSVC>:/EHsc>)
|
||||
endfunction()
|
||||
add_library(boost_url ${BOOST_URL_HEADERS} ${BOOST_URL_SOURCES})
|
||||
add_library(Boost::url ALIAS boost_url)
|
||||
|
||||
@@ -14,13 +14,7 @@ project boost/url
|
||||
<define>BOOST_URL_SOURCE
|
||||
<toolset>msvc-14.0:<build>no
|
||||
# Warnings in dependencies
|
||||
<toolset>gcc-7:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-8:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-9:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-10:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-11:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-12:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-13:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc,<target-os>windows:<cxxflags>"-Wno-error=array-bounds"
|
||||
: common-requirements
|
||||
<link>shared:<define>BOOST_URL_DYN_LINK=1
|
||||
|
||||
@@ -15,36 +15,38 @@ if(NOT TARGET tests)
|
||||
endif()
|
||||
|
||||
# Replicate error flags from Jamfile
|
||||
set(BOOST_URL_TEST_FLAGS " ")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7)
|
||||
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable -Wno-maybe-uninitialized")
|
||||
else()
|
||||
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable")
|
||||
endif()
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
||||
set(BOOST_URL_TEST_FLAGS "-Wall -Werror")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13)
|
||||
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable")
|
||||
else()
|
||||
if (BOOST_URL_WARNINGS_AS_ERRORS)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7)
|
||||
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable -Wno-maybe-uninitialized")
|
||||
else()
|
||||
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable")
|
||||
endif()
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
||||
set(BOOST_URL_TEST_FLAGS "-Wall -Werror")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13)
|
||||
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable")
|
||||
else()
|
||||
set(BOOST_URL_TEST_FLAGS "-Wall -Werror")
|
||||
endif()
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
|
||||
set(BOOST_URL_TEST_FLAGS "/W4 /WX")
|
||||
endif()
|
||||
|
||||
# Print test configuration if running in CI
|
||||
# This is useful for debugging CI failures related to warnings which might be false positives
|
||||
if (DEFINED ENV{CI})
|
||||
message(STATUS "Boost.URL Tests - Compiler ID: ${CMAKE_CXX_COMPILER_ID} / ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT)
|
||||
message(STATUS "Boost.URL Tests - Compiler Frontend: ${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}")
|
||||
endif()
|
||||
message(STATUS "Boost.URL Tests - Platform: ${CMAKE_SYSTEM_NAME} / ${CMAKE_SYSTEM_VERSION}")
|
||||
message(STATUS "Boost.URL Tests - C++ standard: ${CMAKE_CXX_STANDARD}")
|
||||
message(STATUS "Boost.URL Tests - Test error flags: ${BOOST_URL_TEST_FLAGS}")
|
||||
endif()
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
|
||||
set(BOOST_URL_TEST_FLAGS "/W4 /WX")
|
||||
endif()
|
||||
|
||||
# Print test configuration if running in CI
|
||||
# This is useful for debugging CI failures related to warnings which might be false positives
|
||||
if (DEFINED ENV{CI})
|
||||
message(STATUS "Boost.URL Tests - Compiler ID: ${CMAKE_CXX_COMPILER_ID} / ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT)
|
||||
message(STATUS "Boost.URL Tests - Compiler Frontend: ${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}")
|
||||
endif()
|
||||
message(STATUS "Boost.URL Tests - Platform: ${CMAKE_SYSTEM_NAME} / ${CMAKE_SYSTEM_VERSION}")
|
||||
message(STATUS "Boost.URL Tests - C++ standard: ${CMAKE_CXX_STANDARD}")
|
||||
message(STATUS "Boost.URL Tests - Test error flags: ${BOOST_URL_TEST_FLAGS}")
|
||||
endif()
|
||||
|
||||
set(SUITE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../extra/test_main.cpp
|
||||
|
||||
25
test/Jamfile
25
test/Jamfile
@@ -14,28 +14,16 @@ project
|
||||
|
||||
: requirements
|
||||
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
# Extra errors that are disabled by default
|
||||
<toolset>msvc:<cxxflags>"/we4265"
|
||||
|
||||
# Warnings in dependencies
|
||||
<toolset>gcc:<cxxflags>"-Wno-unused-but-set-variable"
|
||||
<toolset>gcc-7:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-8:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-9:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-10:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-11:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-12:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>gcc-13:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>clang-4:<cxxflags>"-Wno-unused-but-set-variable"
|
||||
<toolset>clang-5:<cxxflags>"-Wno-unused-but-set-variable"
|
||||
<toolset>clang-6:<cxxflags>"-Wno-unused-but-set-variable"
|
||||
<toolset>clang-13:<cxxflags>"-Wno-unused-but-set-variable"
|
||||
<toolset>clang-14:<cxxflags>"-Wno-unused-but-set-variable"
|
||||
<toolset>clang-15:<cxxflags>"-Wno-unused-but-set-variable"
|
||||
<toolset>gcc:<cxxflags>"-Wno-maybe-uninitialized"
|
||||
<toolset>clang:<cxxflags>"-Wno-unused-but-set-variable"
|
||||
<toolset>gcc,<target-os>windows:<cxxflags>"-Wno-error=array-bounds"
|
||||
# different typeinfos confuse ubsan
|
||||
|
||||
# Different typeinfos confuse ubsan
|
||||
<undefined-sanitizer>norecover:<link>static
|
||||
<undefined-sanitizer>norecover:<visibility>global
|
||||
;
|
||||
@@ -47,9 +35,6 @@ project
|
||||
|
||||
: requirements
|
||||
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
<toolset>gcc:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies
|
||||
<toolset>clang:<cxxflags>"-Wno-unknown-warning-option"
|
||||
<toolset>clang-13:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies
|
||||
|
||||
@@ -16,7 +16,10 @@ target_compile_definitions(boost_url_small_limits PUBLIC BOOST_URL_MAX_SIZE=16 B
|
||||
add_executable(boost_url_limits limits.cpp Jamfile ${SUITE_FILES})
|
||||
target_include_directories(boost_url_limits PRIVATE ../../include ../../extra ../../..)
|
||||
target_link_libraries(boost_url_limits PRIVATE boost_url_small_limits)
|
||||
set_source_files_properties(limits.cpp PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
|
||||
if (DEFINED BOOST_URL_TEST_FLAGS AND NOT BOOST_URL_TEST_FLAGS STREQUAL "")
|
||||
set_source_files_properties(limits.cpp PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
|
||||
set_target_properties(boost_url_small_limits PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
|
||||
endif ()
|
||||
|
||||
# Folders
|
||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES limits.cpp Jamfile)
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
|
||||
# Files
|
||||
file(GLOB_RECURSE BOOST_URL_TESTS_FILES CONFIGURE_DEPENDS *.cpp *.hpp)
|
||||
set_source_files_properties(${BOOST_URL_TESTS_FILES} PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
|
||||
if (DEFINED BOOST_URL_TEST_FLAGS AND NOT BOOST_URL_TEST_FLAGS STREQUAL "")
|
||||
set_source_files_properties(${BOOST_URL_TESTS_FILES} PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
|
||||
set_target_properties(boost_url PROPERTIES COMPILE_FLAGS ${BOOST_URL_TEST_FLAGS})
|
||||
endif()
|
||||
set_property(SOURCE doc_grammar.cpp PROPERTY COMPILE_FLAGS "")
|
||||
set_property(SOURCE doc_3_urls.cpp PROPERTY COMPILE_FLAGS "")
|
||||
list(APPEND BOOST_URL_TESTS_FILES CMakeLists.txt Jamfile)
|
||||
|
||||
Reference in New Issue
Block a user