Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ben-bot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ target_link_libraries (ben_bot PRIVATE ben_bot::libbenbot)

add_executable (ben_bot::ben_bot ALIAS ben_bot)

if (MSVC)
target_compile_definitions (ben_bot PRIVATE _CRT_SECURE_NO_WARNINGS)
endif ()

#

include (CheckIPOSupported)
Expand Down
1 change: 1 addition & 0 deletions config/cmake/All.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ include_guard (GLOBAL)

include ("${CMAKE_CURRENT_LIST_DIR}/Sanitizers.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/Coverage.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/Hardening.cmake")
include ("${CMAKE_CURRENT_LIST_DIR}/Warnings.cmake")

# General settings
Expand Down
56 changes: 56 additions & 0 deletions config/cmake/Hardening.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ======================================================================================
#
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓███████▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░▒▓████████▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
# ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒░
#
# ======================================================================================

include_guard (GLOBAL)

if (MSVC)
add_compile_options (/sdl /DYNAMICBASE /guard:cf)
add_link_options (/NXCOMPAT /CETCOMPAT)

return ()
endif ()

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
get_cmake_property (debug_configs DEBUG_CONFIGURATIONS)

if (NOT debug_configs)
set (debug_configs Debug)
endif ()

list (JOIN debug_configs "," debug_configs)

set (config_debug "$<CONFIG:${debug_configs}>")
set (config_release "$<NOT:${config_debug}>")

add_compile_options ("$<${config_release}:-U_FORTIFY_SOURCE>")

add_compile_definitions (_GLIBCXX_ASSERTIONS "$<${config_release}:_FORTIFY_SOURCE=3>")

include (CheckCXXCompilerFlag)

check_cxx_compiler_flag (-fstack-protector-strong HAVE_fstack_protector_strong)
if (HAVE_fstack_protector_strong)
add_compile_options (-fstack-protector-strong)
endif ()

check_cxx_compiler_flag (-fcf-protection HAVE_fcf_protection)
if (HAVE_fcf_protection)
add_compile_options (-fcf-protection)
endif ()

if (LINUX OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
check_cxx_compiler_flag (-fstack-clash-protection HAVE_fstack_clash_protection)
if (HAVE_fstack_clash_protection)
add_compile_options (-fstack-clash-protection)
endif ()
endif ()
endif ()
13 changes: 8 additions & 5 deletions tests/CTestCustom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ set (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 100)
# this matches forward- or back-slashes
set (slash "[/\\]")

list (APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE @CMAKE_PREFIX_PATH@ "@FETCHCONTENT_BASE_DIR@"
"${slash}_deps${slash}" "tests${slash}"
list (
APPEND
CTEST_CUSTOM_COVERAGE_EXCLUDE
@CMAKE_PREFIX_PATH@
"@FETCHCONTENT_BASE_DIR@"
"${slash}_deps${slash}"
"tests${slash}"
"_cmrc"
)

list (
Expand All @@ -42,7 +48,4 @@ list (
"libutil${slash}src${slash}memory${slash}PageAlignedAlloc_Windows.hpp"
# MSVC warnings about the Visitor class's move operators being implicitly deleted
"util::Visitor<"
# warnings about std::getenv() being deprecated/thread-unsafe
"main.cpp.+getenv"
"note: 'getenv' has been explicitly marked deprecated here"
)
6 changes: 5 additions & 1 deletion tests/perft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ foreach (data_file IN LISTS testcase_files)
)
# cmake-format: on

set (test_name "ben_bot.perft.${filename}.${depth}")

add_test (
NAME "ben_bot.perft.${filename}.${depth}"
NAME "${test_name}"
COMMAND Python::Interpreter "${CMAKE_CURRENT_LIST_DIR}/perft.py" "--test=${data_file}"
"--engine=$<TARGET_FILE:ben_bot>" "--depth=${depth}"
)

set_tests_properties ("${test_name}" PROPERTIES REQUIRED_FILES "$<TARGET_FILE:ben_bot>")
endforeach ()

set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${data_file}")
Expand Down
11 changes: 8 additions & 3 deletions tests/position-solver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ foreach (epd_file IN LISTS testcase_files)
CONFIGURATIONS Release
)

# cmake-format: off
set_tests_properties (
"${test_name}"
PROPERTIES ATTACHED_FILES_ON_FAIL "${engine_log}" RESOURCE_LOCK BenBotPositionSolver
# allow 10 minutes after the go command is received
TIMEOUT_AFTER_MATCH "600;: << go"
PROPERTIES
ATTACHED_FILES_ON_FAIL "${engine_log}"
RESOURCE_LOCK BenBotPositionSolver
REQUIRED_FILES "$<TARGET_FILE:ben_bot>"
# allow 10 minutes after the go command is received
TIMEOUT_AFTER_MATCH "600;: << go"
)
# cmake-format: on

set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${engine_log}")
endforeach ()
Expand Down
2 changes: 1 addition & 1 deletion tests/rampart/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ foreach (data_file IN LISTS testcase_files)
"--test=${data_file}" "--exec=$<TARGET_FILE:rampart>"
)

set_tests_properties ("${test_name}" PROPERTIES REQUIRED_FILES "${data_file}")
set_tests_properties ("${test_name}" PROPERTIES REQUIRED_FILES "$<TARGET_FILE:rampart>")
endforeach ()
Loading