1 # Copyright (C) 2012-2013 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
21 PROJECT(SalomeMED C CXX)
23 # Ensure a proper linker behavior:
24 CMAKE_POLICY(SET CMP0003 NEW)
28 # Project name, upper case
29 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
31 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
32 SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
33 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
34 SET(${PROJECT_NAME_UC}_VERSION
35 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
36 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
39 # Kernel detection comes before user options to be
40 # able to take previous values of global options ...
43 IF(NOT SALOME_MED_STANDALONE)
44 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
45 IF(EXISTS ${KERNEL_ROOT_DIR})
46 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
48 FIND_PACKAGE(SalomeKERNEL REQUIRED)
49 ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
50 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
51 SET(_default_MPI ${SALOME_USE_MPI})
52 ELSE(EXISTS ${KERNEL_ROOT_DIR})
53 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_MED_STANDALONE to ON !")
54 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
55 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
56 ELSE(NOT SALOME_MED_STANDALONE)
57 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local_without_kernel/cmake_files")
59 ENDIF(NOT SALOME_MED_STANDALONE)
63 INCLUDE(SalomeSetupPlatform)
65 IF(NOT SALOME_MED_STANDALONE)
66 FIND_PACKAGE(SalomePThread REQUIRED) # for MEDCouplingCorba/Test for EDF
67 FIND_PACKAGE(SalomeOmniORB REQUIRED)
68 ENDIF(NOT SALOME_MED_STANDALONE)
72 INCLUDE(CMakeDependentOption)
73 OPTION(SALOME_MED_STANDALONE "Build MED without CORBA bindings. When OFF, exchange to PARAVIS is disabled." OFF)
74 OPTION(SALOME_MED_MICROMED "Build MED without MED file dependancy." OFF)
75 OPTION(SALOME_MED_ENABLE_PYTHON "Build PYTHON bindings." ON)
76 OPTION(SALOME_MED_ENABLE_PARTITIONER "Build MEDPartitioner." ON)
77 OPTION(SALOME_MED_ENABLE_RENUMBER "Build Renumber." ON)
78 OPTION(SALOME_MED_WITH_FILE_EXAMPLES "Install examples of files containing meshes and fields of different formats." ON)
79 OPTION(SALOME_USE_MPI "(Use MPI containers) - For MED this triggers the build of ParaMEDMEM." ${_default_MPI})
80 OPTION(SALOME_BUILD_GUI "Build GUI of MED." ON)
81 OPTION(SALOME_BUILD_TESTS "Build MED tests." ON)
82 OPTION(SALOME_BUILD_DOC "Build MED doc." ON)
83 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_METIS "Enable metis graph library in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;NOT SALOME_USE_MPI" OFF)
84 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_SCOTCH "Enable scotch graph library in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;NOT SALOME_USE_MPI" OFF)
85 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_PARMETIS "Enable parmetis graph library in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;SALOME_USE_MPI" OFF)
87 CMAKE_DEPENDENT_OPTION(SALOME_MED_MEDLOADER_USE_XDR "Enable use of XDR for SauvReader." ON "NOT SALOME_MED_MICROMED" OFF)
91 # Set list of prerequisites
92 # =========================
94 IF(NOT SALOME_MED_STANDALONE)
95 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
96 IF(EXISTS ${KERNEL_ROOT_DIR})
97 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
99 FIND_PACKAGE(SalomeKERNEL REQUIRED)
100 ELSE(EXISTS ${KERNEL_ROOT_DIR})
101 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_MED_STANDALONE to ON !")
102 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
103 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
104 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
105 ELSE(NOT SALOME_MED_STANDALONE)
106 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
107 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local_without_kernel/cmake_files")
108 INCLUDE(SalomeMacros)
109 ENDIF(NOT SALOME_MED_STANDALONE)
111 IF(NOT SALOME_MED_MICROMED)
112 FIND_PACKAGE(SalomeHDF5 REQUIRED)
113 FIND_PACKAGE(SalomeMEDFile REQUIRED)
116 FIND_PACKAGE(SalomeXDR REQUIRED)
118 IF(SALOME_MED_MEDLOADER_USE_XDR)
119 FIND_PACKAGE(SalomeXDR REQUIRED)
120 ENDIF(SALOME_MED_MEDLOADER_USE_XDR)
123 IF(SALOME_MED_ENABLE_PARTITIONER)
124 FIND_PACKAGE(SalomeLibXml2)
125 SALOME_LOG_OPTIONAL_PACKAGE(LibXml2 SALOME_MED_ENABLE_PARTITIONER)
126 IF(SALOME_MED_PARTITIONER_METIS)
127 FIND_PACKAGE(SalomeMetis)
128 SALOME_LOG_OPTIONAL_PACKAGE(Metis SALOME_MED_PARTITIONER_METIS)
129 ENDIF(SALOME_MED_PARTITIONER_METIS)
130 IF(SALOME_MED_PARTITIONER_SCOTCH)
131 FIND_PACKAGE(SalomeScotch)
132 SALOME_LOG_OPTIONAL_PACKAGE(Scotch SALOME_MED_PARTITIONER_SCOTCH)
133 ENDIF(SALOME_MED_PARTITIONER_SCOTCH)
134 ENDIF(SALOME_MED_ENABLE_PARTITIONER)
135 ENDIF(NOT SALOME_MED_MICROMED)
137 # Find GUI (optional)
140 IF(NOT SALOME_MED_STANDALONE)
141 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
142 IF(EXISTS ${GUI_ROOT_DIR})
143 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
144 FIND_PACKAGE(SalomeGUI REQUIRED)
145 ADD_DEFINITIONS(${GUI_DEFINITIONS})
146 INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
147 ELSE(EXISTS ${GUI_ROOT_DIR})
148 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
149 ENDIF(EXISTS ${GUI_ROOT_DIR})
150 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
151 FIND_PACKAGE(SalomeCAS REQUIRED) # maybe one day it will disappear ...
152 ENDIF(NOT SALOME_MED_STANDALONE)
153 ENDIF(SALOME_BUILD_GUI)
155 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
157 ENABLE_TESTING() # let it outsite because even if SALOME_BUILD_TESTS is OFF, python tests that not need additional compilation can be run.
159 IF(SALOME_BUILD_TESTS)
160 FIND_PACKAGE(SalomeCppUnit)
161 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
162 ENDIF(SALOME_BUILD_TESTS)
165 FIND_PACKAGE(SalomeMPI REQUIRED)
166 IF(SALOME_MED_PARTITIONER_PARMETIS)
167 FIND_PACKAGE(SalomeParMetis)
168 SALOME_LOG_OPTIONAL_PACKAGE(ParMetis SALOME_MED_PARTITIONER_PARMETIS)
169 ENDIF(SALOME_MED_PARTITIONER_PARMETIS)
170 ENDIF(SALOME_USE_MPI)
172 IF(SALOME_MED_ENABLE_RENUMBER)
173 FIND_PACKAGE(SalomeBoost)
174 SALOME_LOG_OPTIONAL_PACKAGE(Boost SALOME_MED_ENABLE_RENUMBER)
175 ENDIF(SALOME_MED_ENABLE_RENUMBER)
178 FIND_PACKAGE(SalomeDoxygen)
179 FIND_PACKAGE(SalomeGraphviz)
180 FIND_PACKAGE(SalomeSphinx)
181 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
182 SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC)
183 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
184 ENDIF(SALOME_BUILD_DOC)
186 IF(SALOME_MED_ENABLE_PYTHON)
187 FIND_PACKAGE(SalomePython)
188 FIND_PACKAGE(SalomeSWIG)
189 SALOME_LOG_OPTIONAL_PACKAGE(Python SALOME_MED_ENABLE_PYTHON)
190 SALOME_LOG_OPTIONAL_PACKAGE(SWIG SALOME_MED_ENABLE_PYTHON)
191 IF(NOT SALOME_MED_STANDALONE)
192 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
193 ENDIF(NOT SALOME_MED_STANDALONE)
194 # Set the extra flags for SWIG for numpy and scipy
195 SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY)
197 SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY "-DWITH_NUMPY")
200 SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY "${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY};-DWITH_SCIPY")
202 ENDIF(SALOME_MED_ENABLE_PYTHON)
205 SALOME_PACKAGE_REPORT_AND_CHECK()
209 # Directories have to be given after prerequisites (to be able to use
210 # Python version string for example).
212 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
213 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
214 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
215 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
216 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
217 "Install path: SALOME scripts")
218 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
219 "Install path: SALOME script data")
220 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
221 "Install path: SALOME Python scripts")
222 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
223 "Install path: SALOME application skeleton - scripts")
224 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
225 "Install path: SALOME application skeleton - Python")
226 SET(SALOME_INSTALL_CMAKE salome_adm/cmake_files CACHE PATH "Install path: SALOME CMake files")
227 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH
228 "Install path: local SALOME CMake files")
230 IF(SALOME_MED_ENABLE_PYTHON)
231 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
232 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
233 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH
234 "Install path: SALOME Python shared modules")
235 ENDIF(SALOME_MED_ENABLE_PYTHON)
237 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
238 SET(SALOME_INSTALL_DOC share/doc/salome CACHE PATH "Install path: SALOME documentation")
242 SET(SALOME_MED_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific data")
243 SET(SALOME_MED_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific scripts")
245 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
246 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
247 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
248 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_MED_INSTALL_RES_DATA SALOME_MED_INSTALL_RES_SCRIPTS SALOME_INSTALL_DOC)
250 # Header configuration
251 # ====================
252 SALOME_XVERSION(${PROJECT_NAME})
253 SALOME_CONFIGURE_FILE(MED_version.h.in MED_version.h INSTALL ${SALOME_INSTALL_HEADERS})
254 SALOME_CONFIGURE_FILE(VERSION.in VERSION INSTALL ${SALOME_INSTALL_BINS})
256 # Accumulate environment variables for MED module
257 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
258 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
259 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
265 ADD_DEFINITIONS("-D_USE_MATH_DEFINES")
268 ADD_SUBDIRECTORY(src)
269 ADD_SUBDIRECTORY(adm_local)
272 ADD_SUBDIRECTORY(doc)
273 ENDIF(SALOME_BUILD_DOC)
275 IF(NOT SALOME_MED_STANDALONE)
276 ADD_SUBDIRECTORY(idl)
277 ELSE(NOT SALOME_MED_STANDALONE)
278 ADD_SUBDIRECTORY(adm_local_without_kernel)
279 ENDIF(NOT SALOME_MED_STANDALONE)
281 IF(NOT SALOME_MED_MICROMED)
282 IF(SALOME_MED_WITH_FILE_EXAMPLES)
283 ADD_SUBDIRECTORY(resources)
284 ENDIF(SALOME_MED_WITH_FILE_EXAMPLES)
285 ENDIF(NOT SALOME_MED_MICROMED)
287 # Configuration export
288 # ====================
289 INCLUDE(CMakePackageConfigHelpers)
291 # List of targets in this project we want to make visible to the rest of the world.
292 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
293 SET(_${PROJECT_NAME}_exposed_targets
294 interpkernel medcoupling medcouplingremapper)
296 IF(NOT SALOME_MED_MICROMED)
297 LIST(APPEND _${PROJECT_NAME}_exposed_targets
300 LIST(APPEND _${PROJECT_NAME}_exposed_targets
302 ENDIF(SALOME_USE_MPI)
303 ENDIF(NOT SALOME_MED_MICROMED)
306 LIST(APPEND _${PROJECT_NAME}_exposed_targets
308 ENDIF(SALOME_USE_MPI)
310 IF(NOT SALOME_MED_STANDALONE)
311 LIST(APPEND _${PROJECT_NAME}_exposed_targets
312 SalomeIDLMED medcouplingcorba )
313 ENDIF(NOT SALOME_MED_STANDALONE)
315 # Add all targets to the build-tree export set
317 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
318 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
320 # Create the configuration files:
321 # - in the build tree:
323 # Ensure the variables are always defined for the configure (even if empty):
324 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
325 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
326 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
327 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
328 SET(HDF5_ROOT_DIR "${HDF5_ROOT_DIR}")
329 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
330 SET(PTHREAD_ROOT_DIR "${PTHREAD_ROOT_DIR}")
331 SET(BOOST_ROOT_DIR "${BOOST_ROOT_DIR}")
332 SET(SWIG_ROOT_DIR "${SWIG_ROOT_DIR}")
333 SET(PYTHON_ROOT_DIR "${PYTHON_ROOT_DIR}")
334 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
335 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
336 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
337 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
339 SET(METIS_ROOT_DIR "${METIS_ROOT_DIR}")
340 SET(PARMETIS_ROOT_DIR "${PARMETIS_ROOT_DIR}")
341 SET(SCOTCH_ROOT_DIR "${SCOTCH_ROOT_DIR}")
342 SET(XDR_ROOT_DIR "${XDR_ROOT_DIR}")
344 # - in the install tree:
345 # Get the relative path of the include directory so
346 # we can register it in the generated configuration files:
347 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
349 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
350 SALOME_CONFIGURE_PREPARE(Metis ParMetis Scotch XDR CAS Qt4 CppUnit Graphviz Doxygen Sphinx MPI omniORB
351 PThread Boost libXml2 Python HDF5 MEDFile)
353 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
354 ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
355 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}_LOCAL"
356 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
357 KERNEL_ROOT_DIR GUI_ROOT_DIR MEDFILE_ROOT_DIR MPI_ROOT_DIR
358 HDF5_ROOT_DIR OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR BOOST_ROOT_DIR
359 SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
360 SPHINX_ROOT_DIR METIS_ROOT_DIR PARMETIS_ROOT_DIR SCOTCH_ROOT_DIR XDR_ROOT_DIR)
362 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
363 VERSION ${${PROJECT_NAME_UC}_VERSION}
364 COMPATIBILITY AnyNewerVersion)
366 # Install the CMake configuration files:
368 "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
369 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
370 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
372 # Install the export set for use with the install-tree
373 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
374 FILE ${PROJECT_NAME}Targets.cmake)