1 # Copyright (C) 2012-2024 CEA, EDF, OPEN CASCADE
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
19 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
20 INCLUDE(CMakeDependentOption)
25 PROJECT(SalomeSMESH C CXX)
27 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
31 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
32 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
33 LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
34 INCLUDE(SalomeMacros NO_POLICY_SCOPE)
36 MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
41 SALOME_SETUP_VERSION(9.12.0)
42 MESSAGE(STATUS "Building ${PROJECT_NAME_UC} ${${PROJECT_NAME_UC}_VERSION} from \"${${PROJECT_NAME_UC}_GIT_SHA1}\"")
46 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
47 IF(EXISTS ${KERNEL_ROOT_DIR})
48 FIND_PACKAGE(SalomeKERNEL REQUIRED)
49 KERNEL_WITH_CORBA() #check whether KERNEL built with CORBA
50 ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
51 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
52 ELSE(EXISTS ${KERNEL_ROOT_DIR})
53 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
54 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
58 INCLUDE(SalomeSetupPlatform) # From KERNEL
59 # Always build libraries as shared objects:
60 SET(BUILD_SHARED_LIBS TRUE)
64 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
65 OPTION(SALOME_BUILD_DOC "Generate SALOME SMESH documentation" ON)
68 OPTION(SALOME_BUILD_GUI "Enable GUI" ON)
69 OPTION(SALOME_SMESH_USE_CGNS "Enable import/export to CGNS format" OFF)
70 OPTION(SALOME_SMESH_USE_TBB "Enable parallel computation" OFF)
71 OPTION(SALOME_SMESH_DYNLOAD_LOCAL "Load plug-ins' symbols locally (Linux only)" ON)
72 OPTION(SMESH_USE_MESHGEMS_HYPOSET "Prefer MeshGems algorithms in sets of hypotheses" OFF)
73 CMAKE_DEPENDENT_OPTION(SALOME_SMESH_BUILD_FRENCH_DOC "Generate SALOME SMESH French documentation" OFF
74 "SALOME_BUILD_DOC" OFF)
76 IF(SALOME_SMESH_DYNLOAD_LOCAL)
77 ADD_DEFINITIONS(-DDYNLOAD_LOCAL)
78 ENDIF(SALOME_SMESH_DYNLOAD_LOCAL)
80 IF(SALOME_USE_64BIT_IDS)
81 SET(SMESH_ID_TYPE "long long")
83 SET(SMESH_ID_TYPE "long")
86 IF(SMESH_USE_MESHGEMS_HYPOSET)
87 SET(SMESH_USE_MESHGEMS_HYPOSET_VAR "true")
88 ELSE(SMESH_USE_MESHGEMS_HYPOSET)
89 SET(SMESH_USE_MESHGEMS_HYPOSET_VAR "false")
90 ENDIF(SMESH_USE_MESHGEMS_HYPOSET)
92 MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_SMESH_USE_CGNS SALOME_SMESH_USE_TBB SALOME_SMESH_DYNLOAD_LOCAL SMESH_USE_MESHGEMS_HYPOSET)
96 # Find "big" prerequisites first - they reference themselves many others
97 # -> this can help finding the smaller prerequisites and detect conflicts.
98 # In our case KERNEL has already loaded many prereq:
106 FIND_PACKAGE(SalomePythonInterp REQUIRED)
107 FIND_PACKAGE(SalomePythonLibs REQUIRED)
109 FIND_PACKAGE(SalomePThread REQUIRED)
111 FIND_PACKAGE(SalomeSWIG REQUIRED)
113 FIND_PACKAGE(SalomeBoost REQUIRED)
115 FIND_PACKAGE(SalomeOmniORB REQUIRED)
116 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
118 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
120 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
122 # Other KERNEL optionals:
123 IF(SALOME_BUILD_TESTS)
125 FIND_PACKAGE(SalomeCppUnit)
126 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
129 FIND_PACKAGE(SalomeDoxygen)
130 FIND_PACKAGE(SalomeSphinx)
132 SPHINX_CHECK_EXTENSIONS(sphinx_rtd_theme)
133 IF(SPHINX_VERSION VERSION_LESS "1.3")
134 SPHINX_CHECK_EXTENSIONS(sphinxcontrib.napoleon)
136 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
137 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
142 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
143 IF(EXISTS ${GUI_ROOT_DIR})
144 FIND_PACKAGE(SalomeGUI)
145 SALOME_GUI_WITH_CORBA() #check whether GUI built with CORBA
146 SALOME_GUI_MODE(SALOME_USE_VTKVIEWER SALOME_USE_SALOMEOBJECT
147 OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_PYCONSOLE)
149 ## Prerequisites From GUI:
152 FIND_PACKAGE(SalomeQt5 REQUIRED)
154 FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt5
156 FIND_PACKAGE(SalomePyQt5 REQUIRED)
158 FIND_PACKAGE(SalomeQwt REQUIRED)
159 ELSE(EXISTS ${GUI_ROOT_DIR})
160 MESSAGE(FATAL_ERROR "GUI_ROOT_DIR is not well defined, SMESH will be built without GUI!!!")
161 ENDIF(EXISTS ${GUI_ROOT_DIR})
162 SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
163 ENDIF(SALOME_BUILD_GUI)
167 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
168 IF(EXISTS ${GEOM_ROOT_DIR})
169 FIND_PACKAGE(SalomeGEOM REQUIRED)
170 ADD_DEFINITIONS(${GEOM_DEFINITIONS})
171 INCLUDE_DIRECTORIES(${GEOM_INCLUDE_DIRS})
173 IF(NOT SALOME_GEOM_BUILD_GUI)
174 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM with GUI, please set SALOME_BUILD_GUI=ON in GEOM module")
175 ENDIF(NOT SALOME_GEOM_BUILD_GUI)
176 ENDIF(SALOME_BUILD_GUI)
177 ELSE(EXISTS ${GEOM_ROOT_DIR})
178 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR")
179 ENDIF(EXISTS ${GEOM_ROOT_DIR})
183 SET(WITH_SHAPER_STUDY OFF)
184 SET(SHAPERSTUDY_ROOT_DIR $ENV{SHAPERSTUDY_ROOT_DIR} CACHE PATH "Path to the Salome SHAPERSTUDY")
185 IF(EXISTS ${SHAPERSTUDY_ROOT_DIR})
186 FIND_PACKAGE(SalomeSHAPERSTUDY)
187 IF(SalomeSHAPERSTUDY_FOUND)
188 SET(WITH_SHAPER_STUDY ON)
190 ENDIF(EXISTS ${SHAPERSTUDY_ROOT_DIR})
191 IF(NOT WITH_SHAPER_STUDY AND SALOME_BUILD_TESTS)
192 MESSAGE(WARNING "SHAPERSTUDY is not found; the corresponding tests will be omitted")
197 SET(MEDCOUPLING_ROOT_DIR $ENV{MEDCOUPLING_ROOT_DIR} CACHE PATH "Path to the MEDCoupling tool")
198 IF(EXISTS ${MEDCOUPLING_ROOT_DIR})
199 FIND_PACKAGE(SalomeMEDCoupling REQUIRED) # will reload HDF5, MEDFile, XDR, etc ...
200 ELSE(EXISTS ${MEDCOUPLING_ROOT_DIR})
201 MESSAGE(FATAL_ERROR "We absolutely need the MEDCoupling tool, please define MEDCOUPLING_ROOT_DIR !")
202 ENDIF(EXISTS ${MEDCOUPLING_ROOT_DIR})
208 # VTK is obligatiry for the SMESH
209 FIND_PACKAGE(SalomeVTK REQUIRED)
211 FIND_PACKAGE(SalomeOpenCASCADE REQUIRED)
213 IF(SALOME_SMESH_USE_CGNS)
214 FIND_PACKAGE(SalomeCGNS)
215 SALOME_LOG_OPTIONAL_PACKAGE(CGNS SALOME_SMESH_USE_CGNS)
216 ADD_DEFINITIONS(-DWITH_CGNS)
217 ENDIF(SALOME_SMESH_USE_CGNS)
219 IF(SALOME_SMESH_USE_TBB)
220 FIND_PACKAGE(SalomeTBB)
221 SALOME_LOG_OPTIONAL_PACKAGE(TBB SALOME_SMESH_USE_TBB)
222 ADD_DEFINITIONS(-DWITH_TBB)
223 ENDIF(SALOME_SMESH_USE_TBB)
225 FIND_PACKAGE(SalomeMEDFile REQUIRED)
228 SET (SALOME_SMESH_DISABLE_MG_ADAPT OFF)
229 SET (SALOME_SMESH_DISABLE_HOMARD_ADAPT OFF)
231 # On Windows temporarily disable MG_ADAPT
232 SET (SALOME_SMESH_DISABLE_MG_ADAPT ON)
233 SET (SALOME_SMESH_DISABLE_HOMARD_ADAPT ON)
235 IF(SALOME_SMESH_DISABLE_MG_ADAPT)
236 ADD_DEFINITIONS(-DDISABLE_MG_ADAPT)
239 IF(SALOME_SMESH_DISABLE_HOMARD_ADAPT)
240 ADD_DEFINITIONS(-DDISABLE_HOMARD_ADAPT)
245 SALOME_PACKAGE_REPORT_AND_CHECK()
248 # (default values taken from KERNEL)
250 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
251 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
252 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
253 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
254 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
255 "Install path: SALOME scripts")
256 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
257 "Install path: SALOME script data")
258 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
259 "Install path: SALOME Python scripts")
260 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH
261 "Install path: SALOME application skeleton - scripts")
262 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH
263 "Install path: SALOME application skeleton - Python")
264 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
265 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
266 "Install path: SALOME Python shared modules")
267 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH
268 "Install path: local SALOME CMake files")
269 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
270 "Install path: local SALOME config files (obsolete, to be removed)")
271 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
272 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
275 SET(SALOME_SMESH_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/smesh" CACHE PATH
276 "Install path: SALOME SMESH specific data")
277 SET(SALOME_SMESH_INSTALL_PLUGINS share/salome/plugins/smesh CACHE PATH
278 "Install path: SALOME SMESH plugins")
280 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
281 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
282 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
283 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
284 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
285 MARK_AS_ADVANCED(SALOME_SMESH_INSTALL_RES_DATA SALOME_SMESH_INSTALL_PLUGINS)
287 # Accumulate environment variables for SMESH module
288 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
289 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
290 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
291 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
296 SET(SMESH_TEST_DIR ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test)
297 IF(SALOME_BUILD_TESTS)
298 CONFIGURE_FILE(CTestTestfileInstall.cmake.in CTestTestfileInstall.cmake @ONLY)
299 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileInstall.cmake
300 DESTINATION ${SMESH_TEST_DIR}
301 RENAME CTestTestfile.cmake)
307 ADD_SUBDIRECTORY(idl)
308 ADD_SUBDIRECTORY(adm_local)
309 ADD_SUBDIRECTORY(resources)
310 ADD_SUBDIRECTORY(bin)
311 ADD_SUBDIRECTORY(src)
312 ADD_SUBDIRECTORY(doc)
313 IF(SALOME_BUILD_TESTS)
314 ADD_SUBDIRECTORY(test)
317 # Header configuration
318 # ====================
319 SALOME_CONFIGURE_FILE(SMESH_version.h.in SMESH_version.h INSTALL ${SALOME_INSTALL_HEADERS})
321 # Configuration export
322 # (here only the level 1 prerequisites are exposed)
323 # ====================
324 INCLUDE(CMakePackageConfigHelpers)
326 # List of targets in this project we want to make visible to the rest of the world.
327 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
328 SET(_${PROJECT_NAME}_exposed_targets
329 SMESHControls MeshDriver MeshDriverDAT MeshDriverGMF MeshDriverMED
330 MeshDriverSTL MeshDriverUNV MEDWrapper
331 SMDS SMESHimpl SMESHEngine SMESHClient SMESHDS
332 SMESHUtils StdMeshers StdMeshersEngine MeshJobManagerEngine
333 SPADDERPluginTesterEngine SalomeIDLSMESH SalomeIDLSPADDER
337 LIST(APPEND _${PROJECT_NAME}_exposed_targets
338 SMESHObject SMESHFiltersSelection SMESH PluginUtils StdMeshersGUI
340 ENDIF(SALOME_BUILD_GUI)
342 IF(SALOME_SMESH_USE_CGNS)
343 LIST(APPEND _${PROJECT_NAME}_exposed_targets
346 ENDIF(SALOME_SMESH_USE_CGNS)
348 # Add all targets to the build-tree export set
349 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
350 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
352 # Create the configuration files:
353 # - in the build tree:
355 # Ensure the variables are always defined for the configure:
356 SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}")
357 SET(MEDCOUPLING_ROOT_DIR "${MEDCOUPLING_ROOT_DIR}")
358 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
359 SET(CGNS_ROOT_DIR "${CGNS_ROOT_DIR}")
360 SET(TBB_ROOT_DIR "${TBB_ROOT_DIR}")
362 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
364 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
365 SALOME_CONFIGURE_PREPARE(MEDCoupling CGNS TBB MEDFile)
367 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
368 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
369 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
370 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
371 GEOM_ROOT_DIR MEDCOUPLING_ROOT_DIR MEDFILE_ROOT_DIR CGNS_ROOT_DIR TBB_ROOT_DIR)
373 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
374 VERSION ${${PROJECT_NAME_UC}_VERSION}
375 COMPATIBILITY AnyNewerVersion)
377 # Install the CMake configuration files:
379 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
380 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
381 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
383 # Install the export set for use with the install-tree
384 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
385 FILE ${PROJECT_NAME}Targets.cmake)