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

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

7 8 9 10
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
11

12

Kirill Terekhov's avatar
Kirill Terekhov committed
13 14

option(USE_MPI "Compile with MPI support" ON)
Kirill Terekhov's avatar
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
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 24

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
25
option(USE_NONLINEAR "Compile nonlinear solver capabilities" ON)
Kirill Terekhov's avatar
Kirill Terekhov committed
26 27 28 29 30 31
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
32
option(USE_SOLVER_METIS "Use METIS for matrix reordering" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
33
option(USE_SOLVER_MONDRIAAN "Use Mondriaan for matrix reordering" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
34 35
option(USE_SOLVER_PETSC "Use PETSc solvers" OFF)
option(USE_SOLVER_TRILINOS "Use Trilinos solvers" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
36
option(USE_SOLVER_SUPERLU "Use SuperLU solver" OFF)
Kirill Terekhov's avatar
Kirill Terekhov committed
37 38
#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
39

40 41
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
42
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
43 44
endif( MSVC )

45
add_subdirectory(Source)
46 47
add_definitions(${SOLVER_DEFINITIONS})

48 49
add_library(inmost STATIC ${SOURCE} ${HEADER})

Kirill Terekhov's avatar
Kirill Terekhov committed
50 51 52
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_find/")


53 54 55 56 57 58 59
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
60
if(TEST_FORTRAN_ANI3D)
61 62 63 64 65
	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
66 67
		option(USE_SOLVER_ANI "Compile with ANI3D sequential solvers" OFF)
	else()
68 69
		enable_language(Fortran)
		add_subdirectory(ILU2)
Kirill Terekhov's avatar
Kirill Terekhov committed
70 71
		option(USE_SOLVER_ANI "Compile with ANI3D sequential solvers" ON)
	endif()
72

Kirill Terekhov's avatar
Kirill Terekhov committed
73 74 75 76 77 78
endif()


if(USE_MPI)
	find_package(MPI)
	if(NOT MPI_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
79
		set(USE_MPI OFF CACHE BOOL "Compile with MPI support" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
80 81 82 83 84 85 86 87 88 89 90 91 92
		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
93
		message("OpenMP FOUND")
Kirill Terekhov's avatar
Kirill Terekhov committed
94
	else()
Kirill Terekhov's avatar
Kirill Terekhov committed
95
		set(USE_OMP OFF CACHE BOOL "Compile with OpenMP support" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
96
		message("OpenMP NOT FOUND")
Kirill Terekhov's avatar
Kirill Terekhov committed
97 98 99 100 101 102
	endif()
endif()

if(USE_PARTITIONER_PARMETIS)
	find_package(ParMETIS)
	if(NOT PARMETIS_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
103
		set(USE_PARTITIONER_PARMETIS OFF CACHE BOOL "Use ParMetis partitioner" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
104 105 106
		message("PARMETIS NOT FOUND")
	else()
		include_directories(${PARMETIS_INCLUDE_DIR})
Kirill Terekhov's avatar
Kirill Terekhov committed
107
		include_directories(${METIS_INCLUDE_DIR})
Kirill Terekhov's avatar
Kirill Terekhov committed
108 109 110 111
		message("PARMETIS FOUND")
	endif()
endif()

Kirill Terekhov's avatar
Kirill Terekhov committed
112 113 114
if(USE_SOLVER_METIS)
	find_package(METIS)
	if(NOT METIS_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
115
		set(USE_SOLVER_METIS OFF CACHE BOOL "Use METIS for matrix reordering" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
116 117 118 119 120 121
		message("METIS NOT FOUND")
	else()
		include_directories(${METIS_INCLUDE_DIR})
		message("METIS FOUND")
	endif()
endif()
Kirill Terekhov's avatar
Kirill Terekhov committed
122

Kirill Terekhov's avatar
Kirill Terekhov committed
123 124 125
if(USE_SOLVER_MONDRIAAN)
	find_package(MONDRIAAN)
	if(NOT MONDRIAAN_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
126
		set(USE_SOLVER_MONDRIAAN OFF CACHE BOOL "Use Mondriaan for matrix reordering" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
127 128 129 130 131 132 133 134 135
		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
136 137 138
if(USE_PARTITIONER_ZOLTAN)
	find_package(ZOLTAN)
	if(NOT ZOLTAN_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
139
		set(USE_PARTITIONER_ZOLTAN OFF CACHE BOOL "Use Zoltan partitioner" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
140 141
		message("ZOLTAN NOT FOUND")
	else()
142
		#include_directories(${ZOLTAN_INCLUDE_DIR})
Kirill Terekhov's avatar
Kirill Terekhov committed
143 144 145 146 147 148 149 150
		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
151
		set(USE_SOLVER_PETSC OFF CACHE BOOL "Use PETSc solvers" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
152 153 154 155 156 157 158 159 160 161
		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
162 163 164 165
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
166
		set(USE_SOLVER_TRILINOS OFF CACHE BOOL "Use Trilinos solvers" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
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
		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
195 196 197
if(USE_SOLVER_SUPERLU)
	find_package(SUPERLU)
	if(NOT SUPERLU_FOUND)
Kirill Terekhov's avatar
Kirill Terekhov committed
198
		set(USE_SOLVER_SUPERLU OFF CACHE BOOL "Use SuperLU solver" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
199 200 201 202 203 204 205 206 207 208
		MESSAGE("SUPERLU NOT FOUND")
	else()
		MESSAGE("\nFound SuperLU!  Here are the details: ")
		MESSAGE("INCLUDES:  ${SUPERLU_INCLUDES}")
		MESSAGE("LIBRARIES: ${SUPERLU_LIBRARIES}")

		include_directories(${SUPERLU_INCLUDES})
	endif()
endif()

209
if(USE_OPENCL)
Kirill Terekhov's avatar
Kirill Terekhov committed
210 211 212
	find_package(OpenCL)
	if(OPENCL_FOUND)
		include_directories(${OPENCL_INCLUDE_DIRS})
213
		link_directories(${OpenCL_LIBRARY})
Kirill Terekhov's avatar
Kirill Terekhov committed
214
	else()
215
		set(USE_OPENCL OFF CACHE BOOL "Use OpenCL where possible (experimental)" FORCE)
Kirill Terekhov's avatar
Kirill Terekhov committed
216 217 218 219 220
		message("OpenCL not found")
	endif()
endif()

if(USE_AUTODIFF_ASMJIT)
Kirill Terekhov's avatar
Kirill Terekhov committed
221
	set(ASMJIT_STATIC TRUE)
Kirill Terekhov's avatar
Kirill Terekhov committed
222 223 224 225 226 227 228 229 230 231 232
	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()

233 234 235 236 237
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
238

Kirill Terekhov's avatar
Kirill Terekhov committed
239 240 241 242 243 244 245 246
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
247
configure_file("Source/Headers/inmost_options_cmake.h" "${PROJECT_BINARY_DIR}/inmost_options.h")
Kirill Terekhov's avatar
Kirill Terekhov committed
248 249
include_directories("${PROJECT_BINARY_DIR}")

Kirill Terekhov's avatar
Kirill Terekhov committed
250 251 252 253
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
254
if(COMPILE_EXAMPLES)
Kirill Terekhov's avatar
Kirill Terekhov committed
255
add_subdirectory(Examples)
Kirill Terekhov's avatar
Kirill Terekhov committed
256 257 258 259
endif(COMPILE_EXAMPLES)


if(COMPILE_TESTS)
Kirill Terekhov's avatar
Kirill Terekhov committed
260 261
enable_testing()
include(CTest)
Kirill Terekhov's avatar
Kirill Terekhov committed
262
add_subdirectory(Tests)
Kirill Terekhov's avatar
Kirill Terekhov committed
263 264
endif(COMPILE_TESTS)

265

Kirill Terekhov's avatar
Kirill Terekhov committed
266 267
set(INMOST_INSTALL_HEADERS Source/Headers/inmost.h
                           Source/Headers/inmost_autodiff.h
268 269 270
                           Source/Headers/inmost_residual.h
                           Source/Headers/inmost_model.h
                           Source/Headers/inmost_operator.h
Kirill Terekhov's avatar
Kirill Terekhov committed
271 272
                           Source/Headers/inmost_common.h
                           Source/Headers/inmost_data.h
273
                           Source/Headers/inmost_dense.h
Kirill Terekhov's avatar
Kirill Terekhov committed
274 275 276 277 278 279
                           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
280
                           Source/Headers/inmost_xml.h
Kirill Terekhov's avatar
Kirill Terekhov committed
281
                           Source/Headers/inmost_variable.h
282
                           Source/Headers/inmost_block_variable.h
Kirill Terekhov's avatar
Kirill Terekhov committed
283 284 285
                           Source/Headers/container.hpp)


286 287 288 289

include(CPack)
export(TARGETS inmost FILE inmost-targets.cmake)
export(PACKAGE inmost)
Kirill Terekhov's avatar
Kirill Terekhov committed
290
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/Source/Headers" "${PROJECT_BINARY_DIR}")
291
configure_file(inmost-config.cmake.in "${PROJECT_BINARY_DIR}/inmost-config.cmake" @ONLY)
292
set(CONF_INCLUDE_DIRS "\${inmost_DIR}/include")
293 294 295 296
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
297

298 299
set_property(TARGET inmost PROPERTY PUBLIC_HEADER
	"${PROJECT_BINARY_DIR}/inmost_options.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
300 301
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_autodiff.h"
302 303 304
	"${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
305 306
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_common.h"
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_data.h"
307
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_dense.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
308 309 310 311 312 313 314
	"${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"
315
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_block_variable.h"
316
	"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_xml.h"
Kirill Terekhov's avatar
Kirill Terekhov committed
317
	"${PROJECT_SOURCE_DIR}/Source/Headers/container.hpp")
318 319 320 321 322 323 324 325

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
326 327 328
	LIBRARY DESTINATION lib
	RUNTIME DESTINATION bin
	PUBLIC_HEADER DESTINATION include)
329 330


331
install(EXPORT inmost-targets DESTINATION cmake)