Skip to content

Commit 125beec

Browse files
author
MarkusB
committed
Add compile-check target and adjust Clang warning flags
Introduce a compile-check target to ensure the umbrella header compiles successfully in isolation. Remove the `-Wno-character-conversion` flag in Clang MaxWarn configuration and update the MaxSan preset to include relevant profiles.
1 parent aa7b3e7 commit 125beec

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

CMakePresets.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676
{
7777
"name": "MaxWarnClang",
7878
"hidden": true,
79-
"description": "Duplicates mb_ul_set_target_warnings Clang compile options via global CMAKE_CXX_FLAGS so they apply project-wide; this can break builds that pull in third-party sources (e.g. FetchContent) that do not compile cleanly under -Werror and the rest. Does not pass -D_FORTIFY_SOURCE=3 here (glibc requires -O; Debug would fail with -Werror); mb_ul_set_target_warnings still sets it for Release-family configs. Adds -Wno-unused-command-line-argument so globally ignored -f flags on some platforms do not fail the build. Adds -Wno-poison-system-directories so -Werror does not fail when Clang rejects host include paths (e.g. /usr/local/include) during cross-compilation. Adds -Wno-character-conversion so -Wconversion does not fail third-party code (e.g. GoogleTest gtest-printers); devenv/cmake/detail/warnings.cmake strips this flag for Apple Clang, which does not support it.",
79+
"description": "Duplicates mb_ul_set_target_warnings Clang compile options via global CMAKE_CXX_FLAGS so they apply project-wide; this can break builds that pull in third-party sources (e.g. FetchContent) that do not compile cleanly under -Werror and the rest. Does not pass -D_FORTIFY_SOURCE=3 here (glibc requires -O; Debug would fail with -Werror); mb_ul_set_target_warnings still sets it for Release-family configs. Adds -Wno-unused-command-line-argument so globally ignored -f flags on some platforms do not fail the build. Adds -Wno-poison-system-directories so -Werror does not fail when Clang rejects host include paths (e.g. /usr/local/include) during cross-compilation",
8080
"cacheVariables": {
81-
"CMAKE_CXX_FLAGS": "-D_GLIBCXX_ASSERTIONS -fexceptions -fno-builtin -fstack-clash-protection -fstack-protector-strong -U_FORTIFY_SOURCE -fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -fno-limit-debug-info -fstrict-flex-arrays=3 -Wall -Wconversion -Werror -Wextra -Wformat -Wformat=2 -Wimplicit-fallthrough -Wno-deprecated-declarations -Wpedantic -Wsign-conversion -Wdocumentation -Wmissing-prototypes -Wno-c++11-narrowing -Wno-c++20-compat -Wno-switch-default -Wno-unused-command-line-argument -Wno-poison-system-directories -Wno-character-conversion",
81+
"CMAKE_CXX_FLAGS": "-D_GLIBCXX_ASSERTIONS -fexceptions -fno-builtin -fstack-clash-protection -fstack-protector-strong -U_FORTIFY_SOURCE -fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -fno-limit-debug-info -fstrict-flex-arrays=3 -Wall -Wconversion -Werror -Wextra -Wformat -Wformat=2 -Wimplicit-fallthrough -Wno-deprecated-declarations -Wpedantic -Wsign-conversion -Wdocumentation -Wmissing-prototypes -Wno-c++11-narrowing -Wno-c++20-compat -Wno-switch-default -Wno-unused-command-line-argument -Wno-poison-system-directories",
8282
"MB_DEVENV_ALL_WARNINGS": "ON"
8383
}
8484
},
@@ -178,6 +178,7 @@
178178
"appleclang",
179179
"debug",
180180
"MaxWarnClang",
181+
"MaxSan",
181182
"base"
182183
]
183184
},

devenv

src/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ if(NOT MB_CPP_LIB_TEMPLATE_HEADER_ONLY)
44
target_sources(mb.cpp-lib-template PRIVATE ${sources})
55
endif()
66

7+
add_executable(mb.cpp-lib-template.compile-check)
8+
target_sources(mb.cpp-lib-template.compile-check PRIVATE compile-check.cpp)
9+
target_link_libraries(
10+
mb.cpp-lib-template.compile-check
11+
PRIVATE mb::cpp-lib-template
12+
)
13+
mb_devenv_set_target_defaults(mb.cpp-lib-template.compile-check)
14+
715
if(NOT MB_CPP_LIB_TEMPLATE_BUILD_TESTS)
816
return()
917
endif()

src/compile-check.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// TUs that include the umbrella header force a full compile of the header-only surface.
2+
#include "mb/cpp-lib-template/cpp-lib-template.hpp"
3+
#include <cstdint>
4+
5+
int32_t main() {
6+
return 0;
7+
}

0 commit comments

Comments
 (0)