1 # Copyright (C) 2012-2015 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, or (at your option) any later version.
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 INCLUDE(CMakeDependentOption)
22 PROJECT(SalomeMED C CXX)
24 # Ensure a proper linker behavior:
25 CMAKE_POLICY(SET CMP0003 NEW)
29 # Project name, upper case
30 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
32 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
33 SET(${PROJECT_NAME_UC}_MINOR_VERSION 7)
34 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
35 SET(${PROJECT_NAME_UC}_VERSION
36 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
37 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
40 # Kernel detection comes before user options to be
41 # able to take previous values of global options ...
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 KERNEL_WITH_CORBA() #check whether KERNEL builded with CORBA
50 ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
51 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
52 SET(_default_MPI ${SALOME_USE_MPI})
53 ELSE(EXISTS ${KERNEL_ROOT_DIR})
54 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR !")
55 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
56 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
60 INCLUDE(SalomeSetupPlatform)
62 FIND_PACKAGE(SalomePThread REQUIRED) # for MEDCouplingCorba/Test for EDF
63 FIND_PACKAGE(SalomeOmniORB REQUIRED)
67 INCLUDE(CMakeDependentOption)
68 OPTION(SALOME_MED_ENABLE_PYTHON "Build PYTHON bindings." ON)
69 OPTION(SALOME_MED_WITH_FILE_EXAMPLES "Install examples of files containing meshes and fields of different formats." ON)
70 OPTION(SALOME_USE_MPI "(Use MPI containers) - For MED this triggers the build of ParaMEDMEM." ${_default_MPI})
71 OPTION(SALOME_BUILD_GUI "Build GUI of MED." ON)
72 OPTION(SALOME_BUILD_TESTS "Build MED tests." ON)
73 OPTION(SALOME_BUILD_DOC "Build MED doc." ON)
75 # Find MEDCoupling (required)
76 # ==========================
77 SET(MEDCOUPLING_ROOT_DIR $ENV{MEDCOUPLING_ROOT_DIR} CACHE PATH "Path to the MEDCoupling tool")
78 IF(EXISTS ${MEDCOUPLING_ROOT_DIR})
79 LIST(APPEND CMAKE_MODULE_PATH "${MEDCOUPLING_ROOT_DIR}/cmake_files")
80 FIND_PACKAGE(SalomeMEDCoupling REQUIRED) # will reload HDF5, MEDFile, XDR, etc ...
81 ELSE(EXISTS ${MEDCOUPLING_ROOT_DIR})
82 MESSAGE(FATAL_ERROR "We absolutely need the MEDCoupling tool, please define MEDCOUPLING_ROOT_DIR !")
83 ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR})
86 # Set list of prerequisites
87 # =========================
90 FIND_PACKAGE(SalomeXDR REQUIRED)
97 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
98 IF(EXISTS ${GUI_ROOT_DIR})
99 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
100 FIND_PACKAGE(SalomeGUI REQUIRED)
101 SALOME_GUI_WITH_CORBA() #check whether GUI builded with CORBA
102 SALOME_GUI_MODE(SALOME_USE_SALOMEOBJECT SALOME_USE_PYCONSOLE OPTIONAL SALOME_USE_PVVIEWER)
103 ADD_DEFINITIONS(${GUI_DEFINITIONS})
104 INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
105 ELSE(EXISTS ${GUI_ROOT_DIR})
106 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
107 ENDIF(EXISTS ${GUI_ROOT_DIR})
108 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
109 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
111 FIND_PACKAGE(SalomeQt5 REQUIRED)
113 ENDIF(SALOME_BUILD_GUI)
115 IF(SALOME_MED_ENABLE_PYTHON)
116 FIND_PACKAGE(SalomePython)
117 FIND_PACKAGE(SalomeSWIG)
118 SALOME_LOG_OPTIONAL_PACKAGE(Python SALOME_MED_ENABLE_PYTHON)
119 SALOME_LOG_OPTIONAL_PACKAGE(SWIG SALOME_MED_ENABLE_PYTHON)
120 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
121 # Set the extra flags for SWIG for numpy and scipy
122 SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY)
124 SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY "-DWITH_NUMPY")
127 SET(SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY "${SWIG_EXTRA_FLAGS_FOR_NUMPYANDSCIPY};-DWITH_SCIPY")
129 ENDIF(SALOME_MED_ENABLE_PYTHON)
131 IF(SALOME_BUILD_TESTS)
133 FIND_PACKAGE(SalomeCppUnit)
134 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
135 ENDIF(SALOME_BUILD_TESTS)
138 FIND_PACKAGE(SalomeMPI REQUIRED)
139 ADD_DEFINITIONS("-DHAVE_MPI")
140 ENDIF(SALOME_USE_MPI)
143 FIND_PACKAGE(SalomeDoxygen)
144 FIND_PACKAGE(SalomeGraphviz)
145 FIND_PACKAGE(SalomeSphinx)
146 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
147 SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC)
148 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
149 ENDIF(SALOME_BUILD_DOC)
152 SALOME_PACKAGE_REPORT_AND_CHECK()
156 # Directories have to be given after prerequisites (to be able to use
157 # Python version string for example).
159 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
160 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
161 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
162 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
163 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
164 "Install path: SALOME scripts")
165 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
166 "Install path: SALOME script data")
167 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
168 "Install path: SALOME Python scripts")
169 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
170 "Install path: SALOME application skeleton - scripts")
171 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
172 "Install path: SALOME application skeleton - Python")
173 SET(SALOME_INSTALL_CMAKE salome_adm/cmake_files CACHE PATH "Install path: SALOME CMake files")
174 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH
175 "Install path: local SALOME CMake files")
177 IF(SALOME_MED_ENABLE_PYTHON)
178 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
179 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
180 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH
181 "Install path: SALOME Python shared modules")
182 ENDIF(SALOME_MED_ENABLE_PYTHON)
184 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
185 SET(SALOME_INSTALL_DOC share/doc/salome CACHE PATH "Install path: SALOME documentation")
189 SET(SALOME_MED_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific data")
190 SET(SALOME_MED_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific scripts")
192 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
193 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
194 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
195 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_MED_INSTALL_RES_DATA SALOME_MED_INSTALL_RES_SCRIPTS SALOME_INSTALL_DOC)
197 # Header configuration
198 # ====================
199 SALOME_XVERSION(${PROJECT_NAME})
200 SALOME_CONFIGURE_FILE(MED_version.h.in MED_version.h INSTALL ${SALOME_INSTALL_HEADERS})
201 SALOME_CONFIGURE_FILE(VERSION.in VERSION INSTALL ${SALOME_INSTALL_BINS})
203 # Accumulate environment variables for MED module
204 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
205 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
206 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
212 ADD_DEFINITIONS("-D_USE_MATH_DEFINES")
215 ADD_SUBDIRECTORY(src)
216 ADD_SUBDIRECTORY(adm_local)
219 ADD_SUBDIRECTORY(doc)
220 ENDIF(SALOME_BUILD_DOC)
222 ADD_SUBDIRECTORY(idl)
223 ADD_SUBDIRECTORY(resources)
225 # Configuration export
226 # ====================
227 INCLUDE(CMakePackageConfigHelpers)
229 # List of targets in this project we want to make visible to the rest of the world.
230 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
231 SET(_${PROJECT_NAME}_exposed_targets SalomeIDLMED SalomeIDLMEDTests)
234 LIST(APPEND _${PROJECT_NAME}_exposed_targets paramedcouplingcorba paramedmemcompo)
237 LIST(APPEND _${PROJECT_NAME}_exposed_targets
238 medcouplingcorba medcouplingclient medcalculator MEDFactoryEngine)
239 IF(SALOME_MED_ENABLE_PYTHON)
240 LIST(APPEND _${PROJECT_NAME}_exposed_targets medcalculatorspython)
244 LIST(APPEND _${PROJECT_NAME}_exposed_targets MEDCALCGUI_dialogs MEDCALCGUI)
247 # Add all targets to the build-tree export set
249 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
250 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
252 # Create the configuration files:
253 # - in the build tree:
255 # Ensure the variables are always defined for the configure (even if empty):
256 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
257 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
258 SET(MEDCOUPLING_ROOT_DIR "${MEDCOUPLING_ROOT_DIR}")
259 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
260 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
261 SET(PTHREAD_ROOT_DIR "${PTHREAD_ROOT_DIR}")
262 SET(SWIG_ROOT_DIR "${SWIG_ROOT_DIR}")
263 SET(PTHREAD_ROOT_DIR "${SWIG_ROOT_DIR}")
264 SET(PYTHON_ROOT_DIR "${PYTHON_ROOT_DIR}")
265 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
266 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
267 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
268 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
269 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
270 SET(QT_ROOT_DIR "${QT4_ROOT_DIR}")
272 SET(QT_ROOT_DIR "${QT5_ROOT_DIR}")
275 # - in the install tree:
276 # Get the relative path of the include directory so
277 # we can register it in the generated configuration files:
278 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
280 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
281 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
282 SALOME_CONFIGURE_PREPARE(MEDCoupling Qt4 MPI omniORB CppUnit Graphviz Doxygen Sphinx
285 SALOME_CONFIGURE_PREPARE(MEDCoupling Qt5 MPI omniORB CppUnit Graphviz Doxygen Sphinx
289 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
290 ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
291 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
292 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
293 KERNEL_ROOT_DIR GUI_ROOT_DIR MEDCOUPLING_ROOT_DIR QT_ROOT_DIR MPI_ROOT_DIR
294 OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR
295 GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR SPHINX_ROOT_DIR)
297 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
298 VERSION ${${PROJECT_NAME_UC}_VERSION}
299 COMPATIBILITY AnyNewerVersion)
301 # Install the CMake configuration files:
303 "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
304 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
305 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
307 # Install the export set for use with the install-tree
308 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
309 FILE ${PROJECT_NAME}Targets.cmake)