forked from tseip/fourinarow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
103 lines (81 loc) · 2.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
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
cmake_minimum_required(VERSION 3.15)
project(NInARow)
include (FetchContent)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
# Make the default build type Release. If user or another
# project sets a different value than use that
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to default -- Release")
set(CMAKE_BUILD_TYPE "Release" CACHE
STRING "Choose the type of build." FORCE)
endif()
message(STATUS "NInARow Build Type: ${CMAKE_BUILD_TYPE}")
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.13.0.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
FetchContent_Declare(
Eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG master
)
FetchContent_MakeAvailable(Eigen)
find_package(SWIG REQUIRED)
find_package(PythonLibs REQUIRED)
# Find Boost library
find_package(Boost REQUIRED)
# Add Boost include directories
include_directories(${Boost_INCLUDE_DIRS})
include(${SWIG_USE_FILE})
set(CMAKE_SWIG_FLAGS "")
include_directories(${PYTHON_INCLUDE_DIRS})
set(CXX_FLAGS)
list(APPEND CXX_FLAGS "-fPIC" "-Wall" "-Wextra" "-Werror" "-Wno-unused" "-fexceptions")
enable_testing()
add_executable(tests
bfs_node_ut.cpp
ninarow_bfs_ut.cpp
ninarow_board_ut.cpp
ninarow_heuristic_ut.cpp
ninarow_heuristic_feature_ut.cpp
ninarow_vectorized_feature_evaluator_ut.cpp
ninarow_move_ut.cpp
ninarow_pattern_ut.cpp
)
target_link_libraries(tests
GTest::gtest_main
Eigen3::Eigen
)
include(GoogleTest)
gtest_discover_tests(tests)
SET_SOURCE_FILES_PROPERTIES(fourbynine.i PROPERTIES CPLUSPLUS ON)
SWIG_ADD_LIBRARY(swig_fourbynine TYPE SHARED LANGUAGE python OUTPUT_DIR "../model_fitting" OUTFILE_DIR "./" SOURCES fourbynine.i)
set_property(TARGET swig_fourbynine PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
include(CheckTypeSize)
# Check the size of size_t
check_type_size("size_t" SIZE_T_SIZE)
message(STATUS "Detected size_t size: ${SIZE_T_SIZE}")
# Define SWIGWORDSIZE64 if size_t is not 8 bytes
if (NOT SIZE_T_SIZE EQUAL 8)
target_compile_definitions(swig_fourbynine PRIVATE SWIGWORDSIZE64)
endif()
IF (NOT WIN32)
set_target_properties(swig_fourbynine PROPERTIES SUFFIX ".so")
ENDIF()
target_include_directories(swig_fourbynine PUBLIC "./")
target_link_libraries(swig_fourbynine
${PYTHON_LIBRARIES}
Eigen3::Eigen
)
add_custom_command(TARGET swig_fourbynine POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:swig_fourbynine>"
"../model_fitting"
COMMENT "Copying SWIG library to output directory")