forked from ddemidov/amgcl
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
194 lines (167 loc) · 6.71 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
cmake_minimum_required(VERSION 2.8)
project(AMGCL)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
#----------------------------------------------------------------------------
# Find OpenMP
#----------------------------------------------------------------------------
find_package(OpenMP)
if (OpenMP_CXX_FLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif ()
# #----------------------------------------------------------------------------
# # Find Eigen
# #----------------------------------------------------------------------------
# find_path(EIGEN_INCLUDE Eigen/SparseCore PATH_SUFFIXES eigen3)
# if (EIGEN_INCLUDE)
# include_directories(${EIGEN_INCLUDE})
# add_definitions(-DAMGCL_HAVE_EIGEN)
# endif()
#----------------------------------------------------------------------------
# Find Blaze
#----------------------------------------------------------------------------
find_path(BLAZE_INCLUDE blaze/Math.h)
if (BLAZE_INCLUDE)
include_directories(${BLAZE_INCLUDE})
add_definitions(-DAMGCL_HAVE_BLAZE)
endif()
#----------------------------------------------------------------------------
# Find HPX
#----------------------------------------------------------------------------
option(HAVE_HPX "Build HPX examples" OFF)
if (HAVE_HPX)
find_package(HPX)
set(BOOST_COMPONENTS serialization)
endif()
#----------------------------------------------------------------------------
# Find Boost
#----------------------------------------------------------------------------
if (WIN32)
set(Boost_USE_STATIC_LIBS ON)
else ()
option(
USE_STATIC_BOOST_LIBS
"Use static versions of Boost libraries"
OFF
)
if (USE_STATIC_BOOST_LIBS)
set(Boost_USE_STATIC_LIBS ON)
else()
set(Boost_USE_STATIC_LIBS OFF)
add_definitions(-DBOOST_TEST_DYN_LINK)
endif()
endif ()
set(BOOST_COMPONENTS ${BOOST_COMPONENTS}
program_options
system
filesystem
serialization
unit_test_framework
)
find_package(Boost COMPONENTS ${BOOST_COMPONENTS})
include_directories( ${Boost_INCLUDE_DIRS} )
#----------------------------------------------------------------------------
# Find VexCL
#----------------------------------------------------------------------------
set(VEXCL_ROOT $ENV{VEXCL_ROOT} CACHE STRING "VexCL root")
if (VEXCL_ROOT)
include_directories( ${VEXCL_ROOT} )
add_definitions(-DAMGCL_HAVE_VEXCL)
set(VEXCL_BACKEND "OpenCL" CACHE STRING "Select VexCL backend (OpenCL/CUDA)")
set_property(CACHE VEXCL_BACKEND PROPERTY STRINGS "OpenCL" "CUDA")
#----------------------------------------------------------------------------
# Find VexCL backend
#----------------------------------------------------------------------------
if ("${VEXCL_BACKEND}" STREQUAL "OpenCL")
find_package(OpenCL REQUIRED)
include_directories( ${OPENCL_INCLUDE_DIRS} )
set(VEXCL_BACKEND_LIBRARIES ${OPENCL_LIBRARIES})
add_definitions(-DVEXCL_BACKEND_OPENCL)
elseif ("${VEXCL_BACKEND}" STREQUAL "CUDA")
find_package(CUDA REQUIRED)
include_directories( ${CUDA_INCLUDE_DIRS} )
set(VEXCL_BACKEND_LIBRARIES ${CUDA_CUDA_LIBRARY})
add_definitions(-DVEXCL_BACKEND_CUDA)
endif()
endif()
#----------------------------------------------------------------------------
# Find ViennaCL
#----------------------------------------------------------------------------
find_path(VIENNACL_INCLUDE viennacl/forwards.h)
if (VIENNACL_INCLUDE)
add_definitions(-DAMGCL_HAVE_VIENNACL)
add_definitions(-DVIENNACL_WITH_OPENMP)
include_directories(${VIENNACL_INCLUDE})
endif()
#----------------------------------------------------------------------------
# Find CUDA
#----------------------------------------------------------------------------
find_package(CUDA QUIET)
if (CUDA_FOUND)
set(CUDA_COMPUTE_CAPABILITY "35" CACHE STRING "CUDA Compute Capability")
add_definitions(-DAMGCL_HAVE_CUDA)
add_definitions(-DBOOST_DISABLE_ASSERTS)
endif ()
#----------------------------------------------------------------------------
# Find MPI
#----------------------------------------------------------------------------
find_package(MPI QUIET)
if (MPI_CXX_FOUND)
include_directories(${MPI_CXX_INCLUDE_PATH})
endif()
#----------------------------------------------------------------------------
# Find Pastix
#----------------------------------------------------------------------------
find_package(Metis QUIET)
find_package(Scotch QUIET)
find_package(Pastix QUIET)
find_package(BLAS QUIET)
if (METIS_INCLUDES)
include_directories(${METIS_INCLUDES})
endif()
if (PASTIX_INCLUDES AND SCOTCH_INCLUDES AND BLAS_FOUND)
set(HAVE_PASTIX ON)
include_directories(${PASTIX_INCLUDES})
add_definitions(-DAMGCL_HAVE_PASTIX)
endif()
if (SCOTCH_INCLUDES)
include_directories(${SCOTCH_INCLUDES})
endif()
#----------------------------------------------------------------------------
# Protect Visual Studio from itself
#----------------------------------------------------------------------------
if (WIN32)
add_definitions(-DNOMINMAX)
add_definitions(-D_VARIADIC_MAX=10)
add_definitions(/bigobj)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif ()
#----------------------------------------------------------------------------
# Enable C++11 support, set compilation flags
#----------------------------------------------------------------------------
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wclobbered -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized -Wno-unused-parameter -Wunused-but-set-parameter -Wno-comment -Wno-type-limits -Wno-strict-aliasing -Wno-unused-local-typedefs")
set(CXX11_FLAG -std=c++0x)
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(CXX11_FLAG -std=c++11)
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wsign-compare -Wtype-limits -Wuninitialized -Wno-unused-parameter -Wno-comment -Wno-tautological-compare")
set(CXX11_FLAG -std=c++11)
option(USE_LIBCPP "Use libc++ with Clang" OFF)
if (USE_LIBCPP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif ()
endif ()
#----------------------------------------------------------------------------
enable_testing()
add_subdirectory(tests)
#----------------------------------------------------------------------------
set(BUILD_SHARED_LIBS ON)
add_subdirectory(lib)
add_subdirectory(pyamgcl)
add_subdirectory(examples)
add_subdirectory(doc)
install(DIRECTORY amgcl DESTINATION include)