CMakeLists.txt 23.7 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

ptomin's avatar
ptomin committed
4

Kirill Terekhov's avatar
Kirill Terekhov committed
5
include_directories("Source/Headers")
Kirill Terekhov's avatar
Kirill Terekhov committed
6

Kirill Terekhov's avatar
Kirill Terekhov committed
7
set(INMOST_MAJOR_VERSION 0)
8
set(INMOST_MINOR_VERSION 3)
Kirill Terekhov's avatar
Kirill Terekhov committed
9
10
set(INMOST_PATCH_VERSION 0)
set(INMOST_VERSION "${INMOST_MAJOR_VERSION}.${INMOST_MINOR_VERSION}.${INMOST_PATCH_VERSION}")
Kirill Terekhov's avatar
Kirill Terekhov committed
11

12

Kirill Terekhov's avatar
Kirill Terekhov committed
13
14

option(USE_MPI "Compile with MPI support" ON)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
15
16
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
17
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
18
option(USE_OMP "Compile with OpenMP support (experimental)" OFF)
19
option(USE_OPENCL "Use OpenCL where possible (experimental)" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
20

21
22
23
option(USE_INT64 "Use 64-bit integer types (use for large problems)" OFF)
option(USE_FP64 "Use 64-bit floating-point types (usually on)" ON)

Kirill Terekhov's avatar
Kirill Terekhov committed
24
25
26
27
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
28
option(USE_NONLINEAR "Compile nonlinear solver capabilities" ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
29
30
31
32
33
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)
34
option(USE_PARTITIONER_PARMETIS_DOWNLOAD "Attempts to download ParMetis if library not found" OFF)
35
option(USE_PARTITIONER_METIS "Use METIS partitioner" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
36
option(USE_PARTITIONER_ZOLTAN "Use Zoltan partitioner" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
37
option(USE_SOLVER_METIS "Use METIS for matrix reordering" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
38
option(USE_SOLVER_MONDRIAAN "Use Mondriaan for matrix reordering" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
39
40
option(USE_SOLVER_PETSC "Use PETSc solvers" OFF)
option(USE_SOLVER_TRILINOS "Use Trilinos solvers" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
41
option(USE_SOLVER_SUPERLU "Use SuperLU solver" OFF)
42
option(USE_SOLVER_SUPERLU_DOWNLOAD "Attempts to download SuperLU solver if library not found" OFF)
43
44
option(USE_SOLVER_K3BIILU2 "Activate K3BIILU2 solver (requires USE_MPI and USE_SOLVER_METIS)")
option(USE_SOLVER_FCBIILU2 "Activate FCBIILU2 solver (requires fcbiilu2.cpp)")
Dmitry Bagaev's avatar
Dmitry Bagaev committed
45
46
option(USE_OPTIMIZER "Use Optimization toolkit" OFF)
option(USE_OPTIMIZER_BAYESIAN "Compile Optimization module against Limbo library to provide Bayesian optimization algorithm" OFF)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
47
48
#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
49

50
51
set(LIB_DOWNLOAD_PATH "${CMAKE_BINARY_DIR}/Libraries/download")

52
53
if( MSVC )
option(USE_MT "Use /MT switch instead of /MD switch for libraries generated with Visual Studio" OFF)
Pavel Tomin's avatar
Pavel Tomin committed
54
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
55
56
endif( MSVC )

ptomin's avatar
ptomin committed
57
add_subdirectory(Source)
Kirill Terekhov's avatar
Kirill Terekhov committed
58
59
add_definitions(${SOLVER_DEFINITIONS})

ptomin's avatar
ptomin committed
60
61
add_library(inmost STATIC ${SOURCE} ${HEADER})

Kirill Terekhov's avatar
Kirill Terekhov committed
62
63
64
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_find/")


65
66
67
68
69
70
71
if( USE_MT )
set(CompilerFlags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE)
foreach(CompilerFlag ${CompilerFlags}) 
	string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif( USE_MT )

Kirill Terekhov's avatar
Kirill Terekhov committed
72
if(TEST_FORTRAN_ANI3D)
73
74
75
76
77
	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
78
79
		option(USE_SOLVER_ANI "Compile with ANI3D sequential solvers" OFF)
	else()
80
81
		enable_language(Fortran)
		add_subdirectory(ILU2)
Kirill Terekhov's avatar
Kirill Terekhov committed
82
83
		option(USE_SOLVER_ANI "Compile with ANI3D sequential solvers" ON)
	endif()
84

Kirill Terekhov's avatar
Kirill Terekhov committed
85
86
endif()

Dmitry Bagaev's avatar
Dmitry Bagaev committed
87
if(USE_OPTIMIZER_BAYESIAN)
Dmitry Bagaev's avatar
Dmitry Bagaev committed
88
89
90
91
92
93
	include_directories(/Users/bvdmitri/Projects/CXX/limbo/src)
	target_link_libraries(inmost /Users/bvdmitri/Projects/CXX/limbo/build/src/liblimbo.a)

	find_package(Eigen3 REQUIRED)
	include_directories(${EIGEN3_INCLUDE_DIR})

Dmitry Bagaev's avatar
Dmitry Bagaev committed
94
95
96
	find_package(NLOPT)
	include_directories(${NLOPT_INCLUDE_DIRS})
	target_link_libraries(inmost ${NLOPT_LIBRARIES})
Dmitry Bagaev's avatar
Dmitry Bagaev committed
97
98
99
100
101

	find_package(boost REQUIRED)
	include_directories(${Boost_INCLUDE_DIRS})
	target_link_libraries(inmost ${Boost_LIBRARIES})
endif()
Kirill Terekhov's avatar
Kirill Terekhov committed
102
103
104
105

if(USE_MPI)
	find_package(MPI)
	if(NOT MPI_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
106
		set(USE_MPI OFF CACHE BOOL "Compile with MPI support" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
107
108
109
110
111
112
113
114
115
116
117
118
119
		message("MPI NOT FOUND")
	else()
		include_directories(${MPI_INCLUDE_PATH})
		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
120
		message("OpenMP FOUND")
Kirill Terekhov's avatar
Kirill Terekhov committed
121
	else()
Kirill Terekhov's avatar
Kirill Terekhov committed
122
		set(USE_OMP OFF CACHE BOOL "Compile with OpenMP support" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
123
		message("OpenMP NOT FOUND")
Kirill Terekhov's avatar
Kirill Terekhov committed
124
125
126
127
128
129
	endif()
endif()

if(USE_PARTITIONER_PARMETIS)
	find_package(ParMETIS)
	if(NOT PARMETIS_FOUND)
130
		#set(USE_PARTITIONER_PARMETIS OFF CACHE BOOL "Use ParMetis partitioner" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
131
		message("PARMETIS NOT FOUND")
132
133
134
135
136
137
138
139
140
141
142
143

		if( USE_PARTITIONER_PARMETIS_DOWNLOAD )
			include(ExternalProject)
			message("-- Download ParMetis")
			string (REPLACE ";" "|" PASS_MPI "${MPI_INCLUDE_PATH}")
			message("-- Passing MPI include to ParMETIS: '${PASS_MPI}'")
			
			ExternalProject_Add(ParMETIS
								#This one is not good
								#GIT_REPOSITORY "https://github.com/ibaned/parmetis.git"
								GIT_REPOSITORY "https://github.com/scibuilder/parmetis.git"
								GIT_TAG "master"
Kirill Terekhov's avatar
Kirill Terekhov committed
144
145
								UPDATE_DISCONNECTED 1 
								#${EXTERNAL_NOUPDATE}
146
147
148
149
150
151
152
153
154
155
156
157
								PREFIX "${LIB_DOWNLOAD_PATH}"
								#this command is responsible for update of repository from git
								#UPDATE_COMMAND ""
								LIST_SEPARATOR | # Use the alternate list separator
								#for the one from ibaned
								#CMAKE_ARGS "-DMPI_INCLUDE_PATH:PATH='${PASS_MPI}'"
								CMAKE_ARGS  "-DDISABLE_PARMETIS_PROGRAMS:BOOL=TRUE "
											"-DCMAKE_INSTALL_PREFIX=${LIB_DOWNLOAD_PATH} "
											"-DCMAKE_BUILD_TYPE=Release "
											"-DMPI_C_COMPILER=${MPI_C_COMPILER} "
											"-DMPI_CXX_COMPILER=${MPI_CXX_COMPILER} "
											"-DCMAKE_POSITION_INDEPENDENT_CODE=ON "
158
159
											"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} "
											"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} "
160
								)
161
			add_dependencies(inmost ParMETIS)
Igor Konshin's avatar
Igor Konshin committed
162
163
			set(PARMETIS_INCLUDE_DIR "${LIB_DOWNLOAD_PATH}/include" CACHE PATH "PARMETIS_INCLUDE_DIR is set" FORCE)
			set(METIS_INCLUDE_DIR    "${LIB_DOWNLOAD_PATH}/include" CACHE PATH "METIS_INCLUDE_DIR is set" FORCE)
164
165
			if( WIN32 )
				set(PARMETIS_LIBRARIES "${LIB_DOWNLOAD_PATH}/lib/parmetis.lib;${LIB_DOWNLOAD_PATH}/lib/metis.lib")
Igor Konshin's avatar
Igor Konshin committed
166
				set(METIS_LIBRARIES    "${LIB_DOWNLOAD_PATH}/lib/metis.lib")
167
			else( WIN32 )
Igor Konshin's avatar
Igor Konshin committed
168
169
				set(PARMETIS_LIBRARIES "${LIB_DOWNLOAD_PATH}/lib/libparmetis.a;${LIB_DOWNLOAD_PATH}/lib/libmetis.a" CACHE PATH "PARMETIS_LIBRARIES is set" FORCE)
				set(METIS_LIBRARIES    "${LIB_DOWNLOAD_PATH}/lib/libmetis.a" CACHE PATH "METIS_LIBRARIES is set" FORCE)
170
171
			endif( WIN32 )
			message("-- PARMETIS_INCLUDE_DIR: ${PARMETIS_INCLUDE_DIR}")
Igor Konshin's avatar
Igor Konshin committed
172
173
174
			message("-- PARMETIS_LIBRARIES:   ${PARMETIS_LIBRARIES}")
			message("-- METIS_INCLUDE_DIR:    ${METIS_INCLUDE_DIR}")
			message("-- METIS_LIBRARIES:      ${METIS_LIBRARIES}")
175
176
			include_directories(${PARMETIS_INCLUDE_DIR})
			include_directories(${METIS_INCLUDE_DIR})
177
			set(USE_PARTITIONER_METIS ON CACHE BOOL "Use METIS partitioner" FORCE)
178
179
180
		else(USE_PARTITIONER_PARMETIS_DOWNLOAD)
			set(USE_PARTITIONER_PARMETIS OFF CACHE BOOL "Use ParMetis partitioner" FORCE)
		endif(USE_PARTITIONER_PARMETIS_DOWNLOAD)
Kirill Terekhov's avatar
Kirill Terekhov committed
181
182
	else()
		include_directories(${PARMETIS_INCLUDE_DIR})
Kirill Terekhov's avatar
Kirill Terekhov committed
183
		include_directories(${METIS_INCLUDE_DIR})
Kirill Terekhov's avatar
Kirill Terekhov committed
184
185
186
187
		message("PARMETIS FOUND")
	endif()
endif()

188
189
190
191
192
193
194
195
196
197
198
if(USE_PARTITIONER_METIS)
	find_package(METIS)
	if(NOT METIS_FOUND)
		set(USE_SOLVER_METIS OFF CACHE BOOL "Use METIS partitioner" FORCE)
		message("METIS NOT FOUND")
	else()
		include_directories(${METIS_INCLUDE_DIR})
		message("METIS FOUND")
	endif()
endif()

Kirill Terekhov's avatar
Kirill Terekhov committed
199
200
201
if(USE_SOLVER_METIS)
	find_package(METIS)
	if(NOT METIS_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
202
		set(USE_SOLVER_METIS OFF CACHE BOOL "Use METIS for matrix reordering" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
203
204
205
206
207
208
		message("METIS NOT FOUND")
	else()
		include_directories(${METIS_INCLUDE_DIR})
		message("METIS FOUND")
	endif()
endif()
Kirill Terekhov's avatar
Kirill Terekhov committed
209

Kirill Terekhov's avatar
Kirill Terekhov committed
210
211
212
if(USE_SOLVER_MONDRIAAN)
	find_package(MONDRIAAN)
	if(NOT MONDRIAAN_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
213
		set(USE_SOLVER_MONDRIAAN OFF CACHE BOOL "Use Mondriaan for matrix reordering" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
214
215
216
217
218
219
220
221
222
		message("Mondriaan NOT FOUND")
	else()
		link_directories(${MONDRIAAN_LIBRARY_DIRS})
		include_directories(${MONDRIAAN_INCLUDE_DIRS})
		message("Mondriaan FOUND")
	endif()
endif()


Kirill Terekhov's avatar
Kirill Terekhov committed
223
224
225
if(USE_PARTITIONER_ZOLTAN)
	find_package(ZOLTAN)
	if(NOT ZOLTAN_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
226
		set(USE_PARTITIONER_ZOLTAN OFF CACHE BOOL "Use Zoltan partitioner" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
227
228
		message("ZOLTAN NOT FOUND")
	else()
Kirill Terekhov's avatar
Kirill Terekhov committed
229
		#include_directories(${ZOLTAN_INCLUDE_DIR})
Kirill Terekhov's avatar
Kirill Terekhov committed
230
231
232
233
234
235
236
237
		include_directories(${ZOLTAN_INCLUDE_DIRS})
		message("ZOLTAN FOUND")
	endif()
endif()

if(USE_SOLVER_PETSC)
	find_package(PETSc)
	if(NOT PETSC_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
238
		set(USE_SOLVER_PETSC OFF CACHE BOOL "Use PETSc solvers" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
239
240
241
242
243
244
245
246
247
248
		message("PETSC NOT FOUND")
	else()
		include_directories(${PETSC_INCLUDES})
		message("PETSC FOUND")
		add_definitions(${PETSC_DEFINITIONS})
		#message(${PETSC_LIBRARIES})
	endif()
endif()


Kirill Terekhov's avatar
Kirill Terekhov committed
249
250
251
252
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)
Kirill Terekhov's avatar
Kirill Terekhov committed
253
		set(USE_SOLVER_TRILINOS OFF CACHE BOOL "Use Trilinos solvers" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
		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})


		message("Trilinos FOUND")
	endif()
endif()


Kirill Terekhov's avatar
Kirill Terekhov committed
282
if(USE_SOLVER_SUPERLU)
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
	find_package(LAPACK)
	if( NOT LAPACK_FOUND )
		message("-- Download LAPACK")
		ExternalProject_Add(LAPACK
							URL "https://www.netlib.org/clapack/clapack-3.2.1-CMAKE.tgz"
							UPDATE_DISCONNECTED 1
							PREFIX "${LIB_DOWNLOAD_PATH}"
							INSTALL_COMMAND true
							CMAKE_ARGS #"-DCMAKE_INSTALL_PREFIX=${LIB_DOWNLOAD_PATH} " #no install script!
									   "-DMPI_C_COMPILER=${MPI_C_COMPILER} "
									   "-DMPI_CXX_COMPILER=${MPI_CXX_COMPILER} "
									   "-DCMAKE_BUILD_TYPE=Release ")
		if( WIN32 )
			set(LAPACK_LIBRARIES "${LIB_DOWNLOAD_PATH}/src/LAPACK-build/SRC/lapack.lib" CACHE PATH "LAPACK_LIBRARIES is set" FORCE)
			set(BLAS_LIBRARIES "${LIB_DOWNLOAD_PATH}/src/LAPACK-build/BLAS/SRC/blas.lib;${LIB_DOWNLOAD_PATH}/src/LAPACK-build/F2CLIBS/libf2c/f2c.lib" CACHE PATH "LAPACK_LIBRARIES is set" FORCE)
		else( WIN32 )
			set(LAPACK_LIBRARIES "${LIB_DOWNLOAD_PATH}/src/LAPACK-build/SRC/liblapack.a" CACHE PATH "LAPACK_LIBRARIES is set" FORCE)
			set(BLAS_LIBRARIES "${LIB_DOWNLOAD_PATH}/src/LAPACK-build/BLAS/SRC/libblas.a;${LIB_DOWNLOAD_PATH}/src/LAPACK-build/F2CLIBS/libf2c/libf2c.a" CACHE PATH "LAPACK_LIBRARIES is set" FORCE)
		endif( WIN32 )
Kirill Terekhov's avatar
Kirill Terekhov committed
302
	endif()
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
	string (REPLACE ";" "|" PASS_LAPACK_LIBRARIES "${LAPACK_LIBRARIES}")
	string (REPLACE ";" "|" PASS_BLAS_LIBRARIES "${BLAS_LIBRARIES}")
	
	if( NOT USE_MPI )
		find_package(SUPERLU)
		if(NOT SUPERLU_FOUND)
			#set(USE_SOLVER_SUPERLU OFF CACHE BOOL "Use SuperLU solver" FORCE)
			MESSAGE("SUPERLU NOT FOUND")
			if( USE_SOLVER_SUPERLU_DOWNLOAD )
				
				include(ExternalProject)
				message("-- Download SUPERLU")
				#string (REPLACE ";" "|" PASS_MPI "${MPI_INCLUDE_PATH}")
				#message("-- Passing MPI include to ParMETIS: '${PASS_MPI}'")
				
				ExternalProject_Add(SUPERLU
									GIT_REPOSITORY "https://github.com/xiaoyeli/superlu.git"
320
									GIT_TAG "master"
321
322
									UPDATE_DISCONNECTED 1 
									#${EXTERNAL_NOUPDATE}
323
324
325
326
									PREFIX "${LIB_DOWNLOAD_PATH}"
									#this command is responsible for update of repository from git
									#UPDATE_COMMAND ""
									LIST_SEPARATOR | # Use the alternate list separator
327
328
329
330
331
									#for the one from ibaned
									#CMAKE_ARGS "-DMPI_INCLUDE_PATH:PATH='${PASS_MPI}'"
									CMAKE_ARGS  		"-DCMAKE_INSTALL_PREFIX=${LIB_DOWNLOAD_PATH} "
												"-DCMAKE_INSTALL_INCLUDEDIR=${LIB_DOWNLOAD_PATH}/include/superlu "
												"-DBLAS_LIBRARIES=${PASS_BLAS_LIBRARIES} " #should come from find_pacakge(LAPACK)
332
333
334
335
												"-DCMAKE_BUILD_TYPE=Release "
												"-DMPI_C_COMPILER=${MPI_C_COMPILER} "
												"-DMPI_CXX_COMPILER=${MPI_CXX_COMPILER} "
												"-DCMAKE_POSITION_INDEPENDENT_CODE=ON "
336
337
												"-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} "
												"-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} "
338
									)
339
340
341
342
343
344
345
346
347
348
349
350
351
				#get internal blas
				#find_package(BLAS)
				#if (NOT BLAS_FOUND)
				#	if( WIN32 )
				#		set(BLAS_LIBRARIES "${LIB_DOWNLOAD_PATH}/src/SUPERLU-build/CBLAS/blas.lib" CACHE FILEPATH "BLAS_LIBRARIES" FORCE)
				#	else( WIN32 )
				#		set(BLAS_LIBRARIES "${LIB_DOWNLOAD_PATH}/src/SUPERLU-build/CBLAS/libblas.a" CACHE FILEPATH "BLAS_LIBRARIES" FORCE)
				#	endif( WIN32 )
				#endif()
				
				add_dependencies(inmost SUPERLU)

				set(SUPERLU_INCLUDES "${LIB_DOWNLOAD_PATH}/include" CACHE PATH "SUPERLU_INCLUDE_DIR is set" FORCE)
352
				if( WIN32 )
353
					set(SUPERLU_LIBRARIES "${LIB_DOWNLOAD_PATH}/lib/superlu.lib;${BLAS_LIBRARIES}" CACHE PATH "SUPERLU_LIBRARIES is set" FORCE)
354
				else( WIN32 )
355
356
357
					include(GNUInstallDirs)
					message("gnu install library dirs ${CMAKE_INSTALL_LIBDIR}")
					set(SUPERLU_LIBRARIES "${LIB_DOWNLOAD_PATH}/${CMAKE_INSTALL_LIBDIR}/libsuperlu.a;${BLAS_LIBRARIES}" CACHE PATH "SUPERLU_LIBRARIES is set" FORCE)
358
359
				endif( WIN32 )
				message("-- SUPERLU_INCLUDE_DIR: ${SUPERLU_INCLUDES}")
360
361
362
363
364
365
366
367
368
				message("-- SUPERLU_LIBRARIES:   ${SUPERLU_LIBRARIES}")
			else(USE_SOLVER_SUPERLU_DOWNLOAD)
				set(USE_SOLVER_SUPERLU OFF CACHE BOOL "Use SuperLU solver" FORCE)
			endif(USE_SOLVER_SUPERLU_DOWNLOAD)
		else()
			MESSAGE("\nFound SuperLU!  Here are the details: ")
			MESSAGE("INCLUDES:  ${SUPERLU_INCLUDES}")
			MESSAGE("LIBRARIES: ${SUPERLU_LIBRARIES}")
		endif()
369
	else()
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
		find_package(SUPERLU_DIST)
		if(NOT SUPERLU_DIST_FOUND)
			#set(USE_SOLVER_SUPERLU OFF CACHE BOOL "Use SuperLU solver" FORCE)
			MESSAGE("SUPERLU_DIST NOT FOUND")
			
			if( USE_SOLVER_SUPERLU_DOWNLOAD )
				if( USE_MPI AND USE_PARTITIONER_PARMETIS )
					message("-- Download SuperLU_DIST")
					set(C_STANDARD_FLAG "-std=c99")
					string (REPLACE ";" "|" PASS_PARMETIS_LIBRARIES "${PARMETIS_LIBRARIES}")
					message("-- Pass parmetis libraries ${PASS_PARMETIS_LIBRARIES} ")
					message("-- Pass lapack libraries ${PASS_LAPACK_LIBRARIES} ")
					message("-- Pass blas libraries ${PASS_BLAS_LIBRARIES} ")
					ExternalProject_Add(SuperLU_DIST
										GIT_REPOSITORY "https://github.com/xiaoyeli/superlu_dist.git"
										GIT_TAG "master"
										UPDATE_DISCONNECTED 1
										PREFIX "${LIB_DOWNLOAD_PATH}"
										#this command is responsible for update of repository from git
										#UPDATE_COMMAND ""
										LIST_SEPARATOR | # Use the alternate list separator
										CMAKE_ARGS  "-DTPL_PARMETIS_INCLUDE_DIRS=${PARMETIS_INCLUDE_DIR} "
													"-DTPL_PARMETIS_LIBRARIES=${PASS_PARMETIS_LIBRARIES} "
													"-DTPL_LAPACK_LIBRARIES=${PASS_LAPACK_LIBRARIES} "
394
													"-DBLAS_LIBRARIES=${PASS_BLAS_LIBRARIES} "
395
396
397
398
													"-Denable_examples=OFF "
													"-Denable_tests=OFF "
													"-Denable_doc=OFF "
													"-DCMAKE_INSTALL_PREFIX=${LIB_DOWNLOAD_PATH} "
399
400
401
402
403
													"-DUSE_XSDK_DEFAULTS=OFF "
													"-DUSE_XSDK_DEFAULTS_DEFAULT=OFF "
													"-DXSDK_ENABLE_Fortran=OFF "
													"-DNOFORTRAN=ON "
													"-DCMAKE_C_FLAGS='-DMETIS_EXPORT=' "
404
405
406
407
													"-DCMAKE_CXX_FLAGS='-DMETIS_EXPORT=' "
													"-DCMAKE_BUILD_TYPE=Release "
													"-DMPI_C_COMPILER=${MPI_C_COMPILER} "
													"-DMPI_CXX_COMPILER=${MPI_CXX_COMPILER} "
408
													"-DCMAKE_DISABLE_FIND_PACKAGE_OpenMP=ON "
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
													"-DCMAKE_POSITION_INDEPENDENT_CODE=ON "
										)

					message("-- Linking SuperLU_dist and ParMETIS")
					if( NOT LAPACK_FOUND )
						add_dependencies(SuperLU_DIST LAPACK)
					endif()
					add_dependencies(SuperLU_DIST ParMETIS)
					add_dependencies(inmost SuperLU_DIST)
					add_definitions(-DUSE_SOLVER_SUPERLU_DIST)
					#same as above
					#set(SUPERLU_INCLUDES "${LIB_DOWNLOAD_PATH}/include" CACHE PATH "SUPERLU_INCLUDE_DIR is set" FORCE)
					#extended
					#TODO: properly install lapack
					if( WIN32 )
						set(SUPERLU_LIBRARIES "${SUPERLU_LIBRARIES};${METIS_LIBRARIES};${LIB_DOWNLOAD_PATH}/lib/superlu_dist.lib;${LAPACK_LIBRARIES};${BLAS_LIBRARIES};${PARMETIS_LIBRARIES}" CACHE PATH "SUPERLU_LIBRARIES is set" FORCE)
					else( WIN32 )
426
427
428
						include(GNUInstallDirs)
						message("gnu install library dirs ${CMAKE_INSTALL_LIBDIR}")
						set(SUPERLU_LIBRARIES "${SUPERLU_LIBRARIES};${METIS_LIBRARIES};${LIB_DOWNLOAD_PATH}/${CMAKE_INSTALL_LIBDIR}/libsuperlu_dist.a;${LAPACK_LIBRARIES};${BLAS_LIBRARIES};${PARMETIS_LIBRARIES}" CACHE PATH "SUPERLU_LIBRARIES is set" FORCE)
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
					endif( WIN32 )
					message("-- SUPERLU_INCLUDE_DIR: ${SUPERLU_INCLUDES}")
					message("-- SUPERLU_LIBRARIES:   ${SUPERLU_LIBRARIES}")					
				else()
					message("-- Skip SuperLU_DIST as either USE_MPI or USE_PARTITIONER_PARMETIS are not checked for compilation")
				endif()
				
				
			else(USE_SOLVER_SUPERLU_DOWNLOAD)
				set(USE_SOLVER_SUPERLU OFF CACHE BOOL "Use SuperLU solver" FORCE)
			endif(USE_SOLVER_SUPERLU_DOWNLOAD)
		else()
			MESSAGE("\nFound SuperLU_DIST!  Here are the details: ")
			set(SUPERLU_INCLUDES "${SUPERLU_INCLUDES};${SUPERLU_DIST_INCLUDES}")
			set(SUPERLU_LIBRARIES "${SUPERLU_LIBRARIES};${SUPERLU_DIST_LIBRARIES}")
			MESSAGE("INCLUDES:  ${SUPERLU_INCLUDES}")
			MESSAGE("LIBRARIES: ${SUPERLU_LIBRARIES}")
		endif()
	endif()
	if( USE_SOLVER_SUPERLU )
		include_directories(${SUPERLU_INCLUDES})
450
	endif()
Kirill Terekhov's avatar
Kirill Terekhov committed
451
452
endif()

453
if(USE_OPENCL)
Kirill Terekhov's avatar
Kirill Terekhov committed
454
455
456
	find_package(OpenCL)
	if(OPENCL_FOUND)
		include_directories(${OPENCL_INCLUDE_DIRS})
457
		link_directories(${OpenCL_LIBRARY})
Kirill Terekhov's avatar
Kirill Terekhov committed
458
	else()
459
		set(USE_OPENCL OFF CACHE BOOL "Use OpenCL where possible (experimental)" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
460
461
462
463
464
		message("OpenCL not found")
	endif()
endif()

if(USE_AUTODIFF_ASMJIT)
Kirill Terekhov's avatar
Fixes    
Kirill Terekhov committed
465
	set(ASMJIT_STATIC TRUE)
Kirill Terekhov's avatar
Kirill Terekhov committed
466
467
468
469
470
471
472
473
474
475
476
	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()

477
478
479
480
481
if(MSVC)
	message("Adding flag for exception handling in Visual Studio that is sometimes missing for some reason")
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
endif()

Kirill Terekhov's avatar
Kirill Terekhov committed
482

Kirill Terekhov's avatar
Kirill Terekhov committed
483
484
485
486
487
488
489
490
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
491
configure_file("Source/Headers/inmost_options_cmake.h" "${PROJECT_BINARY_DIR}/inmost_options.h")
Kirill Terekhov's avatar
Kirill Terekhov committed
492
493
include_directories("${PROJECT_BINARY_DIR}")

Kirill Terekhov's avatar
Kirill Terekhov committed
494
495
496
497
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
498
if(COMPILE_EXAMPLES)
Kirill Terekhov's avatar
Kirill Terekhov committed
499
add_subdirectory(Examples)
Kirill Terekhov's avatar
Kirill Terekhov committed
500
501
502
503
endif(COMPILE_EXAMPLES)


if(COMPILE_TESTS)
Kirill Terekhov's avatar
Kirill Terekhov committed
504
505
enable_testing()
include(CTest)
Kirill Terekhov's avatar
Kirill Terekhov committed
506
add_subdirectory(Tests)
Kirill Terekhov's avatar
Kirill Terekhov committed
507
508
endif(COMPILE_TESTS)

Kirill Terekhov's avatar
Kirill Terekhov committed
509

Kirill Terekhov's avatar
Kirill Terekhov committed
510
511
set(INMOST_INSTALL_HEADERS Source/Headers/inmost.h
                           Source/Headers/inmost_autodiff.h
512
513
514
                           Source/Headers/inmost_residual.h
                           Source/Headers/inmost_model.h
                           Source/Headers/inmost_operator.h
Kirill Terekhov's avatar
Kirill Terekhov committed
515
516
                           Source/Headers/inmost_common.h
                           Source/Headers/inmost_data.h
517
                           Source/Headers/inmost_dense.h
Kirill Terekhov's avatar
Kirill Terekhov committed
518
519
520
521
522
523
                           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
                           Source/Headers/inmost_sparse.h
524
                           Source/Headers/inmost_xml.h
Kirill Terekhov's avatar
Kirill Terekhov committed
525
                           Source/Headers/inmost_variable.h
526
                           Source/Headers/inmost_block_variable.h
Dmitry Bagaev's avatar
Dmitry Bagaev committed
527
		Source/Headers/inmost_optimizer.h
Kirill Terekhov's avatar
Kirill Terekhov committed
528
529
                           Source/Headers/container.hpp)

530
531
532
533
#if( COMPILE_EXAMPLES )
#list(APPEND INMOST_INSTALL_HEADERS "${PROJECT_SOURCE_DIR}/Examples/AdaptiveMesh/amesh.h")
#message(${INMOST_INSTALL_HEADERS})
#endif( COMPILE_EXAMPLES )
Kirill Terekhov's avatar
Kirill Terekhov committed
534
535
536
537

include(CPack)
export(TARGETS inmost FILE inmost-targets.cmake)
export(PACKAGE inmost)
Kirill Terekhov's avatar
Kirill Terekhov committed
538
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/Source/Headers" "${PROJECT_BINARY_DIR}")
539
540
541
542
543
544
545
set(CONF_LIBRARY_DIRS "")
if( COMPILE_EXAMPLES )
list(APPEND CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/Examples/AdaptiveMesh")
list(APPEND CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/Examples/GridTools")
list(APPEND CONF_LIBRARY_DIRS "${PROJECT_BINARY_DIR}/Examples/AdaptiveMesh")
list(APPEND CONF_LIBRARY_DIRS "${PROJECT_BINARY_DIR}/Examples/GridTools")
endif( COMPILE_EXAMPLES )
Kirill Terekhov's avatar
Kirill Terekhov committed
546
configure_file(inmost-config.cmake.in "${PROJECT_BINARY_DIR}/inmost-config.cmake" @ONLY)
Kirill Terekhov's avatar
Kirill Terekhov committed
547
set(CONF_INCLUDE_DIRS "\${inmost_DIR}/include")
548
set(CONF_LIBRARY_DIRS "\$")
Kirill Terekhov's avatar
Kirill Terekhov committed
549
550
551
552
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
553

Kirill Terekhov's avatar
Kirill Terekhov committed
554
555
set_property(TARGET inmost PROPERTY PUBLIC_HEADER
	"${PROJECT_BINARY_DIR}/inmost_options.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
556
557
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_autodiff.h"
558
559
560
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_residual.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_operator.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_model.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
561
562
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_common.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_data.h"
563
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_dense.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
564
565
566
567
568
569
570
	"${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"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_sparse.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_variable.h"
571
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_block_variable.h"
572
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_xml.h"
Dmitry Bagaev's avatar
Dmitry Bagaev committed
573
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_optimizer.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
574
	"${PROJECT_SOURCE_DIR}/Source/Headers/container.hpp")
Kirill Terekhov's avatar
Kirill Terekhov committed
575

576
577
578
579
580
581
#if( COMPILE_EXAMPLES )
#set_property(TARGET inmost APPEND PROPERTY PUBLIC_HEADER "${PROJECT_SOURCE_DIR}/Examples/AdaptiveMesh/amesh.h")
#get_property(PRINT_PUBLIC_HEADER TARGET inmost PROPERTY PUBLIC_HEADER)
#message(${PRINT_PUBLIC_HEADER})
#endif( COMPILE_EXAMPLES )

Kirill Terekhov's avatar
Kirill Terekhov committed
582
583
584
585
586
587
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
Igor Konshin's avatar
Igor Konshin committed
588
	ARCHIVE DESTINATION lib
Kirill Terekhov's avatar
Kirill Terekhov committed
589
590
591
	LIBRARY DESTINATION lib
	RUNTIME DESTINATION bin
	PUBLIC_HEADER DESTINATION include)
Kirill Terekhov's avatar
Kirill Terekhov committed
592
593


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