-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
46 lines (36 loc) · 1.37 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
cmake_minimum_required(VERSION 3.25)
project(ChessEngine)
set(CMAKE_CXX_STANDARD 23)
option(WASM "Build Webassembly binary" TRUE)
option(LOGTOFILE "Make a file with a detailed search log" FALSE)
add_executable(ChessEngine main.cpp)
set(CMAKE_CXX_FLAGS "-std=c++23")
if (WASM)
message("Building for Webassembly")
add_compile_definitions(wasm)
set(CMAKE_CXX_FLAGS "-std=c++23 -fexperimental-library")
endif ()
if (LOGTOFILE)
message("Logging to file enabled")
add_compile_definitions(logtofile)
endif ()
include_directories(src)
add_subdirectory(src)
target_link_libraries(ChessEngine src)
if (NOT WASM)
add_subdirectory(tests)
endif ()
if (WASM)
set_target_properties(src PROPERTIES
COMPILE_FLAGS "-pthread"
)
set_target_properties(ChessEngine PROPERTIES
LINK_FLAGS "-O3 --closure 1 -sMODULARIZE -sEXPORT_ES6=1 -sEXPORT_NAME=Engine -sENVIRONMENT=web,worker -pthread -sPTHREAD_POOL_SIZE=8 --embed-file ../assets@/ -sINITIAL_MEMORY=512MB -sEXPORTED_FUNCTIONS=['_main','_init','_move','_unmove','_listPieces','_getMoves','_getAttacks','_setFen','_runPerft','_eval','_startSearch','_stopSearch'] -sEXPORTED_RUNTIME_METHODS=['ccall','cwrap']"
COMPILE_FLAGS "-pthread"
)
#-s ENVIRONMENT=web / -s ENVIRONMENT=node
#--profiling -g -s ASSERTIONS
endif ()
if (NOT WASM)
set(CMAKE_EXE_LINKER_FLAGS "-static")
endif ()