-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·52 lines (41 loc) · 1.32 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
cmake_minimum_required(VERSION 3.8.0)
project(library)
#
# option
option(WRAP_LIB "wrap library" ON)
option(UNIT_TEST "unit test" ON)
# gcc
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_STANDARD 17)
endif()
set(Torch_DIR ./libtorch/share/cmake/Torch)
# find torch
find_package(Torch REQUIRED)
# find swig
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
# find python
find_package(PythonLibs 3.6 REQUIRED)
include_directories(${PYTHON_INCLUDE_PATH})
# add sources
include_directories(./src)
aux_source_directory(./src SOURCES)
# unit test
#if(UNIT_TEST)
add_library(test_lib ${SOURCES})
target_link_libraries(test_lib ${TORCH_LIBRARIES})
add_executable(thread_pool_test ./test/thread_pool_test.cpp)
target_link_libraries(thread_pool_test test_lib)
add_executable(gomoku_test ./test/gomoku_test.cpp)
target_link_libraries(gomoku_test test_lib)
add_executable(libtorch_test ./test/libtorch_test.cpp)
target_link_libraries(libtorch_test test_lib)
add_executable(mcts_test ./test/mcts_test.cpp)
target_link_libraries(mcts_test test_lib)
#endif()
#swig
if(WRAP_LIB)
set_property(SOURCE ./src/library.i PROPERTY CPLUSPLUS ON)
swig_add_library(library TYPE SHARED LANGUAGE python SOURCES ./src/library.i ${SOURCES})
swig_link_libraries(library ${PYTHON_LIBRARIES} ${TORCH_LIBRARIES})
endif()