Skip to content

Commit d02e128

Browse files
authored
2 parents bcce67e + e93ce16 commit d02e128

File tree

7 files changed

+83
-10
lines changed

7 files changed

+83
-10
lines changed

ben-bot/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ target_link_libraries (ben_bot PRIVATE ben_bot::libbenbot)
1818

1919
add_executable (ben_bot::ben_bot ALIAS ben_bot)
2020

21+
if (MSVC)
22+
target_compile_definitions (ben_bot PRIVATE _CRT_SECURE_NO_WARNINGS)
23+
endif ()
24+
2125
#
2226

2327
include (CheckIPOSupported)

config/cmake/All.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ include_guard (GLOBAL)
1414

1515
include ("${CMAKE_CURRENT_LIST_DIR}/Sanitizers.cmake")
1616
include ("${CMAKE_CURRENT_LIST_DIR}/Coverage.cmake")
17+
include ("${CMAKE_CURRENT_LIST_DIR}/Hardening.cmake")
1718
include ("${CMAKE_CURRENT_LIST_DIR}/Warnings.cmake")
1819

1920
# General settings

config/cmake/Hardening.cmake

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# ======================================================================================
2+
#
3+
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
4+
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
5+
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
6+
# ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
7+
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
8+
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
9+
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
10+
#
11+
# ======================================================================================
12+
13+
include_guard (GLOBAL)
14+
15+
if (MSVC)
16+
add_compile_options (/sdl /DYNAMICBASE /guard:cf)
17+
add_link_options (/NXCOMPAT /CETCOMPAT)
18+
19+
return ()
20+
endif ()
21+
22+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
23+
get_cmake_property (debug_configs DEBUG_CONFIGURATIONS)
24+
25+
if (NOT debug_configs)
26+
set (debug_configs Debug)
27+
endif ()
28+
29+
list (JOIN debug_configs "," debug_configs)
30+
31+
set (config_debug "$<CONFIG:${debug_configs}>")
32+
set (config_release "$<NOT:${config_debug}>")
33+
34+
add_compile_options ("$<${config_release}:-U_FORTIFY_SOURCE>")
35+
36+
add_compile_definitions (_GLIBCXX_ASSERTIONS "$<${config_release}:_FORTIFY_SOURCE=3>")
37+
38+
include (CheckCXXCompilerFlag)
39+
40+
check_cxx_compiler_flag (-fstack-protector-strong HAVE_fstack_protector_strong)
41+
if (HAVE_fstack_protector_strong)
42+
add_compile_options (-fstack-protector-strong)
43+
endif ()
44+
45+
check_cxx_compiler_flag (-fcf-protection HAVE_fcf_protection)
46+
if (HAVE_fcf_protection)
47+
add_compile_options (-fcf-protection)
48+
endif ()
49+
50+
if (LINUX OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
51+
check_cxx_compiler_flag (-fstack-clash-protection HAVE_fstack_clash_protection)
52+
if (HAVE_fstack_clash_protection)
53+
add_compile_options (-fstack-clash-protection)
54+
endif ()
55+
endif ()
56+
endif ()

tests/CTestCustom.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ set (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 100)
2626
# this matches forward- or back-slashes
2727
set (slash "[/\\]")
2828

29-
list (APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE @CMAKE_PREFIX_PATH@ "@FETCHCONTENT_BASE_DIR@"
30-
"${slash}_deps${slash}" "tests${slash}"
29+
list (
30+
APPEND
31+
CTEST_CUSTOM_COVERAGE_EXCLUDE
32+
@CMAKE_PREFIX_PATH@
33+
"@FETCHCONTENT_BASE_DIR@"
34+
"${slash}_deps${slash}"
35+
"tests${slash}"
36+
"_cmrc"
3137
)
3238

3339
list (
@@ -42,7 +48,4 @@ list (
4248
"libutil${slash}src${slash}memory${slash}PageAlignedAlloc_Windows.hpp"
4349
# MSVC warnings about the Visitor class's move operators being implicitly deleted
4450
"util::Visitor<"
45-
# warnings about std::getenv() being deprecated/thread-unsafe
46-
"main.cpp.+getenv"
47-
"note: 'getenv' has been explicitly marked deprecated here"
4851
)

tests/perft/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ foreach (data_file IN LISTS testcase_files)
4040
)
4141
# cmake-format: on
4242

43+
set (test_name "ben_bot.perft.${filename}.${depth}")
44+
4345
add_test (
44-
NAME "ben_bot.perft.${filename}.${depth}"
46+
NAME "${test_name}"
4547
COMMAND Python::Interpreter "${CMAKE_CURRENT_LIST_DIR}/perft.py" "--test=${data_file}"
4648
"--engine=$<TARGET_FILE:ben_bot>" "--depth=${depth}"
4749
)
50+
51+
set_tests_properties ("${test_name}" PROPERTIES REQUIRED_FILES "$<TARGET_FILE:ben_bot>")
4852
endforeach ()
4953

5054
set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${data_file}")

tests/position-solver/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,17 @@ foreach (epd_file IN LISTS testcase_files)
4343
CONFIGURATIONS Release
4444
)
4545

46+
# cmake-format: off
4647
set_tests_properties (
4748
"${test_name}"
48-
PROPERTIES ATTACHED_FILES_ON_FAIL "${engine_log}" RESOURCE_LOCK BenBotPositionSolver
49-
# allow 10 minutes after the go command is received
50-
TIMEOUT_AFTER_MATCH "600;: << go"
49+
PROPERTIES
50+
ATTACHED_FILES_ON_FAIL "${engine_log}"
51+
RESOURCE_LOCK BenBotPositionSolver
52+
REQUIRED_FILES "$<TARGET_FILE:ben_bot>"
53+
# allow 10 minutes after the go command is received
54+
TIMEOUT_AFTER_MATCH "600;: << go"
5155
)
56+
# cmake-format: on
5257

5358
set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${engine_log}")
5459
endforeach ()

tests/rampart/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ foreach (data_file IN LISTS testcase_files)
5151
"--test=${data_file}" "--exec=$<TARGET_FILE:rampart>"
5252
)
5353

54-
set_tests_properties ("${test_name}" PROPERTIES REQUIRED_FILES "${data_file}")
54+
set_tests_properties ("${test_name}" PROPERTIES REQUIRED_FILES "$<TARGET_FILE:rampart>")
5555
endforeach ()

0 commit comments

Comments
 (0)