Skip to content

Commit db245a4

Browse files
committed
Enable standard library assertions in CI
1 parent dfd14db commit db245a4

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- platform: { name: Windows MinGW, os: windows-2022 }
6464
config: { name: Static Standard Libraries, flags: -GNinja -DSFML_USE_MESA3D=TRUE -DCMAKE_CXX_COMPILER=g++ -DSFML_USE_STATIC_STD_LIBS=TRUE }
6565
- platform: { name: Windows MinGW, os: windows-2022 }
66-
config: { name: Static with PCH (GCC), flags: -GNinja -DSFML_USE_MESA3D=TRUE -DCMAKE_CXX_COMPILER=g++ -DBUILD_SHARED_LIBS=FALSE -DSFML_ENABLE_PCH=1 }
66+
config: { name: Static with PCH (GCC), flags: -GNinja -DSFML_USE_MESA3D=TRUE -DCMAKE_CXX_COMPILER=g++ -DBUILD_SHARED_LIBS=FALSE -DSFML_ENABLE_PCH=1 -DSFML_ENABLE_STDLIB_ASSERTIONS=FALSE } # disabling stdlib assertions due to false positive
6767
- platform: { name: macOS, os: macos-12 }
6868
config: { name: Frameworks, flags: -GNinja -DSFML_BUILD_FRAMEWORKS=TRUE -DBUILD_SHARED_LIBS=TRUE }
6969
- platform: { name: macOS , os: macos-12 }

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ if(SFML_ENABLE_SANITIZERS)
204204
string(APPEND CMAKE_CXX_FLAGS " -fno-omit-frame-pointer -fno-sanitize-recover=all -fsanitize=undefined")
205205
endif()
206206

207+
option(SFML_ENABLE_STDLIB_ASSERTIONS "Enable standard library assertions" OFF)
208+
if(SFML_ENABLE_STDLIB_ASSERTIONS)
209+
# intentionally using `add_definitions` here to propagate defines to subdirectories
210+
add_definitions(-D_GLIBCXX_ASSERTIONS=1) # see https://gcc.gnu.org/wiki/LibstdcxxDebugMode
211+
add_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE) # see https://libcxx.llvm.org/Hardening.html
212+
endif()
213+
207214
# set the output directory for SFML DLLs and executables
208215
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
209216

CMakePresets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
1111
"SFML_BUILD_EXAMPLES": "ON",
1212
"SFML_BUILD_TEST_SUITE": "ON",
13+
"SFML_ENABLE_STDLIB_ASSERTIONS": "ON",
1314
"SFML_WARNINGS_AS_ERRORS": "ON"
1415
}
1516
}

0 commit comments

Comments
 (0)