-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·34 lines (27 loc) · 1.16 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.8.0)
PROJECT(AlphaZero_Gomoku)
# find torch package
# use this statement to set your Torch_DIR
SET(Torch_DIR ~/anaconda3/envs/AlphaZero/lib/python3.7/site-packages/torch/share/cmake/Torch)
FIND_PACKAGE(Torch REQUIRED)
MESSAGE(STATUS "TORCH_LIBRARIES="${TORCH_LIBRARIES})
# find python package
FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
MESSAGE(STATUS "PYTHON_INCLUDE_PATH="${PYTHON_INCLUDE_PATH})
MESSAGE(STATUS "PYTHON_LIBRARIES="${PYTHON_LIBRARIES})
# find swig package
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
MESSAGE(STATUS "SWIG_USE_FILE="${SWIG_USE_FILE})
# cpp compile flags
SET(CMAKE_CXX_FLAGS "-std=c++14 -pthread -O3")
# include source file
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)
AUX_SOURCE_DIRECTORY(${PROJECT_SOURCE_DIR}/src DIR_SRCS)
# output executable file to this path
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
# swig
SET_PROPERTY(SOURCE ${PROJECT_SOURCE_DIR}/src/library.i PROPERTY CPLUSPLUS ON)
SWIG_ADD_LIBRARY(library LANGUAGE python TYPE SHARED SOURCES ${PROJECT_SOURCE_DIR}/src/library.i ${DIR_SRCS})
SWIG_LINK_LIBRARIES(library ${PYTHON_LIBRARIES} ${TORCH_LIBRARIES})