2
0
mirror of https://github.com/boostorg/url.git synced 2026-01-19 04:42:15 +00:00

build: test flags depend on frontend

The logic for test flags in cmake also needs to check CMAKE_CXX_COMPILER_FRONTEND_VARIANT. In particular, if the compiler is clang but the frontend is MSVC, we need to add flags as if it were MSVC rather than GCC-like flags.

This commit also updates existing flags to account for new compiler versions.
This commit is contained in:
alandefreitas
2023-12-21 19:23:06 -03:00
committed by Alan de Freitas
parent e35ae73ba5
commit e34828ecd0
3 changed files with 53 additions and 19 deletions

View File

@@ -13,7 +13,14 @@ project boost/url
$(c11-requires)
<define>BOOST_URL_SOURCE
<toolset>msvc-14.0:<build>no
<toolset>gcc-7:<cxxflags>"-Wno-maybe-uninitialized" # variant2
# 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,<target-os>windows:<cxxflags>"-Wno-error=array-bounds"
: common-requirements
<link>shared:<define>BOOST_URL_DYN_LINK=1

View File

@@ -22,18 +22,36 @@ endif()
# Replicate error flags from Jamfile
set(BOOST_URL_TEST_FLAGS " ")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION_MAJOR EQUAL 7)
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable -Wno-maybe-uninitialized")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION_MAJOR EQUAL 4)
set(BOOST_URL_TEST_FLAGS "-Wall -Werror -Wno-unused-but-set-variable")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
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 STREQUAL "MSVC")
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()
set(SUITE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/../extra/test_main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../extra/test_suite.hpp)

View File

@@ -17,17 +17,26 @@ project
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>msvc:<cxxflags>"/we4265" # Extra errors that are disabled by default
<toolset>gcc:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies
<toolset>gcc-7:<cxxflags>"-Wno-maybe-uninitialized" # Warnings in dependencies
<toolset>clang-4:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies
<toolset>clang-5:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies
<toolset>clang-6:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies
<toolset>clang-13:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies
<toolset>clang-14:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies
<toolset>clang-15:<cxxflags>"-Wno-unused-but-set-variable" # Warnings in dependencies
# 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,<target-os>windows:<cxxflags>"-Wno-error=array-bounds"
<undefined-sanitizer>norecover:<link>static # different typeinfos confuse ubsan
# different typeinfos confuse ubsan
<undefined-sanitizer>norecover:<link>static
<undefined-sanitizer>norecover:<visibility>global
;