forked from facebookarchive/Polygames
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
68 lines (52 loc) · 1.77 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
project(polygames)
# if(NOT CMAKE_BUILD_TYPE)
# set(CMAKE_BUILD_TYPE RelWithDebInfo)
# endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fsized-deallocation -O3 -ffast-math")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
OPTION(PYTORCH12 "Is PyTorch >= 1.2" OFF)
OPTION(PYTORCH15 "Is PyTorch >= 1.5" OFF)
IF(PYTORCH15)
ADD_DEFINITIONS(-DPYTORCH15 -DPYTORCH12)
ELSEIF(PYTORCH12)
ADD_DEFINITIONS(-DPYTORCH12)
ENDIF()
execute_process(
COMMAND python -c "import torch; import os; print(os.path.dirname(torch.__file__), end='')"
OUTPUT_VARIABLE TorchPath
)
set(CMAKE_PREFIX_PATH ${TorchPath})
find_package(Torch REQUIRED)
find_package(Boost COMPONENTS system)
if( Boost_FOUND )
include_directories( ${Boost_INCLUDE_DIRS})
endif()
option(WITH_LUDII "Include LUDII support" ON)
if(WITH_LUDII)
find_package(JNI)
if (JNI_FOUND)
include_directories( ${JNI_INCLUDE_DIRS})
else()
message(STATUS "Java not found, LUDII support will not be included")
add_definitions(-DNO_JAVA)
endif()
else()
add_definitions(-DNO_JAVA)
endif()
message(STATUS "Adding PyTorch compilation flags: ${TORCH_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
add_subdirectory(src)
# add Minesweeper benchmarks
add_subdirectory(src/games/minesweeper_csp_vkms)
# tests
add_executable(test_state src/core/test_state.cc src/core/state.cc)
target_link_libraries(test_state PUBLIC _tube _mcts _games ${JNI_LIBRARIES})
enable_testing()
add_test(NAME test_replay_buffer
COMMAND ${PYTHON_EXECUTABLE} -m test_replay_buffer
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/python)
set_tests_properties(test_replay_buffer
PROPERTIES ENVIRONMENT "PYTHONPATH=${PROJECT_SOURCE_DIR}:$ENV{PYTHONPATH}")