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 ...
49 IF(NOT SALOME_MED_STANDALONE)
50 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
51 IF(EXISTS ${KERNEL_ROOT_DIR})
52 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
54 FIND_PACKAGE(SalomeKERNEL REQUIRED)
55 ELSE(EXISTS ${KERNEL_ROOT_DIR})
56 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_MED_STANDALONE to ON !")
57 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
58 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
59 FIND_PACKAGE(SalomePThread REQUIRED) # for MEDCouplingCorba/Test for EDF
60 FIND_PACKAGE(SalomeOmniORB REQUIRED)
61 ELSE(NOT SALOME_MED_STANDALONE)
62 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local_without_kernel/cmake_files")
64 ENDIF(NOT SALOME_MED_STANDALONE)
69 INCLUDE(CMakeDependentOption)
70 OPTION(SALOME_MED_STANDALONE "Build MED without CORBA bindings. When OFF, exchange to PARAVIS is disabled." OFF)
71 OPTION(SALOME_MED_MICROMED "Build MED without MED file dependancy." OFF)
72 OPTION(SALOME_MED_ENABLE_PYTHON "Build PYTHON bindings." ON)
73 OPTION(SALOME_MED_ENABLE_PARTITIONER "Build MEDPartitioner." ON)
74 OPTION(SALOME_MED_ENABLE_RENUMBER "Build Renumber." ON)
75 OPTION(SALOME_USE_MPI "To build ParaMEDMEM." OFF)
76 OPTION(SALOME_BUILD_GUI "Build GUI of MED." ON)
77 OPTION(SALOME_BUILD_TESTS "Build MED tests." ON)
78 OPTION(SALOME_BUILD_DOC "Build MED doc." ON)
79 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_METIS "Enable metis graph librarie in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;NOT SALOME_USE_MPI" OFF)
80 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_SCOTCH "Enable scotch graph librarie in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;NOT SALOME_USE_MPI" OFF)
81 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_PARMETIS "Enable parmetis graph librarie in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;SALOME_USE_MPI" OFF)
85 # Set list of prerequisites
86 # =========================
88 IF(NOT SALOME_MED_STANDALONE)
89 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
90 IF(EXISTS ${KERNEL_ROOT_DIR})
91 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
93 FIND_PACKAGE(SalomeKERNEL REQUIRED)
94 ELSE(EXISTS ${KERNEL_ROOT_DIR})
95 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_MED_STANDALONE to ON !")
96 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
97 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
98 FIND_PACKAGE(SalomeOmniORB REQUIRED)
99 ELSE(NOT SALOME_MED_STANDALONE)
100 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local_without_kernel/cmake_files")
101 INCLUDE(SalomeMacros)
102 ENDIF(NOT SALOME_MED_STANDALONE)
104 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
106 IF(NOT SALOME_MED_MICROMED)
107 FIND_PACKAGE(SalomeHDF5 REQUIRED)
108 FIND_PACKAGE(SalomeMEDFile REQUIRED)
109 IF(SALOME_MED_ENABLE_PARTITIONER)
110 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
111 IF(SALOME_MED_PARTITIONER_METIS)
112 FIND_PACKAGE(SalomeMetis REQUIRED)
113 ENDIF(SALOME_MED_PARTITIONER_METIS)
114 IF(SALOME_MED_PARTITIONER_SCOTCH)
115 FIND_PACKAGE(SalomeScotch REQUIRED)
116 ENDIF(SALOME_MED_PARTITIONER_SCOTCH)
117 ENDIF(SALOME_MED_ENABLE_PARTITIONER)
118 ENDIF(NOT SALOME_MED_MICROMED)
121 IF(NOT SALOME_MED_STANDALONE)
122 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
123 IF(EXISTS ${GUI_ROOT_DIR})
124 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
125 FIND_PACKAGE(SalomeGUI REQUIRED)
126 ELSE(EXISTS ${GUI_ROOT_DIR})
127 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
128 ENDIF(EXISTS ${GUI_ROOT_DIR})
129 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
130 FIND_PACKAGE(SalomeCAS REQUIRED) # maybe one day it will disappear ...
131 ENDIF(NOT SALOME_MED_STANDALONE)
132 ENDIF(SALOME_BUILD_GUI)
134 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
136 IF(SALOME_BUILD_TESTS)
138 FIND_PACKAGE(SalomeCppUnit REQUIRED)
139 ENDIF(SALOME_BUILD_TESTS)
142 FIND_PACKAGE(SalomeMPI REQUIRED)
143 IF(SALOME_MED_PARTITIONER_PARMETIS)
144 FIND_PACKAGE(SalomeParMetis REQUIRED)
145 ENDIF(SALOME_MED_PARTITIONER_PARMETIS)
146 ENDIF(SALOME_USE_MPI)
148 IF(SALOME_MED_ENABLE_RENUMBER)
149 FIND_PACKAGE(SalomeBoost)
150 ENDIF(SALOME_MED_ENABLE_RENUMBER)
153 FIND_PACKAGE(SalomeDoxygen REQUIRED)
154 FIND_PACKAGE(SalomeGraphviz) # Remains optional even here.
155 FIND_PACKAGE(SalomeSphinx REQUIRED)
156 ENDIF(SALOME_BUILD_DOC)
158 IF(SALOME_MED_ENABLE_PYTHON)
159 FIND_PACKAGE(SalomePython REQUIRED)
160 FIND_PACKAGE(SalomeSWIG REQUIRED)
161 IF(NOT SALOME_MED_STANDALONE)
162 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
163 ENDIF(NOT SALOME_MED_STANDALONE)
164 ENDIF(SALOME_MED_ENABLE_PYTHON)
168 # Directories have to be given after prerequisites (to be able to use
169 # Python version string for example).
171 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
172 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
173 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
174 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
175 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
176 "Install path: SALOME scripts")
177 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
178 "Install path: SALOME script data")
179 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
180 "Install path: SALOME Python scripts")
181 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
182 "Install path: SALOME application skeleton - scripts")
183 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
184 "Install path: SALOME application skeleton - Python")
185 SET(SALOME_INSTALL_CMAKE adm_local/cmake_files CACHE PATH "Install path: SALOME CMake files")
186 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH
187 "Install path: local SALOME CMake files")
189 IF(SALOME_MED_ENABLE_PYTHON)
190 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
191 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
192 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH
193 "Install path: SALOME Python shared modules")
194 ENDIF(SALOME_MED_ENABLE_PYTHON)
196 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
200 SET(SALOME_MED_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific data")
201 SET(SALOME_MED_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific scripts")
203 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
204 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
205 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
206 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_MED_INSTALL_RES_DATA SALOME_MED_INSTALL_RES_SCRIPTS)
208 # Configuration of MED_version.h.in
210 SET(input ${PROJECT_SOURCE_DIR}/MED_version.h.in)
211 SET(output ${PROJECT_BINARY_DIR}/MED_version.h)
212 MESSAGE(STATUS "Creation of ${output}")
213 CONFIGURE_FILE(${input} ${output} @ONLY)
214 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/MED_version.h DESTINATION ${SALOME_INSTALL_HEADERS})
219 ADD_DEFINITIONS("-D_USE_MATH_DEFINES")
222 ADD_SUBDIRECTORY(src)
223 ADD_SUBDIRECTORY(bin)
224 ADD_SUBDIRECTORY(adm_local)
227 ADD_SUBDIRECTORY(doc)
228 ENDIF(SALOME_BUILD_DOC)
230 IF(NOT SALOME_MED_STANDALONE)
231 ADD_SUBDIRECTORY(idl)
232 ELSE(NOT SALOME_MED_STANDALONE)
233 ADD_SUBDIRECTORY(adm_local_without_kernel)
234 ENDIF(NOT SALOME_MED_STANDALONE)
236 IF(NOT SALOME_MED_MICROMED)
237 ADD_SUBDIRECTORY(resources)
238 ENDIF(NOT SALOME_MED_MICROMED)
240 # Configuration export
241 # ====================
242 INCLUDE(CMakePackageConfigHelpers)
244 # List of targets in this project we want to make visible to the rest of the world.
245 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
246 SET(_${PROJECT_NAME}_exposed_targets
247 interpkernel medcoupling medcouplingremapper)
249 IF(NOT SALOME_MED_MICROMED)
250 LIST(APPEND _${PROJECT_NAME}_exposed_targets
253 LIST(APPEND _${PROJECT_NAME}_exposed_targets
255 ENDIF(SALOME_USE_MPI)
256 ENDIF(NOT SALOME_MED_MICROMED)
259 LIST(APPEND _${PROJECT_NAME}_exposed_targets
261 ENDIF(SALOME_USE_MPI)
263 IF(NOT SALOME_MED_STANDALONE)
264 LIST(APPEND _${PROJECT_NAME}_exposed_targets
265 SalomeIDLMED medcouplingcorba )
266 ENDIF(NOT SALOME_MED_STANDALONE)
268 # Add all targets to the build-tree export set
270 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
271 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
273 # Create the configuration files:
274 # - in the build tree:
276 # Ensure the variables are always defined for the configure (even if empty):
277 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
278 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
279 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
280 SET(HDF5_ROOT_DIR "${HDF5_ROOT_DIR}")
281 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
282 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
283 SET(PTHREAD_ROOT_DIR "${PTHREAD_ROOT_DIR}")
284 SET(SWIG_ROOT_DIR "${SWIG_ROOT_DIR}")
285 SET(PYTHON_ROOT_DIR "${PYTHON_ROOT_DIR}")
286 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
287 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
288 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
289 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
291 # - in the install tree:
292 # Get the relative path of the include directory so
293 # we can register it in the generated configuration files:
294 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
295 CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
296 ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
297 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
298 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
299 KERNEL_ROOT_DIR GUI_ROOT_DIR MEDFILE_ROOT_DIR
300 HDF5_ROOT_DIR OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR
301 SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
304 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
305 VERSION ${${PROJECT_NAME_UC}_VERSION}
306 COMPATIBILITY AnyNewerVersion)
308 # Install the CMake configuration files:
310 "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
311 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
312 DESTINATION "${SALOME_INSTALL_CMAKE}")
314 # Install the export set for use with the install-tree
315 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}"
316 FILE ${PROJECT_NAME}Targets.cmake)