forked from Nonlinear2/Bread-Engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
106 lines (83 loc) · 3.52 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
cmake_minimum_required(VERSION 3.20)
project(bread_engine VERSION 0.0.5)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(bread_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(bread_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/utils)
set(bread_DEPENDENCIES ${CMAKE_CURRENT_SOURCE_DIR}/dependencies)
set(bread_NEURAL_NETWORKS ${CMAKE_CURRENT_SOURCE_DIR}/neural_networks)
set(bread_NN_HEADER_DIR ${CMAKE_BINARY_DIR}/gen)
set(bread_NN_HEADER_PATH ${bread_NN_HEADER_DIR}/neural_network.hpp)
set(bread_NNUE_MODEL_PATH "${bread_NEURAL_NETWORKS}/model_NNUE_2-40960_2x256_32_32_1_quant_layers")
set(bread_INCLUDE_DIRS
${bread_DEPENDENCIES}
${bread_DEPENDENCIES}/extern
${bread_DEPENDENCIES}/unit_tests
${bread_DEPENDENCIES}/extern/Fathom/src
${bread_NN_HEADER_DIR}
)
set(bread_SOURCE
${bread_SRC}/search_board.cpp
${bread_SRC}/nnue/nnue.cpp
${bread_SRC}/nnue/nnue_board.cpp
${bread_SRC}/transposition_table.cpp
${bread_SRC}/bread_engine_core.cpp
${bread_DEPENDENCIES}/extern/Fathom/src/tbprobe.cpp
)
# disable warnings generated by Fathom on GCC and Clang
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
set_source_files_properties(
${bread_DEPENDENCIES}/extern/Fathom/src/tbprobe.cpp
PROPERTIES
COMPILE_FLAGS "-w"
)
endif()
add_executable(generate_neural_net_header ${bread_UTILS}/generate_nn_header.cpp)
target_compile_definitions(generate_neural_net_header PRIVATE bread_NN_HEADER_PATH="${bread_NN_HEADER_PATH}")
target_compile_definitions(generate_neural_net_header PRIVATE bread_NNUE_MODEL_PATH="${bread_NNUE_MODEL_PATH}")
# add custom target that generates the header when needed
add_custom_command(
OUTPUT ${bread_NN_HEADER_PATH}
COMMENT "generating neural network"
COMMAND ${CMAKE_COMMAND} -E make_directory ${bread_NN_HEADER_DIR}
COMMAND $<TARGET_FILE:generate_neural_net_header>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(run_generate_neural_net_header DEPENDS ${bread_NN_HEADER_PATH})
function(bread_configure bread_TARGET)
cmake_parse_arguments(bread "" "" "SOURCES" ${ARGN})
add_executable(${bread_TARGET} ${bread_SOURCES})
target_include_directories(${bread_TARGET} PRIVATE ${bread_INCLUDE_DIRS})
target_compile_definitions(${bread_TARGET} PRIVATE bread_VERSION="${CMAKE_PROJECT_VERSION}")
add_dependencies(${bread_TARGET} run_generate_neural_net_header)
target_compile_definitions(${bread_TARGET} PRIVATE bread_TB_PATH="${bread_TB_PATH}")
target_compile_definitions(${bread_TARGET} PRIVATE bread_NN_HEADER_PATH="${bread_NN_HEADER_PATH}")
target_compile_definitions(${bread_TARGET} PRIVATE bread_NNUE_MODEL_PATH="${bread_NNUE_MODEL_PATH}")
if (TARGET release)
set_target_properties(release PROPERTIES OUTPUT_NAME "bread_engine_${CMAKE_PROJECT_VERSION}")
endif()
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
target_compile_options(${bread_TARGET} PRIVATE -march=native)
endif()
endfunction(bread_configure)
bread_configure(release SOURCES
${bread_SOURCE}
${bread_SRC}/uci.cpp
${bread_SRC}/run_uci.cpp
)
bread_configure(benchmark_engine SOURCES
${bread_SOURCE}
${bread_UTILS}/benchmark_engine.cpp
)
bread_configure(tests SOURCES
${bread_SOURCE}
${bread_UTILS}/unit_tests.cpp
)
bread_configure(parameter_tuning SOURCES
${bread_SOURCE}
${bread_UTILS}/parameter_optimisation.cpp
)
bread_configure(search_position SOURCES
${bread_SOURCE}
${bread_UTILS}/run_search.cpp
)