1 cmake_minimum_required (VERSION 3.1)
2 set(CMAKE_CXX_STANDARD 11)
3 set(CMAKE_CXX_STANDARD_REQUIRED ON)
6 project (SOLVERLAB C CXX)
7 set (SOLVERLAB_VERSION_MAJOR 0)
8 set (SOLVERLAB_VERSION_MINOR 1)
10 option (SOLVERLAB_WITH_DOCUMENTATION "Generate SOLVERLAB documentation" ON)
11 option (SOLVERLAB_WITH_PYTHON "Compile Python interface of SOLVERLAB" ON)
12 option (SOLVERLAB_WITH_GUI "Compile a Graphic user Interface for SOLVERLAB" OFF)
13 option (SOLVERLAB_WITH_PACKAGE "Generate RPM, Debian and tarball packages" OFF)
14 option (SOLVERLAB_WITH_COREFLOWS "Generate COREFLOWS module" ON)
15 option (SOLVERLAB_WITH_TESTS "Generate SOLVERLAB example tests" ON)
17 #Path to installed libraries
18 set (PETSC_DIR OFF CACHE STRING "PETSc library path" )
19 set (SLEPC_DIR OFF CACHE STRING "SLEPc library path" )
20 set (HDF5_ROOT OFF CACHE STRING "HDF5 library path" )#For the compilation of MED with a specific version of HDF5
21 set (MEDFILE_ROOT_DIR OFF CACHE STRING "MED library path" )
22 set (MEDCOUPLING_ROOT_DIR OFF CACHE STRING "MEDCoupling library path" )
23 set (PYTHON_ROOT_DIR OFF CACHE STRING "Python library path" )
25 #url of tarball librairies
26 set (DOWNLOAD_PETSC http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-3.14.0.tar.gz
27 CACHE STRING "PETSc tarball path/url" )
28 set (DOWNLOAD_SLEPC https://slepc.upv.es/download/distrib/slepc-3.14.0.tar.gz
29 CACHE STRING "SLEPC tarball path/url" )
30 set (DOWNLOAD_F2CBLASLAPACK https://www.mcs.anl.gov/petsc/mirror/externalpackages/f2cblaslapack-3.4.2.q4.tar.gz
31 CACHE STRING "F2CBLASLAPACK tarball path/url" )
32 set (DOWNLOAD_HDF5 https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.3/src/hdf5-1.10.3.tar.gz
33 CACHE STRING "HDF5 tarball path/url" )
34 set (DOWNLOAD_MED http://files.salome-platform.org/Salome/other/med-4.1.0.tar.gz
35 CACHE STRING "MED tarball path/url")
36 set (DOWNLOAD_MEDCOUPLING http://files.salome-platform.org/Salome/other/medCoupling-9.4.0.tar.gz
37 CACHE STRING "MEDCoupling tarball path/url" )
39 set (CMAKE_BUILD_TYPE Release CACHE STRING "Installation mode")
41 list (APPEND CMAKE_MODULE_PATH "${SOLVERLAB_SOURCE_DIR}/cmake_files")
43 include(ExternalProject)#For PETSc, MED and MEDCoupling
45 ######################################################
46 # Detection or compilation of PETSc+SLEPc+HDF5 #
47 ######################################################
48 if ( DEFINED ENV{PETSC_DIR} OR PETSC_DIR)
50 set(PETSC_DIR $ENV{PETSC_DIR})
51 message ( STATUS "Checking variable PETSC_DIR : " $ENV{PETSC_DIR} )
53 message ( STATUS "Checking variable PETSC_DIR : " ${PETSC_DIR} )
56 find_package (PETSc 3.4 REQUIRED)
59 message ( STATUS "PETSc found. Version is ${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}" )
60 set(PETSC_INSTALL ${PETSC_DIR})
62 #Define and search slepc variables
64 if ( DEFINED ENV{SLEPC_DIR} )
65 set(SLEPC_DIR $ENV{SLEPC_DIR})
66 else ( DEFINED ENV{SLEPC_DIR} )
67 set(SLEPC_DIR ${PETSC_DIR}/${PETSC_ARCH})
68 endif( DEFINED ENV{SLEPC_DIR} )
71 message ( STATUS "Checking variable SLEPC_DIR" )
72 if ( IS_DIRECTORY ${SLEPC_DIR}/include AND EXISTS ${SLEPC_DIR}/lib/libslepc.so)
73 set(SLEPC_INCLUDES ${SLEPC_DIR}/include)
74 set(SLEPC_LIBRARIES ${SLEPC_DIR}/lib/libslepc.so)
75 message( STATUS "SLEPc found at ${SLEPC_DIR}" )
77 message( FATAL_ERROR "SLEPc not found at ${SLEPC_DIR}" )
80 #define hdf5 variables
81 if ( NOT HDF5_ROOT )#hdf5 is not defined in cmake arguments
82 if ( DEFINED ENV{HDF5_ROOT} )#hdf5 is defined in the environment
83 set(HDF5_ROOT $ENV{HDF5_ROOT})
84 else( DEFINED ENV{HDF5_ROOT} )#hdf5 is not defined in the environment
85 #HDF5 to be found in petsc external packages
86 set(HDF5_ROOT ${PETSC_DIR}/${PETSC_ARCH})# define hint for hdf5/med installation in petsc external packages
87 endif( DEFINED ENV{HDF5_ROOT} )
88 endif( NOT HDF5_ROOT )
89 set(HDF5_LIBRARY_DIR ${HDF5_ROOT}/lib)
90 set(HDF5_INCLUDE_DIRS ${HDF5_ROOT}/include)
91 else ( DEFINED ENV{PETSC_DIR} OR PETSC_DIR )
92 message ( STATUS "PETSC_DIR not set, searching PETSc and SLEPc in the system" )
94 if ( IS_DIRECTORY "/usr/include/petsc/" AND EXISTS "/usr/lib64/libpetsc.so" ) #Case fedora/redhat system install
95 message ( STATUS "PETSC includes found in /usr/include/petsc/" )
96 message ( STATUS "PETSC library found in /usr/lib64" )
98 set(PETSC_INCLUDES /usr/include/petsc /usr/include/petsc/petsc/mpiuni)
99 set(PETSC_LIBRARIES /usr/lib64/libpetsc.so)
101 set(PETSC_VERSION "3.8") #3.8 for fedora 26 , 3.9 for fedora 29 , 3.10 for fedora 30, , 3.12 for fedora 32
103 set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, petsc-devel (>= 3.4)") # This is not fully working yet.
104 set(PETSC_INSTALL ${PETSC_DIR})
106 #Define and search slepc variables
107 if ( IS_DIRECTORY "/usr/include/slepc/" AND EXISTS "/usr/lib64/libslepc.so" )
108 message( STATUS "SLEPc includes found in /usr/include/slepc/" )
109 message( STATUS "SLEPc library found in /usr/lib64/slepc/" )
111 set(SLEPC_INCLUDES ${SLEPC_DIR}/include)
112 set(SLEPC_LIBRARIES ${SLEPC_DIR}/lib/libslepc.so)
113 set (CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, slepc-devel (>= 3.4)") # This is not fully working yet.
114 else ( IS_DIRECTORY "/usr/include/slepc/" AND EXISTS "/usr/lib64/libslepc.so" )
115 message( FATAL_ERROR "SLEPc not found in the system" )
116 endif( IS_DIRECTORY "/usr/include/slepc/" AND EXISTS "/usr/lib64/libslepc.so" )
118 #HDF5 to be found in the system
119 if ( NOT HDF5_ROOT AND NOT DEFINED ENV{HDF5_ROOT} )#hdf5 is not defined in the environment
120 find_package(HDF5 REQUIRED)
121 set(CPACK_DEBIAN_PACKAGE_DEPENDS "libhdf5-dev")
122 set(CPACK_RPM_PACKAGE_REQUIRES "hdf5-devel")
123 endif( NOT HDF5_ROOT AND NOT DEFINED ENV{HDF5_ROOT} )
125 #elseif ( IS_DIRECTORY "/usr/lib/petsc/include" AND EXISTS "/usr/lib/petsc/lib/libpetsc_real.so" ) #Case ubuntu/debian system install
126 # message ( STATUS "PETSc includes found in /usr/lib/petsc/include")
127 # message ( STATUS "PETSc library found in /usr/lib/petsc/lib/libpetsc_real.so")
128 # set(PETSC_DIR /usr/lib/petsc/)
129 # set(PETSC_INCLUDES ${PETSC_DIR}/include ${PETSC_DIR}/include/petsc/mpiuni)
130 # set(PETSC_LIBRARIES ${PETSC_DIR}/lib/libpetsc_real.so)
132 # find_package (PETSc 3.4 REQUIRED)
133 # petsc_get_version ()
134 # set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, petsc-dev (>= 3.4)") # This is not fully working yet.
136 # Define and search slepc variables
137 # if ( IS_DIRECTORY "/usr/lib/slepc/include" AND EXISTS "/usr/lib/slepc/lib/libslepc_real.so" )
138 # message( STATUS "SLEPc includes found in /usr/lib/slepc/include" )
139 # message( STATUS "SLEPc library found in /usr/lib/slepc/lib/libslepc_real.so" )
140 # set(SLEPC_DIR /usr/lib/slepc/)
141 # set(SLEPC_INCLUDES ${SLEPC_DIR}/include)
142 # set(SLEPC_LIBRARIES ${SLEPC_DIR}/lib/libslepc_real.so)
143 # set (CPACK_DEBIAN_PACKAGE_REQUIRES "${CPACK_DEBIAN_PACKAGE_REQUIRES}, slepc-devel (>= 3.4)") # This is not fully working yet.
144 # else ( IS_DIRECTORY "/usr/lib/slepc/include" AND EXISTS "/usr/lib/slepc/lib/libslepc_real.so" )
145 # message( FATAL_ERROR "SLEPc not found in the system" )
146 # endif( IS_DIRECTORY "/usr/lib/slepc/include" AND EXISTS "/usr/lib/slepc/lib/libslepc_real.so" )
148 #elseif ( IS_DIRECTORY "/usr/local/lib/python2.7/dist-packages/petsc") #Case ubuntu/debian system pip install
150 else ( IS_DIRECTORY "/usr/include/petsc/" AND EXISTS "/usr/lib64/libpetsc.so" ) # No petsc in system, do compile petsc along with slepc as an external package
151 message (STATUS "PETSC not found in the system")
152 message (STATUS "PETSC will be downloaded and compiled from ${DOWNLOAD_PETSC}" )
153 message (STATUS "SLEPC will be downloaded and compiled from ${DOWNLOAD_SLEPC}" )
154 message (STATUS "HDF5 will be downloaded and compiled from ${DOWNLOAD_HDF5}" )
156 #extract tarball name
157 string(LENGTH "${DOWNLOAD_PETSC}" tarball_url_length)#length of the tarball
158 string(FIND "${DOWNLOAD_PETSC}" "/" start_tarball_name REVERSE )# last occurence of "/"
159 MATH(EXPR start_tarball_name "${start_tarball_name}+1")#start after the occurence of "/"
160 MATH(EXPR tarball_name_length "${tarball_url_length}-${start_tarball_name}-7")#name ends before .tar.gz that counts for 7 characters
161 string(SUBSTRING ${DOWNLOAD_PETSC} ${start_tarball_name} ${tarball_name_length} PETSC_TARBALL_NAME)
163 set(PETSC_DIR ${CMAKE_CURRENT_BINARY_DIR}/pre_requis/${PETSC_TARBALL_NAME}) # Location of the final install
164 set(PETSC_ARCH arch-linux-c-opt)
165 set(PETSC_INSTALL ${CMAKE_INSTALL_PREFIX}/share/petsc)#folder to copy petsc libraries and include files
167 ExternalProject_Add (PETSc
168 URL ${DOWNLOAD_PETSC}
169 SOURCE_DIR ${PETSC_DIR}
171 CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${PETSC_INSTALL} --with-debugging=0 --with-mpi=0 --download-f2cblaslapack=${DOWNLOAD_F2CBLASLAPACK} --with-fc=0 --download-slepc=${DOWNLOAD_SLEPC} --download-hdf5=${DOWNLOAD_HDF5}
172 BUILD_COMMAND make all
173 TEST_COMMAND make check
174 INSTALL_COMMAND make install
175 INSTALL_DIR ${PETSC_DIR}
176 STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/pre_requis
177 LOG_DOWNLOAD TRUE # Wrap download in script to log output
178 LOG_UPDATE TRUE # Wrap update in script to log output
179 LOG_CONFIGURE TRUE # Wrap configure in script to log output
180 LOG_BUILD TRUE # Wrap build in script to log output
181 LOG_TEST TRUE # Wrap test in script to log output
182 LOG_INSTALL TRUE # Wrap install in script to log output
185 message( STATUS "PETSc, SLEPc and HDF5 will be installed at ${PETSC_INSTALL}")
187 string(LENGTH "${PETSC_TARBALL_NAME}" tarball_name_length)#length of the tarball
188 string(FIND "${PETSC_TARBALL_NAME}" "-" start_version_name REVERSE )# last occurence of "-"
189 MATH(EXPR start_version_name "${start_version_name}+1")#start after the occurence of "/"
190 string(SUBSTRING ${PETSC_TARBALL_NAME} ${start_version_name} ${tarball_name_length} PETSC_VERSION)
191 message( STATUS "PETSc version ${PETSC_VERSION} will be installed" )
193 set(PETSC_INCLUDES ${PETSC_DIR}/${PETSC_ARCH}/include ${PETSC_DIR}/include)
194 set(PETSC_LIBRARIES ${PETSC_DIR}/${PETSC_ARCH}/lib/libpetsc.so)
196 #define slepc variables
197 set(SLEPC_DIR ${PETSC_INSTALL})
198 set(SLEPC_INCLUDES ${SLEPC_DIR}/include ${PETSC_DIR}/${PETSC_ARCH}/externalpackages/slepc-3.13.4/include ${PETSC_DIR}/${PETSC_ARCH}/externalpackages/slepc-3.13.4/installed-arch-linux2-c-opt/include)
199 set(SLEPC_LIBRARIES ${PETSC_DIR}/${PETSC_ARCH}/externalpackages/slepc-3.13.4/installed-arch-linux2-c-opt/lib/libslepc.so)
200 message( STATUS "SLEPc includes ${SLEPC_INCLUDES}")
202 #define hdf5 variables
203 if ( NOT HDF5_ROOT )#hdf5 is not defined in cmake arguments
204 if ( DEFINED ENV{HDF5_ROOT} )#hdf5 is defined in the environment
205 set(HDF5_ROOT $ENV{HDF5_ROOT})
206 else( DEFINED ENV{HDF5_ROOT} )#hdf5 is not defined in the environment
207 set(HDF5_ROOT ${PETSC_INSTALL})#HDF5 to be found in petsc installation
208 endif( DEFINED ENV{HDF5_ROOT} )
209 endif( NOT HDF5_ROOT )
210 set(HDF5_LIBRARY_DIR ${HDF5_ROOT}/lib)
211 set(HDF5_INCLUDE_DIRS ${HDF5_ROOT}/include)
213 endif ( IS_DIRECTORY "/usr/include/petsc/" AND EXISTS "/usr/lib64/libpetsc.so" )
214 endif ( DEFINED ENV{PETSC_DIR} OR PETSC_DIR )
216 if ( ${PETSC_VERSION} VERSION_GREATER 3.5 )
217 add_definitions(-DPETSC_VERSION_GREATER_3_5)
218 endif( ${PETSC_VERSION} VERSION_GREATER 3.5 )
220 string(REPLACE ";" ":" PETSC_INCLUDES_INSTALL "${PETSC_INCLUDES}")# use colon instead of semicolon in environment file env_SOLVERLAB.sh
222 add_library(petsc SHARED IMPORTED)
223 set_property(TARGET petsc PROPERTY IMPORTED_LOCATION ${PETSC_LIBRARIES})
224 add_library(slepc SHARED IMPORTED)
225 set_property(TARGET slepc PROPERTY IMPORTED_LOCATION ${SLEPC_LIBRARIES})
227 ######################################################
228 # Detection or compilation of MEDFile #
229 ######################################################
230 if( MEDFILE_ROOT_DIR OR DEFINED ENV{MEDFILE_ROOT_DIR})
232 if ( NOT MEDFILE_ROOT_DIR )
233 set(MEDFILE_ROOT_DIR $ENV{MEDFILE_ROOT_DIR} )
234 endif( NOT MEDFILE_ROOT_DIR )
236 find_package (MEDFile REQUIRED)
238 else( MEDFILE_ROOT_DIR OR DEFINED ENV{MEDFILE_ROOT_DIR})
240 message(STATUS "MED will be downloaded and installed from ${DOWNLOAD_MED}")
242 set(MEDFILE_DEFINITIONS "-D${MACHINE} -DMEDFILE_INSTALL_DOC=OFF")#Comment ne pas compiler la doc ?
243 set(MEDFILE_ROOT_DIR ${CMAKE_INSTALL_PREFIX}/share/med) # Location of the final install
245 #extraction of the tarball archive name
246 string(LENGTH "${DOWNLOAD_MED}" tarball_url_length)#length of the name of the tarball
247 string(FIND "${DOWNLOAD_MED}" "/" start_tarball_name REVERSE )# last occurence of "/"
248 MATH(EXPR start_tarball_name "${start_tarball_name}+1")#start after the occurence of "/"
249 MATH(EXPR tarball_name_length "${tarball_url_length}-${start_tarball_name}-7")#name ends before .tar.gz that counts for 7 characters
250 string(SUBSTRING ${DOWNLOAD_MED} ${start_tarball_name} ${tarball_name_length} MED_TARBALL_NAME)
252 ExternalProject_Add (MED
253 URL ${DOWNLOAD_MED} #location of med tarball
254 SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/pre_requis/${MED_TARBALL_NAME}
256 CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${MEDFILE_ROOT_DIR} --with-hdf5=${HDF5_ROOT} --with-hdf5-include=${HDF5_ROOT}/include --with-hdf5-lib=${HDF5_LIBRARY_DIR} --with-hdf5-bin=${HDF5_ROOT}/bin --with-swig=yes
258 INSTALL_COMMAND make install
259 INSTALL_DIR ${MEDFILE_ROOT_DIR}
260 STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/pre_requis
261 LOG_DOWNLOAD TRUE # Wrap download in script to log output
262 LOG_UPDATE TRUE # Wrap update in script to log output
263 LOG_CONFIGURE TRUE # Wrap configure in script to log output
264 LOG_BUILD TRUE # Wrap build in script to log output
265 LOG_TEST TRUE # Wrap test in script to log output
266 LOG_INSTALL TRUE # Wrap install in script to log output
269 set(MEDFILE_INCLUDE_DIRS ${MEDFILE_ROOT_DIR}/include)# Nécessaire pour le medloader et les sous-dossiers mesh, et IJKMesh
270 set(MEDFILE_LIBRARIES ${MEDFILE_ROOT_DIR}/lib)# Nécessaire pour le env_SOLVERLAB.sh
271 set(MEDFILE_C_LIBRARIES med medC)# Nécessaire pour le medloader
273 endif( MEDFILE_ROOT_DIR OR DEFINED ENV{MEDFILE_ROOT_DIR})
275 add_library(med SHARED IMPORTED)
276 set_property(TARGET med PROPERTY IMPORTED_LOCATION ${MEDFILE_ROOT_DIR}/lib/libmed.so)
277 add_library(medC SHARED IMPORTED)
278 set_property(TARGET medC PROPERTY IMPORTED_LOCATION ${MEDFILE_ROOT_DIR}/lib/libmedC.so)
280 string(REPLACE ";" ":" MEDFILE_LIBRARIES_INSTALL "${MEDFILE_LIBRARIES}")# use colon instead of semicolon in environment file env_SOLVERLAB.sh
282 ######################################################
283 # Detection or compilation of MEDCoupling #
284 ######################################################
285 if( MEDCOUPLING_ROOT_DIR OR DEFINED ENV{MEDCOUPLING_ROOT_DIR})
287 if( NOT MEDCOUPLING_ROOT_DIR )
288 set(MEDCOUPLING_ROOT_DIR $ENV{MEDCOUPLING_ROOT_DIR} )
289 endif( NOT MEDCOUPLING_ROOT_DIR )
291 set(MEDCoupling_DIR ${MEDCOUPLING_ROOT_DIR}/cmake_files)
292 find_package(MEDCoupling CONFIG REQUIRED ) # CONFIG is important !
293 message( STATUS "MEDCoupling found. Version is ${MEDCoupling_VERSION}")
295 else( MEDCOUPLING_ROOT_DIR OR DEFINED ENV{MEDCOUPLING_ROOT_DIR})
296 message(STATUS "MEDCoupling will be downloaded and installed from ${DOWNLOAD_MEDCOUPLING}")
297 set(MEDCOUPLING_ROOT_DIR ${CMAKE_INSTALL_PREFIX}/share/medcoupling) # Location of the final install
298 SET(ENV{HDF5_ROOT} ${HDF5_ROOT})#MEDCoupling install process seems to require an environment variable
300 #extraction of the tarball archive name
301 string(LENGTH "${DOWNLOAD_MEDCOUPLING}" tarball_url_length)#length of the tarball
302 string(FIND "${DOWNLOAD_MEDCOUPLING}" "/" start_tarball_name REVERSE )# last occurence of "/"
303 MATH(EXPR start_tarball_name "${start_tarball_name}+1")#start after the occurence of "/"
304 MATH(EXPR tarball_name_length "${tarball_url_length}-${start_tarball_name}-7")#name ends before .tar.gz that counts for 7 characters
305 string(SUBSTRING ${DOWNLOAD_MEDCOUPLING} ${start_tarball_name} ${tarball_name_length} MEDCOUPLING_TARBALL_NAME)
306 string(SUBSTRING ${MEDCOUPLING_TARBALL_NAME} 12 ${tarball_name_length} MEDCoupling_VERSION)
308 message(STATUS "MEDCoupling version will be ${MEDCoupling_VERSION}")
310 ExternalProject_Add (MEDCoupling
311 URL ${DOWNLOAD_MEDCOUPLING} #location of medcoupling tarball
312 SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/pre_requis/${MEDCOUPLING_TARBALL_NAME}
313 # BUILD_IN_SOURCE FALSE
314 CONFIGURE_COMMAND cmake <SOURCE_DIR>/${MEDCOUPLING_TARBALL_NAME} -DCMAKE_INSTALL_PREFIX=${MEDCOUPLING_ROOT_DIR} -DCONFIGURATION_ROOT_DIR=<SOURCE_DIR>/configuration-${MEDCoupling_VERSION} -DMEDFILE_ROOT_DIR=${MEDFILE_ROOT_DIR} -DMEDCOUPLING_ENABLE_PARTITIONER=OFF -DMEDCOUPLING_PARTITIONER_METIS=OFF -DMEDCOUPLING_PARTITIONER_SCOTCH=OFF -DMEDCOUPLING_ENABLE_RENUMBER=OFF -DMEDCOUPLING_BUILD_DOC=OFF -DHDF5_ROOT_DIR=${HDF5_ROOT}
316 INSTALL_COMMAND make install
317 INSTALL_DIR ${MEDCOUPLING_ROOT_DIR}
318 STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/pre_requis
319 LOG_DOWNLOAD TRUE # Wrap download in script to log output
320 LOG_UPDATE TRUE # Wrap update in script to log output
321 LOG_CONFIGURE TRUE # Wrap configure in script to log output
322 LOG_BUILD TRUE # Wrap build in script to log output
323 LOG_TEST TRUE # Wrap test in script to log output
324 LOG_INSTALL TRUE # Wrap install in script to log output
327 add_library(medloader SHARED IMPORTED )
328 set_property(TARGET medloader PROPERTY IMPORTED_LOCATION ${MEDCOUPLING_ROOT_DIR}/lib/libmedloader.so)
330 endif( MEDCOUPLING_ROOT_DIR OR DEFINED ENV{MEDCOUPLING_ROOT_DIR} )
332 set(MEDCOUPLING_INCLUDE_DIR ${MEDCOUPLING_ROOT_DIR}/include)
333 set(MEDCOUPLING_LIBRARIES ${MEDCOUPLING_ROOT_DIR}/lib )#for environment file env_SOLVERLAB.sh
335 add_library(medcoupling SHARED IMPORTED )
336 set_property(TARGET medcoupling PROPERTY IMPORTED_LOCATION ${MEDCOUPLING_ROOT_DIR}/lib/libmedcoupling.so)
338 if ( ${MEDCoupling_VERSION} VERSION_GREATER 9.4 )
339 add_definitions(-DMEDCoupling_VERSION_VERSION_GREATER_9_4)
340 endif( ${MEDCoupling_VERSION} VERSION_GREATER 9.4 )
342 if (TARGET MED AND TARGET PETSc)
343 ExternalProject_Add_StepDependencies( MED build PETSc )#PETSc doit être compilé avant MED car c'est PETSc qui compile HDF5
344 endif(TARGET MED AND TARGET PETSc)
346 if (TARGET MED AND TARGET MEDCoupling)
347 ExternalProject_Add_StepDependencies( MEDCoupling build MED )#MED doit être compilé avant MEDCoupling
348 endif(TARGET MED AND TARGET MEDCoupling)
350 if (TARGET PETSc AND TARGET MEDCoupling)
351 ExternalProject_Add_StepDependencies( MEDCoupling build PETSc )#PETSc doit être compilé avant MEDCoupling (car il contient hdf5)
352 endif(TARGET PETSc AND TARGET MEDCoupling)
358 # Paraview variables to choose python version and for env_SOLVERLAB.sh
359 if ( DEFINED PARAVIEW_ROOT_DIR OR DEFINED ENV{PARAVIEW_ROOT_DIR})
360 if ( DEFINED PARAVIEW_ROOT_DIR )
361 set( PARAVIEW_INCLUDE_DIR ${PARAVIEW_ROOT_DIR}/include)
362 set( PARAVIEW_LIBRARIES_DIR ${PARAVIEW_ROOT_DIR}/lib)
363 else( DEFINED PARAVIEW_ROOT_DIR )
364 set( PARAVIEW_ROOT_DIR $ENV{PARAVIEW_ROOT_DIR} )
365 set( PARAVIEW_INCLUDE_DIR $ENV{PARAVIEW_ROOT_DIR}/include)
366 set( PARAVIEW_LIBRARIES_DIR $ENV{PARAVIEW_ROOT_DIR}/lib)
367 endif( DEFINED PARAVIEW_ROOT_DIR )
368 else( DEFINED PARAVIEW_ROOT_DIR OR DEFINED ENV{PARAVIEW_ROOT_DIR})
369 message(STATUS "PARAVIEW_ROOT_DIR not set. Trying to detect paraview.")
370 set( PARAVIEW_INCLUDE_DIR /usr/include/paraview/)
371 set( PARAVIEW_LIBRARIES_DIR /usr/lib/paraview/:/usr/lib64/paraview/:/usr/lib64/vtk/:/usr/lib/vtk/)
372 endif( DEFINED PARAVIEW_ROOT_DIR OR DEFINED ENV{PARAVIEW_ROOT_DIR})
374 if ( DEFINED PARAVIEW_VERSION OR DEFINED ENV{PARAVIEW_VERSION} )
375 if ( NOT DEFINED PARAVIEW_VERSION )
376 set( PARAVIEW_VERSION $ENV{PARAVIEW_VERSION})
377 endif( NOT DEFINED PARAVIEW_VERSION )
378 message(STATUS "ParaView version is ${PARAVIEW_VERSION}" )
379 else( DEFINED PARAVIEW_VERSION OR DEFINED ENV{PARAVIEW_VERSION} )
380 set( PARAVIEW_SUFFIXES paraview-5.0 paraview-5.1 paraview-5.2 paraview-5.3 paraview-5.4 paraview-5.5 paraview-5.6 paraview-5.7 paraview-5.8 paraview-5.9 )
381 find_file( vtkConfig_file vtkPVConfig.h HINTS ${PARAVIEW_INCLUDE_DIR} PATH_SUFFIXES ${PARAVIEW_SUFFIXES})
383 #extraction of the paraview version"
384 IF ( ${vtkConfig_file} STREQUAL "vtkConfig_file-NOTFOUND" )
385 message(WARNING "Could not find ParaView configuration file vtkPVConfig.h in folder ${PARAVIEW_INCLUDE_DIR} and subdirectories ${PARAVIEW_SUFFIXES}. Postprocessing may not work")
386 set( PARAVIEW_VERSION "5.0")
387 ELSE ( ${vtkConfig_file} STREQUAL "vtkConfig_file-NOTFOUND" )
388 message( STATUS "Found vtkPVConfig.h in ${vtkConfig_file}")
389 file(STRINGS ${vtkConfig_file} vtkConfig)
390 FOREACH(line ${vtkConfig})
391 string(FIND "${line}" "#define PARAVIEW_VERSION_FULL " pos)
392 IF(NOT ${pos} EQUAL -1)
393 string(LENGTH ${line} line_length)#length of the tarball
394 MATH(EXPR start_pv_version "${line_length}-6")#line ends with "x.y.z", that counts for 7 characters
395 string(SUBSTRING ${line} ${start_pv_version} 5 PARAVIEW_VERSION)
397 ENDIF(NOT ${pos} EQUAL -1)
398 ENDFOREACH(line ${vtkConfig})
399 message(STATUS "ParaView detected, version is ${PARAVIEW_VERSION}" )
400 ENDIF( ${vtkConfig_file} STREQUAL "vtkConfig_file-NOTFOUND" )
401 endif( DEFINED PARAVIEW_VERSION OR DEFINED ENV{PARAVIEW_VERSION} )
403 #Choose python 2 or 3
404 IF ( ${PARAVIEW_VERSION} STRGREATER "5.6" OR ${PARAVIEW_VERSION} STREQUAL "5.6" )#Use python 3, use VERSION_GREATER_EQUAL if cmake >=3.7
406 message(STATUS "PARAVIEW_VERSION greater than 5.6. We need python3 for postprocessing scripts.")
407 ELSE ( ${PARAVIEW_VERSION} STRGREATER "5.6" OR ${PARAVIEW_VERSION} STREQUAL "5.6" )#Use python 2
409 message(STATUS "PARAVIEW_VERSION smaller than 5.6. We need python2 for postprocessing scripts.")
410 ENDIF( ${PARAVIEW_VERSION} STRGREATER "5.6" OR ${PARAVIEW_VERSION} STREQUAL "5.6" )
413 IF ( PYTHON_ROOT_DIR OR ENV{PYTHON_ROOT_DIR})
414 IF ( PYTHON_ROOT_DIR )
415 set(Python_ROOT_DIR ${PYTHON_ROOT_DIR} )
416 ELSE( PYTHON_ROOT_DIR })
417 set(Python_ROOT_DIR $ENV{PYTHON_ROOT_DIR} )
418 ENDIF( PYTHON_ROOT_DIR })
419 ENDIF(PYTHON_ROOT_DIR OR ENV{PYTHON_ROOT_DIR})
421 IF (${CMAKE_VERSION} VERSION_GREATER "3.12.0")
422 find_package(Python ${PYTHON2OR3} REQUIRED COMPONENTS Interpreter Development )
423 SET(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
424 ELSE (${CMAKE_VERSION} VERSION_GREATER "3.12.0")
425 find_package(PythonInterp ${PYTHON2OR3} REQUIRED )
426 find_package(PythonLibs ${PYTHON2OR3} REQUIRED )
427 set(Python_LIBRARIES ${PYTHON_LIBRARIES})
428 set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
429 set(Python_VERSION ${PYTHON_VERSION_STRING})
430 set(Python_VERSION_MAJOR ${PYTHON_VERSION_MAJOR})
431 set(Python_VERSION_MINOR ${PYTHON_VERSION_MINOR})
432 ENDIF(${CMAKE_VERSION} VERSION_GREATER "3.12.0")
435 IF ( NOT PYQT5_ROOT_DIR )
436 set(PYQT5_ROOT_DIR $ENV{PYQT5_ROOT_DIR} )
437 ENDIF( NOT PYQT5_ROOT_DIR )
440 IF ( NOT MATPLOTLIB_ROOT_DIR )
441 set(MATPLOTLIB_ROOT_DIR $ENV{MATPLOTLIB_ROOT_DIR} )
442 ENDIF( NOT MATPLOTLIB_ROOT_DIR )
445 IF ( NOT HDF5_ROOT_DIR )
446 IF ( ENV{HDF5_ROOT_DIR} )
447 set(HDF5_ROOT_DIR $ENV{HDF5_ROOT_DIR} )
448 ELSE( ENV{HDF5_ROOT_DIR} )
449 set(HDF5_ROOT_DIR ${HDF5_ROOT} )
450 ENDIF( ENV{HDF5_ROOT_DIR} )
451 ENDIF( NOT HDF5_ROOT_DIR )
454 #Paraview library paths
455 set (PV_LIB_DIR /usr/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/dist-packages/paraview/:/usr/lib64/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/vtk/:${MATPLOTLIB_ROOT_DIR}/lib/:${PARAVIEW_LIBRARIES_DIR})
456 set (PV_PYTHON_DIR /usr/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/dist-packages/paraview/:/usr/lib64/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/vtk/:/usr/lib64/paraview/site-packages/:/usr/lib64/paraview/site-packages/paraview/:/usr/lib64/paraview/site-packages/vtk/:/usr/lib64/paraview/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/:/usr/lib64/paraview/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/paraview/:/usr/lib64/paraview/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/vtkmodules:/usr/lib/paraview/site-packages/paraview:/usr/lib/paraview/site-packages/paraview/vtk:${PARAVIEW_ROOT_DIR}/lib/:${PARAVIEW_ROOT_DIR}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/:${PARAVIEW_ROOT_DIR}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/vtkmodules/:${MATPLOTLIB_ROOT_DIR}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages:${PYQT5_ROOT_DIR}:${PYQT5_ROOT_DIR}/lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages)
458 message(STATUS "Python version found is ${Python_VERSION}")
459 find_package (SWIG 3.0 REQUIRED)
461 if (SOLVERLAB_WITH_DOCUMENTATION) #
462 find_package (Doxygen) #
463 set (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, doxygen, graphviz, mscgen")
464 set (CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}, doxygen, graphviz, mscgen")
465 if (NOT DOXYGEN_FOUND)
466 message (FATAL_ERROR "Doxygen is needed to build the documentation. Please install it correctly.")
467 endif(NOT DOXYGEN_FOUND)
469 if (SOLVERLAB_WITH_TESTS) #
471 find_package (CPPUNIT REQUIRED)
473 find_package (XDR REQUIRED)
475 # Enter subdirectories
476 add_subdirectory (CDMATH)
477 if(SOLVERLAB_WITH_COREFLOWS)
478 add_subdirectory (CoreFlows)
479 endif(SOLVERLAB_WITH_COREFLOWS)
483 ${PROJECT_SOURCE_DIR}/env_SOLVERLAB.sh
484 ${CMAKE_INSTALL_PREFIX}/env_SOLVERLAB.sh