forked from OpenJij/OpenJij
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
89 lines (71 loc) · 1.88 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
cmake_minimum_required(VERSION 3.11)
project(openjij)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-long-long -pedantic")
# add fPIC option to all object files
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(FetchContent)
#### Google test ####
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG release-1.8.1
)
FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
message(STATUS "Fetch googletest for C++ testing")
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_SOURCE_DIR}/googlemock)
endif()
#### for pybind11 ####
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11
GIT_TAG v2.2.4
)
FetchContent_GetProperties(pybind11)
if(NOT pybind11_fetch_POPULATED)
message(STATUS "Fetch pybind11 for python-binding")
FetchContent_Populate(pybind11)
add_subdirectory(${pybind11_SOURCE_DIR})
endif()
set(PYBIND11_CPP_STANDARD -std=c++11)
##### Set default behavior #####
set(DEFAULT_USE_OMP No)
set(DEFAULT_USE_CUDA Yes)
set(DEFAULT_USE_TEST No)
# Use OpenMP as default behavior
if(NOT DEFINED USE_OMP)
set(USE_OMP ${DEFAULT_USE_OMP})
endif()
if(NOT DEFINED USE_CUDA)
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
enable_language(CUDA)
find_package(CUDA)
set(USE_CUDA ${DEFAULT_USE_CUDA})
else()
message(STATUS "No CUDA support")
set(USE_CUDA No)
endif()
endif()
if(NOT DEFINED USE_TEST)
set(USE_TEST ${DEFAULT_USE_TEST})
endif()
message(STATUS "USE_OMP = ${USE_OMP}")
message(STATUS "USE_CUDA = ${USE_CUDA}")
message(STATUS "USE_TEST = ${USE_TEST}")
#TODO: OMP settings
if(USE_CUDA)
add_definitions(-DUSE_CUDA)
endif()
add_subdirectory(src)
# shared libs
add_custom_target(shared
DEPENDS graph
DEPENDS algorithm
DEPENDS system
)
add_subdirectory(openjij)
add_subdirectory(tests)