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
21 # INCLUDE(${PROJECT_SOURCE_DIR}/adm_local/cmake_files/FindXDR.cmake)
24 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
25 PROJECT(SalomeMED C CXX)
27 # Ensure a proper linker behavior:
28 CMAKE_POLICY(SET CMP0003 NEW)
32 # Project name, upper case
33 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
35 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
36 SET(${PROJECT_NAME_UC}_MINOR_VERSION 2)
37 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
38 SET(${PROJECT_NAME_UC}_VERSION
39 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
40 # Temporary backward compatibility:
41 SET(VERSION ${${PROJECT_NAME_UC}_VERSION})
42 SET(XVERSION 0x0${${PROJECT_NAME_UC}_MAJOR_VERSION}0${${PROJECT_NAME_UC}_MINOR_VERSION}0${${PROJECT_NAME_UC}_PATCH_VERSION})
46 # Kernel detection comes before user options to be
47 # able to take previous values of SALOME_USE_MPI, SALOME_BUILD_DOC, etc ...
50 IF(NOT SALOME_MED_STANDALONE)
51 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
52 IF(EXISTS ${KERNEL_ROOT_DIR})
53 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
55 FIND_PACKAGE(SalomeKERNEL REQUIRED)
56 ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
57 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
58 SET(_default_MPI ${SALOME_USE_MPI})
59 ELSE(EXISTS ${KERNEL_ROOT_DIR})
60 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_MED_STANDALONE to ON !")
61 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
62 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
63 FIND_PACKAGE(SalomePThread REQUIRED) # for MEDCouplingCorba/Test for EDF
64 FIND_PACKAGE(SalomeOmniORB REQUIRED)
65 ELSE(NOT SALOME_MED_STANDALONE)
66 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local_without_kernel/cmake_files")
68 ENDIF(NOT SALOME_MED_STANDALONE)
73 INCLUDE(CMakeDependentOption)
74 OPTION(SALOME_MED_STANDALONE "Build MED without CORBA bindings. When OFF, exchange to PARAVIS is disabled." OFF)
75 OPTION(SALOME_MED_MICROMED "Build MED without MED file dependancy." OFF)
76 OPTION(SALOME_MED_ENABLE_PYTHON "Build PYTHON bindings." ON)
77 OPTION(SALOME_MED_ENABLE_PARTITIONER "Build MEDPartitioner." ON)
78 OPTION(SALOME_MED_ENABLE_RENUMBER "Build Renumber." 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)
88 # Set list of prerequisites
89 # =========================
91 IF(NOT SALOME_MED_STANDALONE)
92 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
93 IF(EXISTS ${KERNEL_ROOT_DIR})
94 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
96 FIND_PACKAGE(SalomeKERNEL REQUIRED)
97 ELSE(EXISTS ${KERNEL_ROOT_DIR})
98 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_MED_STANDALONE to ON !")
99 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
100 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
101 FIND_PACKAGE(SalomeOmniORB REQUIRED)
102 ELSE(NOT SALOME_MED_STANDALONE)
103 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local_without_kernel/cmake_files")
104 INCLUDE(SalomeMacros)
105 ENDIF(NOT SALOME_MED_STANDALONE)
107 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
111 INCLUDE(SalomeSetupPlatform)
113 IF(NOT SALOME_MED_MICROMED)
114 FIND_PACKAGE(SalomeHDF5 REQUIRED)
115 FIND_PACKAGE(SalomeMEDFile REQUIRED)
116 IF(SALOME_MED_ENABLE_PARTITIONER)
117 FIND_PACKAGE(SalomeLibXml2)
118 SALOME_LOG_OPTIONAL_PACKAGE(LibXml2 SALOME_MED_ENABLE_PARTITIONER)
119 IF(SALOME_MED_PARTITIONER_METIS)
120 FIND_PACKAGE(SalomeMetis)
121 SALOME_LOG_OPTIONAL_PACKAGE(Metis SALOME_MED_PARTITIONER_METIS)
122 ENDIF(SALOME_MED_PARTITIONER_METIS)
123 IF(SALOME_MED_PARTITIONER_SCOTCH)
124 FIND_PACKAGE(SalomeScotch)
125 SALOME_LOG_OPTIONAL_PACKAGE(Scotch SALOME_MED_PARTITIONER_SCOTCH)
126 ENDIF(SALOME_MED_PARTITIONER_SCOTCH)
127 ENDIF(SALOME_MED_ENABLE_PARTITIONER)
128 ENDIF(NOT SALOME_MED_MICROMED)
131 IF(NOT SALOME_MED_STANDALONE)
132 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
133 IF(EXISTS ${GUI_ROOT_DIR})
134 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
135 FIND_PACKAGE(SalomeGUI REQUIRED)
136 ELSE(EXISTS ${GUI_ROOT_DIR})
137 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
138 ENDIF(EXISTS ${GUI_ROOT_DIR})
139 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
140 FIND_PACKAGE(SalomeCAS REQUIRED) # maybe one day it will disappear ...
141 ENDIF(NOT SALOME_MED_STANDALONE)
142 ENDIF(SALOME_BUILD_GUI)
144 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
146 ENABLE_TESTING() # let it outsite because even if SALOME_BUILD_TESTS is OFF, python tests that not need additional compilation can be run.
148 IF(SALOME_BUILD_TESTS)
149 FIND_PACKAGE(SalomeCppUnit)
150 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
151 ENDIF(SALOME_BUILD_TESTS)
154 FIND_PACKAGE(SalomeMPI REQUIRED)
155 IF(SALOME_MED_PARTITIONER_PARMETIS)
156 FIND_PACKAGE(SalomeParMetis)
157 SALOME_LOG_OPTIONAL_PACKAGE(ParMetis SALOME_MED_PARTITIONER_PARMETIS)
158 ENDIF(SALOME_MED_PARTITIONER_PARMETIS)
159 ENDIF(SALOME_USE_MPI)
161 IF(SALOME_MED_ENABLE_RENUMBER)
162 FIND_PACKAGE(SalomeBoost)
163 SALOME_LOG_OPTIONAL_PACKAGE(Boost SALOME_MED_ENABLE_RENUMBER)
164 ENDIF(SALOME_MED_ENABLE_RENUMBER)
167 FIND_PACKAGE(SalomeDoxygen)
168 FIND_PACKAGE(SalomeGraphviz)
169 FIND_PACKAGE(SalomeSphinx)
170 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
171 SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC)
172 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
173 ENDIF(SALOME_BUILD_DOC)
175 IF(SALOME_MED_ENABLE_PYTHON)
176 FIND_PACKAGE(SalomePython)
177 FIND_PACKAGE(SalomeSWIG)
178 SALOME_LOG_OPTIONAL_PACKAGE(Python SALOME_MED_ENABLE_PYTHON)
179 SALOME_LOG_OPTIONAL_PACKAGE(SWIG SALOME_MED_ENABLE_PYTHON)
180 IF(NOT SALOME_MED_STANDALONE)
181 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
182 ENDIF(NOT SALOME_MED_STANDALONE)
183 ENDIF(SALOME_MED_ENABLE_PYTHON)
186 SALOME_PACKAGE_REPORT_AND_CHECK()
190 # Directories have to be given after prerequisites (to be able to use
191 # Python version string for example).
193 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
194 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
195 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
196 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
197 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
198 "Install path: SALOME scripts")
199 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
200 "Install path: SALOME script data")
201 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
202 "Install path: SALOME Python scripts")
203 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
204 "Install path: SALOME application skeleton - scripts")
205 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
206 "Install path: SALOME application skeleton - Python")
207 SET(SALOME_INSTALL_CMAKE salome_adm/cmake_files CACHE PATH "Install path: SALOME CMake files")
208 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH
209 "Install path: local SALOME CMake files")
211 IF(SALOME_MED_ENABLE_PYTHON)
212 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
213 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
214 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH
215 "Install path: SALOME Python shared modules")
216 ENDIF(SALOME_MED_ENABLE_PYTHON)
218 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
222 SET(SALOME_MED_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific data")
223 SET(SALOME_MED_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific scripts")
225 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
226 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
227 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
228 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_MED_INSTALL_RES_DATA SALOME_MED_INSTALL_RES_SCRIPTS)
230 # Configuration of MED_version.h.in
232 SET(input ${PROJECT_SOURCE_DIR}/MED_version.h.in)
233 SET(output ${PROJECT_BINARY_DIR}/MED_version.h)
234 MESSAGE(STATUS "Creation of ${output}")
235 CONFIGURE_FILE(${input} ${output} @ONLY)
236 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/MED_version.h DESTINATION ${SALOME_INSTALL_HEADERS})
241 ADD_DEFINITIONS("-D_USE_MATH_DEFINES")
244 ADD_SUBDIRECTORY(src)
245 ADD_SUBDIRECTORY(bin)
246 ADD_SUBDIRECTORY(adm_local)
249 ADD_SUBDIRECTORY(doc)
250 ENDIF(SALOME_BUILD_DOC)
252 IF(NOT SALOME_MED_STANDALONE)
253 ADD_SUBDIRECTORY(idl)
254 ELSE(NOT SALOME_MED_STANDALONE)
255 ADD_SUBDIRECTORY(adm_local_without_kernel)
256 ENDIF(NOT SALOME_MED_STANDALONE)
258 IF(NOT SALOME_MED_MICROMED)
259 ADD_SUBDIRECTORY(resources)
260 ENDIF(NOT SALOME_MED_MICROMED)
262 # Configuration export
263 # ====================
264 INCLUDE(CMakePackageConfigHelpers)
266 # List of targets in this project we want to make visible to the rest of the world.
267 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
268 SET(_${PROJECT_NAME}_exposed_targets
269 interpkernel medcoupling medcouplingremapper)
271 IF(NOT SALOME_MED_MICROMED)
272 LIST(APPEND _${PROJECT_NAME}_exposed_targets
275 LIST(APPEND _${PROJECT_NAME}_exposed_targets
277 ENDIF(SALOME_USE_MPI)
278 ENDIF(NOT SALOME_MED_MICROMED)
281 LIST(APPEND _${PROJECT_NAME}_exposed_targets
283 ENDIF(SALOME_USE_MPI)
285 IF(NOT SALOME_MED_STANDALONE)
286 LIST(APPEND _${PROJECT_NAME}_exposed_targets
287 SalomeIDLMED medcouplingcorba )
288 ENDIF(NOT SALOME_MED_STANDALONE)
290 # Add all targets to the build-tree export set
292 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
293 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
295 # Create the configuration files:
296 # - in the build tree:
298 # Ensure the variables are always defined for the configure (even if empty):
299 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
300 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
301 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
302 SET(HDF5_ROOT_DIR "${HDF5_ROOT_DIR}")
303 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
304 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
305 SET(PTHREAD_ROOT_DIR "${PTHREAD_ROOT_DIR}")
306 SET(SWIG_ROOT_DIR "${SWIG_ROOT_DIR}")
307 SET(PYTHON_ROOT_DIR "${PYTHON_ROOT_DIR}")
308 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
309 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
310 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
311 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
313 # - in the install tree:
314 # Get the relative path of the include directory so
315 # we can register it in the generated configuration files:
316 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
317 CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
318 ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
319 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}_LOCAL"
320 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
321 KERNEL_ROOT_DIR GUI_ROOT_DIR MEDFILE_ROOT_DIR
322 HDF5_ROOT_DIR OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR
323 SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
326 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
327 VERSION ${${PROJECT_NAME_UC}_VERSION}
328 COMPATIBILITY AnyNewerVersion)
330 # Install the CMake configuration files:
332 "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
333 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
334 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
336 # Install the export set for use with the install-tree
337 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
338 FILE ${PROJECT_NAME}Targets.cmake)