1- cmake_minimum_required (VERSION 3.9 )
1+ cmake_minimum_required (VERSION 3.11 )
22project (Topple)
33
44set (CMAKE_CXX_STANDARD 17)
@@ -18,12 +18,12 @@ set(SOURCE_FILES
1818 pvs.h pvs.cpp
1919 syzygy/tbcore.h
2020 syzygy/tbprobe.h syzygy/tbprobe.cpp syzygy/tbresolve.h syzygy/tbresolve.cpp)
21- set (TEST_FILES testing/catch.hpp testing/ runner.cpp testing/util.h testing/util.cpp
22- testing/tests/ test_bb.cpp
23- testing/tests/ test_board.cpp
24- testing/tests/ test_perft.cpp
25- testing/tests/ test_see.cpp
26- testing/tests/ test_hash.cpp)
21+ set (TEST_FILES testing/runner.cpp testing/util.h testing/util.cpp
22+ testing/test_bb.cpp
23+ testing/test_board.cpp
24+ testing/test_perft.cpp
25+ testing/test_see.cpp
26+ testing/test_hash.cpp)
2727set (TOPPLE_TUNE_FILES toppletuning/main.cpp
2828 toppletuning/game.cpp toppletuning/game.h
2929 toppletuning/toppletuner.cpp toppletuning/toppletuner.h
@@ -34,7 +34,18 @@ set(TEXEL_TUNE_FILES texeltuning/main.cpp
3434# Add version definitions
3535add_definitions (-DTOPPLE_VER="${TOPPLE_VERSION} " )
3636
37+ # Set up Catch2 unit tests
38+ Include (FetchContent)
39+ FetchContent_Declare(
40+ Catch2
41+ GIT_REPOSITORY https://github.com/catchorg/Catch2.git
42+ GIT_TAG v2.13.3)
43+ FetchContent_MakeAvailable(Catch2)
3744add_executable (ToppleTest ${SOURCE_FILES} ${TEST_FILES} )
45+ target_link_libraries (ToppleTest Catch2::Catch2)
46+ target_compile_options (ToppleTest PUBLIC -march=native -O3)
47+ add_test (NAME ToppleTest COMMAND ToppleTest)
48+
3849set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE )
3950add_executable (Topple ${SOURCE_FILES} main.cpp)
4051add_executable (ToppleTune ${SOURCE_FILES} ${TOPPLE_TUNE_FILES} )
@@ -44,19 +55,17 @@ add_executable(ToppleTexelTune ${SOURCE_FILES} ${TEXEL_TUNE_FILES})
4455set (THREADS_PREFER_PTHREAD_FLAG ON )
4556find_package (Threads REQUIRED)
4657target_link_libraries (Topple Threads::Threads)
47- target_link_libraries (ToppleTest Threads::Threads)
4858target_link_libraries (ToppleTune Threads::Threads)
4959target_link_libraries (ToppleTexelTune Threads::Threads)
5060
5161# Set -march for the Topple target, only enable asserts for tests
52- target_compile_options (ToppleTest PUBLIC -march=native -O3)
5362target_compile_options (Topple PUBLIC -march=native -O3 -DNDEBUG)
5463target_compile_options (ToppleTune PUBLIC -DTOPPLE_TUNE -O3 -march=native -DNDEBUG)
5564target_compile_options (ToppleTexelTune PUBLIC -DTEXEL_TUNE -O3 -march=native -DNDEBUG)
5665
5766# Configure the "Release" target
5867if (CMAKE_BUILD_TYPE STREQUAL "Release" )
59- set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++" )
68+ set (CMAKE_EXE_LINKER_FLAGS "-static -static -libgcc -static-libstdc++" )
6069
6170 add_custom_target (Release)
6271 add_executable (Topple_${TOPPLE_VERSION} _legacy ${SOURCE_FILES} main.cpp)
0 commit comments