CMakeLists.txt 10.6 KB
Newer Older
Kirill Terekhov's avatar
Kirill Terekhov committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
cmake_minimum_required (VERSION 2.6)
project (INMOST)
set(SOURCE solver.cpp 
           solver_ani.cpp 
           solver_petsc.cpp 
           partitioner.cpp 
           algorithm.cpp 
           geometry.cpp 
           iterator.cpp
           storage.cpp
           eset.cpp
           mesh_file.cpp
           timer.cpp
           face.cpp
           edge.cpp
           mesh.cpp
           node.cpp
           cell.cpp
           tag.cpp
           element.cpp
           mesh_parallel.cpp
           modify.cpp
Kirill Terekhov's avatar
Kirill Terekhov committed
23
24
           earray.cpp
           comparator.cpp
Kirill Terekhov's avatar
Kirill Terekhov committed
25
26
           autodiff.cpp
           solver_ddpqiluc2.cpp)
Kirill Terekhov's avatar
Kirill Terekhov committed
27
28
29
30
31
32
33
34
35
36
set(HEADER inmost.h
           inmost_options_cmake.h
           inmost_common.h
           inmost_mesh.h
           inmost_solver.h
           inmost_partitioner.h
           inmost_autodiff.h
           container.hpp
           io.hpp
           solver_ilu2.hpp
Kirill Terekhov's avatar
Kirill Terekhov committed
37
           solver_ddpqiluc2.hpp
Kirill Terekhov's avatar
Kirill Terekhov committed
38
39
40
           solver_bcgsl.hpp
           solver_prototypes.hpp)

Kirill Terekhov's avatar
Kirill Terekhov committed
41
42
43
44
set(INMOST_MAJOR_VERSION 0)
set(INMOST_MINOR_VERSION 1)
set(INMOST_PATCH_VERSION 0)
set(INMOST_VERSION "${INMOST_MAJOR_VERSION}.${INMOST_MINOR_VERSION}.${INMOST_PATCH_VERSION}")
Kirill Terekhov's avatar
Kirill Terekhov committed
45

Kirill Terekhov's avatar
Kirill Terekhov committed
46
47
48
49
50
51
52
53
54
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_mtiluc2.hpp" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_mtiluc2.cpp" )
  add_definitions(-DHAVE_SOLVER_MPTILUC2)
  set(HAVE_SOLVER_MPTILUC2 TRUE)
  list(APPEND HEADER solver_mtiluc2.hpp)
  list(APPEND SOURCE solver_mtiluc2.cpp)
else()
  set(HAVE_SOLVER_MPTILUC2 FALSE)
endif()

Kirill Terekhov's avatar
Kirill Terekhov committed
55
56
57
58
59
60
61
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_mtilu2.hpp" )
  add_definitions(-DHAVE_SOLVER_MPTILU2)
  set(HAVE_SOLVER_MPTILU2 TRUE)
  list(APPEND SOURCE solver_mtilu2.hpp)
else()
  set(HAVE_SOLVER_MPTILU2 FALSE)
endif()
Kirill Terekhov's avatar
Kirill Terekhov committed
62

63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_fcbiilu2.h" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_fcbiilu2.cpp" AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/fcbiilu2.cpp" )
  add_definitions(-DHAVE_SOLVER_FCBIILU2)
  set(HAVE_SOLVER_FCBIILU2 TRUE)
  list(APPEND HEADER solver_fcbiilu2.h)
  list(APPEND SOURCE solver_fcbiilu2.cpp fcbiilu2.cpp)
else()
  set(HAVE_SOLVER_FCBIILU2 FALSE)
endif()

if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/solver_k3biilu2.h" AND EXISTS
		"${CMAKE_CURRENT_SOURCE_DIR}/solver_k3biilu2.cpp" AND EXISTS
		"${CMAKE_CURRENT_SOURCE_DIR}/k3d.h" AND EXISTS
		"${CMAKE_CURRENT_SOURCE_DIR}/k3d.cpp" )
  add_definitions(-DHAVE_SOLVER_K3BIILU2)
  set(HAVE_SOLVER_K3BIILU2 TRUE)
  list(APPEND HEADER solver_k3biilu2.h k3d.h)
  list(APPEND SOURCE solver_k3biilu2.cpp k3d.cpp)
else()
  set(HAVE_SOLVER_K3BIILU2 FALSE)
endif()

Kirill Terekhov's avatar
Kirill Terekhov committed
84
85
86
add_library(inmost STATIC ${SOURCE} ${HEADER})

option(USE_MPI "Compile with MPI support" ON)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
87
88
option(USE_MPI_P2P "Use MPI point to point functionality, may be faster with hardware support" ON)
option(USE_MPI_FILE "Use MPI extension to work with files, may save a lot of memory" ON)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
89
option(USE_MPI2 "Use MPI-2 extensions, useful if your MPI library warns you to use new functions" ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
90
91
92
93
94
95
96
97
option(USE_OMP "Compile with OpenMP support (experimental)" OFF)

option(USE_MESH "Compile mesh capabilities" ON)
option(USE_SOLVER "Compile solver capabilities" ON)
option(USE_PARTITIONER "Compile partitioner capabilities" ON)
option(USE_AUTODIFF "Compile automatic differentiation capabilities" ON)
option(TEST_FORTRAN_ANI3D "Test for fortran availibility to compile ANI3D lib" OFF)
option(COMPILE_EXAMPLES "Compile examples" OFF)
Kirill Terekhov's avatar
Updates    
Kirill Terekhov committed
98
#option(COMPILE_PROJECTS "Compile projects" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
99
100
101
102
option(COMPILE_TESTS "Compile some tests" OFF)

option(USE_PARTITIONER_PARMETIS "Use ParMetis partitioner" OFF)
option(USE_PARTITIONER_ZOLTAN "Use Zoltan partitioner" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
103
option(USE_SOLVER_METIS "Use METIS for matrix reordering" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
104
option(USE_SOLVER_MONDRIAAN "Use Mondriaan for matrix reordering" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
105
106
option(USE_SOLVER_PETSC "Use PETSc solvers" OFF)
option(USE_SOLVER_TRILINOS "Use Trilinos solvers" OFF)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
107
108
109
#option(USE_AUTODIFF_OPENCL "Use OpenCL for automatic differentiation (under work)" OFF)
#option(USE_AUTODIFF_ASMJIT "Use AsmJit for automatic differentiation" OFF)
#option(USE_AUTODIFF_EXPRESSION_TEMPLATES "Use c++ expression templates for automatic differentiation" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
110
111
112
113
114

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_find/")


if(TEST_FORTRAN_ANI3D)
115
116
117
118
119
	include(CheckLanguage)
	check_language(Fortran)
	find_package(BLAS)
	if(NOT CMAKE_Fortran_COMPILER OR NOT BLAS_FOUND)
		message(STATUS "No Fortran or BLAS support")
Kirill Terekhov's avatar
Kirill Terekhov committed
120
121
		option(USE_SOLVER_ANI "Compile with ANI3D sequential solvers" OFF)
	else()
122
123
		enable_language(Fortran)
		add_subdirectory(ILU2)
Kirill Terekhov's avatar
Kirill Terekhov committed
124
125
		option(USE_SOLVER_ANI "Compile with ANI3D sequential solvers" ON)
	endif()
126

Kirill Terekhov's avatar
Kirill Terekhov committed
127
128
129
130
131
132
endif()


if(USE_MPI)
	find_package(MPI)
	if(NOT MPI_FOUND)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
133
		set(USE_MPI OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
134
135
136
		message("MPI NOT FOUND")
	else()
		include_directories(${MPI_INCLUDE_PATH})
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
137
		set(USE_MPI ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
138
139
140
141
142
143
144
145
146
147
148
		set_target_properties(inmost PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
		message("MPI FOUND")
	endif()
endif()

if(USE_OMP)
	find_package(OpenMP)
	if (OPENMP_FOUND)
		set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
		set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
	else()
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
149
		set(USE_OMP OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
150
151
152
153
154
155
	endif()
endif()

if(USE_PARTITIONER_PARMETIS)
	find_package(ParMETIS)
	if(NOT PARMETIS_FOUND)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
156
		set(USE_PARTITIONER_PARMETIS OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
157
158
159
		message("PARMETIS NOT FOUND")
	else()
		include_directories(${PARMETIS_INCLUDE_DIR})
Kirill Terekhov's avatar
Kirill Terekhov committed
160
		include_directories(${METIS_INCLUDE_DIR})
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
161
		set(USE_PARTITIONER_PARMETIS ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
162
163
164
165
		message("PARMETIS FOUND")
	endif()
endif()

Kirill Terekhov's avatar
Kirill Terekhov committed
166
167
168
169
170
171
172
173
174
175
176
if(USE_SOLVER_METIS)
	find_package(METIS)
	if(NOT METIS_FOUND)
		set(USE_SOLVER_METIS OFF)
		message("METIS NOT FOUND")
	else()
		include_directories(${METIS_INCLUDE_DIR})
		set(USE_SOLVER_METIS ON)
		message("METIS FOUND")
	endif()
endif()
Kirill Terekhov's avatar
Kirill Terekhov committed
177

Kirill Terekhov's avatar
Kirill Terekhov committed
178
179
180
181
182
183
184
185
186
187
188
189
190
191
if(USE_SOLVER_MONDRIAAN)
	find_package(MONDRIAAN)
	if(NOT MONDRIAAN_FOUND)
		set(USE_SOLVER_MONDRIAAN OFF)
		message("Mondriaan NOT FOUND")
	else()
		link_directories(${MONDRIAAN_LIBRARY_DIRS})
		include_directories(${MONDRIAAN_INCLUDE_DIRS})
		set(USE_SOLVER_MONDRIAAN ON)
		message("Mondriaan FOUND")
	endif()
endif()


Kirill Terekhov's avatar
Kirill Terekhov committed
192
193
194
if(USE_PARTITIONER_ZOLTAN)
	find_package(ZOLTAN)
	if(NOT ZOLTAN_FOUND)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
195
		set(USE_PARTITIONER_ZOLTAN OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
196
197
		message("ZOLTAN NOT FOUND")
	else()
Kirill Terekhov's avatar
Kirill Terekhov committed
198
		#include_directories(${ZOLTAN_INCLUDE_DIR})
Kirill Terekhov's avatar
Kirill Terekhov committed
199
		include_directories(${ZOLTAN_INCLUDE_DIRS})
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
200
		set(USE_PARTITIONER_ZOLTAN ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
201
202
203
204
205
206
207
		message("ZOLTAN FOUND")
	endif()
endif()

if(USE_SOLVER_PETSC)
	find_package(PETSc)
	if(NOT PETSC_FOUND)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
208
		set(USE_SOLVER_PETSC OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
209
210
211
		message("PETSC NOT FOUND")
	else()
		include_directories(${PETSC_INCLUDES})
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
212
		set(USE_SOLVER_PETSC ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
213
214
215
216
217
218
219
		message("PETSC FOUND")
		add_definitions(${PETSC_DEFINITIONS})
		#message(${PETSC_LIBRARIES})
	endif()
endif()


Kirill Terekhov's avatar
Kirill Terekhov committed
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
if(USE_SOLVER_TRILINOS)
	set(CMAKE_PREFIX_PATH ${TRILINOS_PATH} ${CMAKE_PREFIX_PATH})
	find_package(Trilinos PATHS ${TRILINOS_PATH}/lib/cmake/Trilinos ${TRILINOS_PATH})
	if(NOT Trilinos_FOUND)
		set(USE_SOLVER_TRILINOS OFF)
		message("Trilinos NOT FOUND")
	else()

		MESSAGE("\nFound Trilinos!  Here are the details: ")
		MESSAGE("   Trilinos_DIR = ${Trilinos_DIR}")
		MESSAGE("   Trilinos_VERSION = ${Trilinos_VERSION}")
		MESSAGE("   Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST}")
		MESSAGE("   Trilinos_LIBRARIES = ${Trilinos_LIBRARIES}")
		MESSAGE("   Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS}")
		MESSAGE("   Trilinos_LIBRARY_DIRS = ${Trilinos_LIBRARY_DIRS}")
		MESSAGE("   Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}")
		MESSAGE("   Trilinos_TPL_INCLUDE_DIRS = ${Trilinos_TPL_INCLUDE_DIRS}")
		MESSAGE("   Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}")
		MESSAGE("   Trilinos_TPL_LIBRARY_DIRS = ${Trilinos_TPL_LIBRARY_DIRS}")
		MESSAGE("   Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}")
		MESSAGE("End of Trilinos details\n")

		include_directories(${Trilinos_INCLUDE_DIRS})
		include_directories(${Trilinos_TPL_INCLUDE_DIRS})
		link_directories(${Trilinos_LIBRARY_DIRS})
		link_directories(${Trilinos_TPL_LIBRARY_DIRS})


		set(USE_SOLVER_TRILINOS ON)
		message("Trilinos FOUND")
	endif()
endif()


Kirill Terekhov's avatar
Kirill Terekhov committed
254
255
256
if(USE_AUTODIFF_OPENCL)
	find_package(OpenCL)
	if(OPENCL_FOUND)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
257
		set(USE_AUTODIFF_OPENCL ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
258
		include_directories(${OPENCL_INCLUDE_DIRS})
Kirill Terekhov's avatar
Kirill Terekhov committed
259
		link_directories(${PETSC_LIBRARY_DIRS})
Kirill Terekhov's avatar
Kirill Terekhov committed
260
	else()
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
261
		set(USE_AUTODIFF_OPENCL OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
262
263
264
265
266
		message("OpenCL not found")
	endif()
endif()

if(USE_AUTODIFF_ASMJIT)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
267
	set(ASMJIT_STATIC TRUE)
Kirill Terekhov's avatar
Kirill Terekhov committed
268
269
270
271
272
273
274
275
276
277
278
279
	include("AsmJit/CMakeLists.txt")	
	include_directories("${ASMJIT_INC_DIR}/asmjit")
	target_link_libraries(inmost asmjit)
endif()

if(USE_AUTODIFF_EXPRESSION_TEMPLATES)
	if(MSVC)
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
	endif()
endif()


Kirill Terekhov's avatar
Kirill Terekhov committed
280
281
282
283
284
285
286
287
if(MSVC)
  if(USE_SOLVER_TRILINOS)
    message("Putting workaround for Visual Studio that allow to use Trilinos Release libraries in Debug mode")
    message("Note that this workaround may affect your debugging experience, you may want to debug without Trilinos")
    add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
  endif()
endif()

Kirill Terekhov's avatar
Kirill Terekhov committed
288
289
290
291
292
293
294
configure_file("inmost_options_cmake.h" "${PROJECT_BINARY_DIR}/inmost_options.h")
include_directories("${PROJECT_BINARY_DIR}")

if(COMPILE_EXAMPLES)
add_subdirectory(examples)
endif(COMPILE_EXAMPLES)

Kirill Terekhov's avatar
Updates    
Kirill Terekhov committed
295
296
297
#if(COMPILE_PROJECTS)
#add_subdirectory(projects)
#endif(COMPILE_PROJECTS)
Kirill Terekhov's avatar
Kirill Terekhov committed
298
299

if(COMPILE_TESTS)
Kirill Terekhov's avatar
Kirill Terekhov committed
300
301
enable_testing()
include(CTest)
Kirill Terekhov's avatar
Kirill Terekhov committed
302
303
304
add_subdirectory(tests)
endif(COMPILE_TESTS)

Kirill Terekhov's avatar
Kirill Terekhov committed
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319

set(INMOST_INSTALL_HEADERS inmost.h
                           inmost_options_cmake.h
                           inmost_common.h
                           inmost_mesh.h
                           inmost_solver.h
                           inmost_partitioner.h
                           inmost_autodiff.h
                           container.hpp)

include(CPack)
export(TARGETS inmost FILE inmost-targets.cmake)
export(PACKAGE inmost)
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}")
configure_file(inmost-config.cmake.in "${PROJECT_BINARY_DIR}/inmost-config.cmake" @ONLY)
Kirill Terekhov's avatar
Kirill Terekhov committed
320
set(CONF_INCLUDE_DIRS "\${inmost_DIR}/include")
Kirill Terekhov's avatar
Kirill Terekhov committed
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
configure_file(inmost-config.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/inmost-config.cmake" @ONLY)
configure_file(inmost-config-version.cmake.in "${PROJECT_BINARY_DIR}/inmost-config-version.cmake" @ONLY)


set_property(TARGET inmost PROPERTY PUBLIC_HEADER
	"${PROJECT_BINARY_DIR}/inmost_options.h"
	"${PROJECT_SOURCE_DIR}/inmost.h"
	"${PROJECT_SOURCE_DIR}/inmost_common.h"
	"${PROJECT_SOURCE_DIR}/inmost_mesh.h"
	"${PROJECT_SOURCE_DIR}/inmost_solver.h"
	"${PROJECT_SOURCE_DIR}/inmost_partitioner.h"
	"${PROJECT_SOURCE_DIR}/inmost_autodiff.h"
	"${PROJECT_SOURCE_DIR}/container.hpp")

install(FILES
  "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/inmost-config.cmake"
  "${PROJECT_BINARY_DIR}/inmost-config-version.cmake"
  DESTINATION "${CMAKE_INSTALL_PREFIX}")

install(TARGETS inmost EXPORT inmost-targets
        ARCHIVE DESTINATION lib
Kirill Terekhov's avatar
Kirill Terekhov committed
342
343
344
	LIBRARY DESTINATION lib
	RUNTIME DESTINATION bin
	PUBLIC_HEADER DESTINATION include)
Kirill Terekhov's avatar
Kirill Terekhov committed
345
346


Kirill Terekhov's avatar
Kirill Terekhov committed
347
install(EXPORT inmost-targets DESTINATION cmake)