1 # Copyright (C) 2012-2016 CEA/DEN, EDF R&D, 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 PROJECT(SalomeSMESH C CXX)
22 # Ensure a proper linker behavior:
23 CMAKE_POLICY(SET CMP0003 NEW)
25 CMAKE_POLICY(SET CMP0020 OLD) # disable automatic linking to qtmain.lib
30 # Project name, upper case
31 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
33 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 8)
34 SET(${PROJECT_NAME_UC}_MINOR_VERSION 2)
35 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
36 SET(${PROJECT_NAME_UC}_VERSION
37 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
38 SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
42 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
43 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
44 LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
47 MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
52 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
53 IF(EXISTS ${KERNEL_ROOT_DIR})
54 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
55 FIND_PACKAGE(SalomeKERNEL REQUIRED)
56 KERNEL_WITH_CORBA() #check whether KERNEL builded with CORBA
57 ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
58 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
59 ELSE(EXISTS ${KERNEL_ROOT_DIR})
60 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
61 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
65 INCLUDE(SalomeSetupPlatform) # From KERNEL
66 # Always build libraries as shared objects:
67 SET(BUILD_SHARED_LIBS TRUE)
69 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
73 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
74 OPTION(SALOME_BUILD_DOC "Generate SALOME SMESH documentation" ON)
77 OPTION(SALOME_BUILD_GUI "Enable GUI" ON)
78 OPTION(SALOME_SMESH_USE_CGNS "Enable import/export to CGNS format" OFF)
79 OPTION(SALOME_SMESH_USE_TBB "Enable parallel computation" OFF)
81 #On Linux use Fortran to compile MEFISTO2D
83 ENABLE_LANGUAGE(Fortran)
84 SET(SALOME_SMESH_ENABLE_MEFISTO ON)
85 ADD_DEFINITIONS(-DENABLE_MEFISTO)
88 MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_SMESH_USE_CGNS SALOME_SMESH_USE_TBB)
92 # Find "big" prerequisites first - they reference themselves many others
93 # -> this can help finding the smaller prerequisites and detect conficts.
94 # In our case KERNEL has already loaded many prereq:
102 FIND_PACKAGE(SalomePythonInterp REQUIRED)
103 FIND_PACKAGE(SalomePythonLibs REQUIRED)
105 FIND_PACKAGE(SalomePThread REQUIRED)
107 FIND_PACKAGE(SalomeSWIG REQUIRED)
109 FIND_PACKAGE(SalomeBoost REQUIRED)
111 FIND_PACKAGE(SalomeOmniORB REQUIRED)
112 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
114 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
116 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
118 # Other KERNEL optionals:
119 IF(SALOME_BUILD_TESTS)
121 FIND_PACKAGE(SalomeCppUnit)
122 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
125 FIND_PACKAGE(SalomeDoxygen)
126 FIND_PACKAGE(SalomeSphinx)
127 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
128 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
133 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
134 IF(EXISTS ${GUI_ROOT_DIR})
135 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
136 FIND_PACKAGE(SalomeGUI)
137 SALOME_GUI_WITH_CORBA() #check whether GUI builded with CORBA
138 SALOME_GUI_MODE(SALOME_USE_VTKVIEWER SALOME_USE_SALOMEOBJECT
139 OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_PYCONSOLE)
141 ## Prerequisites From GUI:
144 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
145 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml)
147 FIND_PACKAGE(SalomeQt5 REQUIRED)
150 FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt5
152 IF (NOT SALOME_GUI_BUILD_WITH_QT5)
153 FIND_PACKAGE(SalomePyQt4 REQUIRED)
155 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 LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
170 FIND_PACKAGE(SalomeGEOM REQUIRED)
171 ADD_DEFINITIONS(${GEOM_DEFINITIONS})
172 INCLUDE_DIRECTORIES(${GEOM_INCLUDE_DIRS})
174 IF(NOT SALOME_GEOM_BUILD_GUI)
175 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM with GUI, please set SALOME_BUILD_GUI=ON in GEOM module")
176 ENDIF(NOT SALOME_GEOM_BUILD_GUI)
177 ENDIF(SALOME_BUILD_GUI)
178 ELSE(EXISTS ${GEOM_ROOT_DIR})
179 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR")
180 ENDIF(EXISTS ${GEOM_ROOT_DIR})
186 # VTK is obligatiry for the SMESH
187 FIND_PACKAGE(SalomeVTK REQUIRED)
189 FIND_PACKAGE(SalomeCAS REQUIRED)
191 IF(SALOME_SMESH_USE_CGNS)
192 FIND_PACKAGE(SalomeCGNS)
193 SALOME_LOG_OPTIONAL_PACKAGE(CGNS SALOME_SMESH_USE_CGNS)
194 ADD_DEFINITIONS(-DWITH_CGNS)
195 ENDIF(SALOME_SMESH_USE_CGNS)
197 IF(SALOME_SMESH_USE_TBB)
198 FIND_PACKAGE(SalomeTBB)
199 SALOME_LOG_OPTIONAL_PACKAGE(TBB SALOME_SMESH_USE_TBB)
200 ADD_DEFINITIONS(-DWITH_TBB)
201 ENDIF(SALOME_SMESH_USE_TBB)
203 FIND_PACKAGE(SalomeMEDFile REQUIRED)
205 #On Windows use f2c to generate C MEFISTO2D code
207 SET(SALOME_SMESH_ENABLE_MEFISTO OFF)
208 FIND_PACKAGE(Salomef2c QUIET)
210 ADD_DEFINITIONS(-DENABLE_MEFISTO)
211 SET(SALOME_SMESH_ENABLE_MEFISTO ON)
212 MESSAGE(STATUS "Build MEFISTO2D mesher using Fortran to C generator")
214 MESSAGE(STATUS "Fortran to C generator is not found: MEFISTO2D mesher will be unavailable.")
218 IF(SALOME_SMESH_ENABLE_MEFISTO)
219 SET(MEFISTO2D_NAME "MEFISTO_2D")
220 ELSE(SALOME_SMESH_ENABLE_MEFISTO)
221 SET(MEFISTO2D_NAME "NOT_FOUND")
222 ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
225 SALOME_PACKAGE_REPORT_AND_CHECK()
228 # (default values taken from KERNEL)
230 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
231 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
232 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
233 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
234 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
235 "Install path: SALOME scripts")
236 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
237 "Install path: SALOME script data")
238 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
239 "Install path: SALOME Python scripts")
240 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH
241 "Install path: SALOME application skeleton - scripts")
242 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH
243 "Install path: SALOME application skeleton - Python")
244 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
245 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
246 "Install path: SALOME Python shared modules")
247 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH
248 "Install path: local SALOME CMake files")
249 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
250 "Install path: local SALOME config files (obsolete, to be removed)")
251 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
252 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
255 SET(SALOME_SMESH_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/smesh" CACHE PATH
256 "Install path: SALOME SMESH specific data")
257 SET(SALOME_SMESH_INSTALL_PLUGINS share/salome/plugins/smesh CACHE PATH
258 "Install path: SALOME SMESH plugins")
260 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
261 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
262 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
263 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
264 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
265 MARK_AS_ADVANCED(SALOME_SMESH_INSTALL_RES_DATA SALOME_SMESH_INSTALL_PLUGINS)
267 # Accumulate environment variables for SMESH module
268 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
269 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
270 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
271 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
276 ADD_SUBDIRECTORY(idl)
277 ADD_SUBDIRECTORY(adm_local)
278 ADD_SUBDIRECTORY(resources)
279 ADD_SUBDIRECTORY(bin)
280 ADD_SUBDIRECTORY(src)
282 ADD_SUBDIRECTORY(doc)
285 # Header configuration
286 # ====================
287 SALOME_XVERSION(${PROJECT_NAME})
288 SALOME_CONFIGURE_FILE(SMESH_version.h.in SMESH_version.h INSTALL ${SALOME_INSTALL_HEADERS})
290 # Configuration export
291 # (here only the level 1 prerequisites are exposed)
292 # ====================
293 INCLUDE(CMakePackageConfigHelpers)
295 # List of targets in this project we want to make visible to the rest of the world.
296 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
297 SET(_${PROJECT_NAME}_exposed_targets
298 SMESHControls MeshDriver MeshDriverDAT MeshDriverGMF MeshDriverMED
299 MeshDriverSTL MeshDriverUNV MEDWrapperBase MEDWrapper MEDWrapper_V2_2
300 SMDS SMESHimpl SMESHEngine SMESHClient SMESHDS
301 SMESHUtils StdMeshers StdMeshersEngine MeshJobManagerEngine
302 SPADDERPluginTesterEngine SalomeIDLSMESH SalomeIDLSPADDER
305 IF(SALOME_SMESH_ENABLE_MEFISTO)
306 LIST(APPEND _${PROJECT_NAME}_exposed_targets
308 ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
311 LIST(APPEND _${PROJECT_NAME}_exposed_targets
312 SMESHObject SMESHFiltersSelection SMESH PluginUtils StdMeshersGUI
314 ENDIF(SALOME_BUILD_GUI)
316 IF(SALOME_SMESH_USE_CGNS)
317 LIST(APPEND _${PROJECT_NAME}_exposed_targets
320 ENDIF(SALOME_SMESH_USE_CGNS)
322 # Add all targets to the build-tree export set
323 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
324 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
326 # Create the configuration files:
327 # - in the build tree:
329 # Ensure the variables are always defined for the configure:
330 SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}")
331 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
332 SET(CGNS_ROOT_DIR "${CGNS_ROOT_DIR}")
333 SET(TBB_ROOT_DIR "${TBB_ROOT_DIR}")
335 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
337 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
338 SALOME_CONFIGURE_PREPARE(CGNS TBB MEDFile)
340 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
341 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
342 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
343 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
344 GEOM_ROOT_DIR MEDFILE_ROOT_DIR CGNS_ROOT_DIR TBB_ROOT_DIR)
346 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
347 VERSION ${${PROJECT_NAME_UC}_VERSION}
348 COMPATIBILITY AnyNewerVersion)
350 # Install the CMake configuration files:
352 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
353 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
354 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
356 # Install the export set for use with the install-tree
357 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
358 FILE ${PROJECT_NAME}Targets.cmake)