CMakeLists.txt 10.3 KB
Newer Older
Kirill Terekhov's avatar
Kirill Terekhov committed
1
2
cmake_minimum_required (VERSION 2.6)
project (INMOST)
Kirill Terekhov's avatar
Kirill Terekhov committed
3
4
5
6

add_subdirectory(Source)
add_definitions(${SOLVER_DEFINITIONS})
include_directories("Source/Headers")
Kirill Terekhov's avatar
Kirill Terekhov committed
7

Kirill Terekhov's avatar
Kirill Terekhov committed
8
9
10
11
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
12

13

Kirill Terekhov's avatar
Kirill Terekhov committed
14
15
16
add_library(inmost STATIC ${SOURCE} ${HEADER})

option(USE_MPI "Compile with MPI support" ON)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
17
18
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
19
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
20
21
22
23
24
25
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)
Kirill Terekhov's avatar
Kirill Terekhov committed
26
option(USE_NONLINEAR "Compile nonlinear solver capabilities" ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
27
28
29
30
31
32
option(TEST_FORTRAN_ANI3D "Test for fortran availibility to compile ANI3D lib" OFF)
option(COMPILE_EXAMPLES "Compile examples" OFF)
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
33
option(USE_SOLVER_METIS "Use METIS for matrix reordering" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
34
option(USE_SOLVER_MONDRIAAN "Use Mondriaan for matrix reordering" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
35
36
option(USE_SOLVER_PETSC "Use PETSc solvers" OFF)
option(USE_SOLVER_TRILINOS "Use Trilinos solvers" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
37
option(USE_SOLVER_SUPERLU "Use SuperLU solver" OFF)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
38
39
40
#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
41
42
43
44
45

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


if(TEST_FORTRAN_ANI3D)
46
47
48
49
50
	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
51
52
		option(USE_SOLVER_ANI "Compile with ANI3D sequential solvers" OFF)
	else()
53
54
		enable_language(Fortran)
		add_subdirectory(ILU2)
Kirill Terekhov's avatar
Kirill Terekhov committed
55
56
		option(USE_SOLVER_ANI "Compile with ANI3D sequential solvers" ON)
	endif()
57

Kirill Terekhov's avatar
Kirill Terekhov committed
58
59
60
61
62
63
endif()


if(USE_MPI)
	find_package(MPI)
	if(NOT MPI_FOUND)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
64
		set(USE_MPI OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
65
66
67
		message("MPI NOT FOUND")
	else()
		include_directories(${MPI_INCLUDE_PATH})
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
68
		set(USE_MPI ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
69
70
71
72
73
74
75
76
77
78
		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}")
Kirill Terekhov's avatar
Kirill Terekhov committed
79
		message("OpenMP FOUND")
Kirill Terekhov's avatar
Kirill Terekhov committed
80
	else()
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
81
		set(USE_OMP OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
82
		message("OpenMP NOT FOUND")
Kirill Terekhov's avatar
Kirill Terekhov committed
83
84
85
86
87
88
	endif()
endif()

if(USE_PARTITIONER_PARMETIS)
	find_package(ParMETIS)
	if(NOT PARMETIS_FOUND)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
89
		set(USE_PARTITIONER_PARMETIS OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
90
91
92
		message("PARMETIS NOT FOUND")
	else()
		include_directories(${PARMETIS_INCLUDE_DIR})
Kirill Terekhov's avatar
Kirill Terekhov committed
93
		include_directories(${METIS_INCLUDE_DIR})
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
94
		set(USE_PARTITIONER_PARMETIS ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
95
96
97
98
		message("PARMETIS FOUND")
	endif()
endif()

Kirill Terekhov's avatar
Kirill Terekhov committed
99
100
101
102
103
104
105
106
107
108
109
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
110

Kirill Terekhov's avatar
Kirill Terekhov committed
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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
125
126
127
if(USE_PARTITIONER_ZOLTAN)
	find_package(ZOLTAN)
	if(NOT ZOLTAN_FOUND)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
128
		set(USE_PARTITIONER_ZOLTAN OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
129
130
		message("ZOLTAN NOT FOUND")
	else()
Kirill Terekhov's avatar
Kirill Terekhov committed
131
		#include_directories(${ZOLTAN_INCLUDE_DIR})
Kirill Terekhov's avatar
Kirill Terekhov committed
132
		include_directories(${ZOLTAN_INCLUDE_DIRS})
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
133
		set(USE_PARTITIONER_ZOLTAN ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
134
135
136
137
138
139
140
		message("ZOLTAN FOUND")
	endif()
endif()

if(USE_SOLVER_PETSC)
	find_package(PETSc)
	if(NOT PETSC_FOUND)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
141
		set(USE_SOLVER_PETSC OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
142
143
144
		message("PETSC NOT FOUND")
	else()
		include_directories(${PETSC_INCLUDES})
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
145
		set(USE_SOLVER_PETSC ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
146
147
148
149
150
151
152
		message("PETSC FOUND")
		add_definitions(${PETSC_DEFINITIONS})
		#message(${PETSC_LIBRARIES})
	endif()
endif()


Kirill Terekhov's avatar
Kirill Terekhov committed
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
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
if(USE_SOLVER_SUPERLU)
	find_package(SUPERLU)
	if(NOT SUPERLU_FOUND)
		set(USE_SOLVER_SUPERLU OFF)
		MESSAGE("SUPERLU NOT FOUND")
	else()
		MESSAGE("\nFound SuperLU!  Here are the details: ")
		MESSAGE("INCLUDES:  ${SUPERLU_INCLUDES}")
		MESSAGE("LIBRARIES: ${SUPERLU_LIBRARIES}")

		include_directories(${SUPERLU_INCLUDES})
		set(USE_SOLVER_SUPERLU ON)
		
	endif()
endif()

Kirill Terekhov's avatar
Kirill Terekhov committed
203
204
205
if(USE_AUTODIFF_OPENCL)
	find_package(OpenCL)
	if(OPENCL_FOUND)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
206
		set(USE_AUTODIFF_OPENCL ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
207
		include_directories(${OPENCL_INCLUDE_DIRS})
Kirill Terekhov's avatar
Kirill Terekhov committed
208
		link_directories(${PETSC_LIBRARY_DIRS})
Kirill Terekhov's avatar
Kirill Terekhov committed
209
	else()
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
210
		set(USE_AUTODIFF_OPENCL OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
211
212
213
214
215
		message("OpenCL not found")
	endif()
endif()

if(USE_AUTODIFF_ASMJIT)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
216
	set(ASMJIT_STATIC TRUE)
Kirill Terekhov's avatar
Kirill Terekhov committed
217
218
219
220
221
222
223
224
225
226
227
228
	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
229
230
231
232
233
234
235
236
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
237
configure_file("Source/Headers/inmost_options_cmake.h" "${PROJECT_BINARY_DIR}/inmost_options.h")
Kirill Terekhov's avatar
Kirill Terekhov committed
238
239
include_directories("${PROJECT_BINARY_DIR}")

Kirill Terekhov's avatar
Kirill Terekhov committed
240
241
242
243
target_include_directories(inmost PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_include_directories(inmost PUBLIC $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>)
target_include_directories(inmost PUBLIC $<INSTALL_INTERFACE:include>)

Kirill Terekhov's avatar
Kirill Terekhov committed
244
if(COMPILE_EXAMPLES)
Kirill Terekhov's avatar
Kirill Terekhov committed
245
add_subdirectory(Examples)
Kirill Terekhov's avatar
Kirill Terekhov committed
246
247
248
249
endif(COMPILE_EXAMPLES)


if(COMPILE_TESTS)
Kirill Terekhov's avatar
Kirill Terekhov committed
250
251
enable_testing()
include(CTest)
Kirill Terekhov's avatar
Kirill Terekhov committed
252
add_subdirectory(Tests)
Kirill Terekhov's avatar
Kirill Terekhov committed
253
254
endif(COMPILE_TESTS)

Kirill Terekhov's avatar
Kirill Terekhov committed
255

Kirill Terekhov's avatar
Kirill Terekhov committed
256
257
258
259
set(INMOST_INSTALL_HEADERS Source/Headers/inmost.h
                           Source/Headers/inmost_autodiff.h
                           Source/Headers/inmost_common.h
                           Source/Headers/inmost_data.h
260
                           Source/Headers/inmost_dense.h
Kirill Terekhov's avatar
Kirill Terekhov committed
261
262
263
264
265
                           Source/Headers/inmost_expression.h
                           Source/Headers/inmost_mesh.h
                           Source/Headers/inmost_nonlinear.h
                           Source/Headers/inmost_partitioner.h
                           Source/Headers/inmost_solver.h
Dmitry Bagaev's avatar
Dmitry Bagaev committed
266
						   Source/Headers/inmost_solver_interface.h
Kirill Terekhov's avatar
Kirill Terekhov committed
267
                           Source/Headers/inmost_sparse.h
268
                           Source/Headers/inmost_xml.h
Dmitry Bagaev's avatar
Dmitry Bagaev committed
269
		 				   Source/Headers/inmost_utils.h
Kirill Terekhov's avatar
Kirill Terekhov committed
270
271
272
273
                           Source/Headers/inmost_variable.h
                           Source/Headers/container.hpp)


Kirill Terekhov's avatar
Kirill Terekhov committed
274
275
276
277

include(CPack)
export(TARGETS inmost FILE inmost-targets.cmake)
export(PACKAGE inmost)
Kirill Terekhov's avatar
Kirill Terekhov committed
278
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/Source/Headers" "${PROJECT_BINARY_DIR}")
Kirill Terekhov's avatar
Kirill Terekhov committed
279
configure_file(inmost-config.cmake.in "${PROJECT_BINARY_DIR}/inmost-config.cmake" @ONLY)
Kirill Terekhov's avatar
Kirill Terekhov committed
280
set(CONF_INCLUDE_DIRS "\${inmost_DIR}/include")
Kirill Terekhov's avatar
Kirill Terekhov committed
281
282
283
284
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)


Kirill Terekhov's avatar
Kirill Terekhov committed
285

Kirill Terekhov's avatar
Kirill Terekhov committed
286
287
set_property(TARGET inmost PROPERTY PUBLIC_HEADER
	"${PROJECT_BINARY_DIR}/inmost_options.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
288
289
290
291
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_autodiff.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_common.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_data.h"
292
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_dense.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
293
294
295
296
297
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_expression.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_mesh.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_nonlinear.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_partitioner.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_solver.h"
Dmitry Bagaev's avatar
Dmitry Bagaev committed
298
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_solver_interface.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
299
300
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_sparse.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_variable.h"
301
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_xml.h"
Dmitry Bagaev's avatar
Dmitry Bagaev committed
302
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_utils.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
303
	"${PROJECT_SOURCE_DIR}/Source/Headers/container.hpp")
Kirill Terekhov's avatar
Kirill Terekhov committed
304
305
306
307
308
309
310
311

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
312
313
314
	LIBRARY DESTINATION lib
	RUNTIME DESTINATION bin
	PUBLIC_HEADER DESTINATION include)
Kirill Terekhov's avatar
Kirill Terekhov committed
315
316


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