Salome HOME
Protection for the case of python command wrapped over several lines
[modules/smesh.git] / CMakeLists.txt
1 # Copyright (C) 2012-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
20 PROJECT(SalomeSMESH C CXX)
21
22 INCLUDE(CMakeDependentOption)
23
24 # Versioning
25 # ===========
26 # Project name, upper case
27 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
28
29 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 9)
30 SET(${PROJECT_NAME_UC}_MINOR_VERSION 5)
31 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
32 SET(${PROJECT_NAME_UC}_VERSION
33   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
34 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
35
36 # Common CMake macros
37 # ===================
38 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
39 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
40   LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
41   INCLUDE(SalomeMacros NO_POLICY_SCOPE)
42 ELSE()
43   MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
44 ENDIF()
45
46 # Find KERNEL
47 # ===========
48 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
49 IF(EXISTS ${KERNEL_ROOT_DIR})
50   FIND_PACKAGE(SalomeKERNEL REQUIRED)
51   KERNEL_WITH_CORBA() #check whether KERNEL built with CORBA
52   ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
53   INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
54 ELSE(EXISTS ${KERNEL_ROOT_DIR})
55   MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
56 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
57
58 # Platform setup
59 # ==============
60 INCLUDE(SalomeSetupPlatform)   # From KERNEL
61 # Always build libraries as shared objects:
62 SET(BUILD_SHARED_LIBS TRUE)
63
64 # User options
65 # ============
66 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
67 OPTION(SALOME_BUILD_DOC "Generate SALOME SMESH documentation" ON)
68   
69 # Advanced options:
70 OPTION(SALOME_BUILD_GUI           "Enable GUI" ON)
71 OPTION(SALOME_SMESH_USE_CGNS      "Enable import/export to CGNS format" OFF)
72 OPTION(SALOME_SMESH_USE_TBB       "Enable parallel computation" OFF)
73 OPTION(SALOME_SMESH_DYNLOAD_LOCAL "Load plug-ins' symbols locally (Linux only)" ON)
74 OPTION(SMESH_USE_MESHGEMS_HYPOSET "Prefer MeshGems algorithms in sets of hypotheses" OFF)
75 CMAKE_DEPENDENT_OPTION(SALOME_SMESH_BUILD_FRENCH_DOC "Generate SALOME SMESH French documentation" OFF
76                        "SALOME_BUILD_DOC" OFF)
77
78 IF(SALOME_SMESH_DYNLOAD_LOCAL)
79   ADD_DEFINITIONS(-DDYNLOAD_LOCAL)
80 ENDIF(SALOME_SMESH_DYNLOAD_LOCAL)
81
82 IF(SMESH_USE_MESHGEMS_HYPOSET)
83   SET(SMESH_USE_MESHGEMS_HYPOSET_VAR "true")
84 ELSE(SMESH_USE_MESHGEMS_HYPOSET)
85   SET(SMESH_USE_MESHGEMS_HYPOSET_VAR "false")
86 ENDIF(SMESH_USE_MESHGEMS_HYPOSET)
87
88 #On Linux use Fortran to compile MEFISTO2D
89 IF(NOT WIN32)
90   ENABLE_LANGUAGE(Fortran)
91   SET(SALOME_SMESH_ENABLE_MEFISTO ON)
92   ADD_DEFINITIONS(-DENABLE_MEFISTO)
93 ENDIF(NOT WIN32)
94
95 MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_SMESH_USE_CGNS SALOME_SMESH_USE_TBB SALOME_SMESH_DYNLOAD_LOCAL SMESH_USE_MESHGEMS_HYPOSET)
96
97 # Prerequisites
98 # =============
99 # Find "big" prerequisites first - they reference themselves many others
100 #   -> this can help finding the smaller prerequisites and detect conflicts.
101 # In our case KERNEL has already loaded many prereq:
102
103 ##
104 ## From KERNEL:
105 ##
106
107 # Various
108 # Python
109 FIND_PACKAGE(SalomePythonInterp REQUIRED)
110 FIND_PACKAGE(SalomePythonLibs REQUIRED)
111 # PThread
112 FIND_PACKAGE(SalomePThread REQUIRED)
113 # SWIG
114 FIND_PACKAGE(SalomeSWIG REQUIRED)
115 # Boost
116 FIND_PACKAGE(SalomeBoost REQUIRED)
117 # CORBA
118 FIND_PACKAGE(SalomeOmniORB REQUIRED)
119 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
120 # LibXml2
121 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
122 # HDF5
123 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
124
125 # Other KERNEL optionals:
126 IF(SALOME_BUILD_TESTS)
127   ENABLE_TESTING()
128   FIND_PACKAGE(SalomeCppUnit)
129   SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
130 ENDIF()
131 IF(SALOME_BUILD_DOC)
132   FIND_PACKAGE(SalomeDoxygen)
133   SET(Sphinx_EXTENSIONS sphinxcontrib.napoleon)
134   FIND_PACKAGE(SalomeSphinx)
135   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
136   SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
137 ENDIF()
138
139 # Find GUI
140 IF(SALOME_BUILD_GUI)
141   SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
142   IF(EXISTS ${GUI_ROOT_DIR})
143     FIND_PACKAGE(SalomeGUI)
144     SALOME_GUI_WITH_CORBA() #check whether GUI built with CORBA
145     SALOME_GUI_MODE(SALOME_USE_VTKVIEWER SALOME_USE_SALOMEOBJECT 
146                     OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_PYCONSOLE)
147     ##
148     ## Prerequisites From GUI:
149     ##
150     # Qt
151     FIND_PACKAGE(SalomeQt5 REQUIRED)
152     # SIP
153     FIND_PACKAGE(SalomeSIP REQUIRED)  # should come after Python and before PyQt5
154     # PyQt
155     FIND_PACKAGE(SalomePyQt5 REQUIRED)
156     # Qwt
157     FIND_PACKAGE(SalomeQwt REQUIRED)
158   ELSE(EXISTS ${GUI_ROOT_DIR})
159     MESSAGE(FATAL_ERROR "GUI_ROOT_DIR is not well defined, SMESH will be built without GUI!!!")
160   ENDIF(EXISTS ${GUI_ROOT_DIR})
161   SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
162 ENDIF(SALOME_BUILD_GUI)
163
164 # Find GEOM
165 # ===========
166 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
167 IF(EXISTS ${GEOM_ROOT_DIR})
168   FIND_PACKAGE(SalomeGEOM REQUIRED)
169   ADD_DEFINITIONS(${GEOM_DEFINITIONS})
170   INCLUDE_DIRECTORIES(${GEOM_INCLUDE_DIRS})
171   IF(SALOME_BUILD_GUI)
172     IF(NOT SALOME_GEOM_BUILD_GUI)
173       MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM with GUI, please set SALOME_BUILD_GUI=ON in GEOM module")
174     ENDIF(NOT SALOME_GEOM_BUILD_GUI)
175   ENDIF(SALOME_BUILD_GUI)
176 ELSE(EXISTS ${GEOM_ROOT_DIR})
177   MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR")
178 ENDIF(EXISTS ${GEOM_ROOT_DIR})
179
180 # Find SHAPERSTUDY
181 # ================
182 SET(WITH_SHAPER_STUDY OFF)
183 SET(SHAPERSTUDY_ROOT_DIR $ENV{SHAPERSTUDY_ROOT_DIR} CACHE PATH "Path to the Salome SHAPERSTUDY")
184 IF(EXISTS ${SHAPERSTUDY_ROOT_DIR})
185   FIND_PACKAGE(SalomeSHAPERSTUDY)
186   IF(SalomeSHAPERSTUDY_FOUND)
187     SET(WITH_SHAPER_STUDY ON)
188   ENDIF()
189 ENDIF(EXISTS ${SHAPERSTUDY_ROOT_DIR})
190 IF(NOT WITH_SHAPER_STUDY AND SALOME_BUILD_TESTS)
191   MESSAGE(WARNING "SHAPERSTUDY is not found; the corresponding tests will be omitted")
192 ENDIF()
193
194 ##
195 ## SMESH specifics
196 ##
197
198 # VTK is obligatiry for the SMESH
199 FIND_PACKAGE(SalomeVTK REQUIRED)
200
201 FIND_PACKAGE(SalomeOpenCASCADE REQUIRED) 
202
203 IF(SALOME_SMESH_USE_CGNS)
204   FIND_PACKAGE(SalomeCGNS)
205   SALOME_LOG_OPTIONAL_PACKAGE(CGNS SALOME_SMESH_USE_CGNS)
206   ADD_DEFINITIONS(-DWITH_CGNS)
207 ENDIF(SALOME_SMESH_USE_CGNS)
208
209 IF(SALOME_SMESH_USE_TBB)
210   FIND_PACKAGE(SalomeTBB)
211   SALOME_LOG_OPTIONAL_PACKAGE(TBB SALOME_SMESH_USE_TBB)
212   ADD_DEFINITIONS(-DWITH_TBB)
213 ENDIF(SALOME_SMESH_USE_TBB)
214
215 FIND_PACKAGE(SalomeMEDFile REQUIRED)
216
217 #On Windows use f2c to generate C MEFISTO2D code
218 IF(WIN32)
219   SET(SALOME_SMESH_ENABLE_MEFISTO OFF)
220   FIND_PACKAGE(Salomef2c QUIET)
221   IF(${F2C_FOUND})
222     ADD_DEFINITIONS(-DENABLE_MEFISTO)
223     SET(SALOME_SMESH_ENABLE_MEFISTO ON)
224     MESSAGE(STATUS "Build MEFISTO2D mesher using Fortran to C generator")
225   ELSE(${F2C_FOUND})
226     MESSAGE(STATUS "Fortran to C generator is not found: MEFISTO2D mesher will be unavailable.")
227   ENDIF(${F2C_FOUND})  
228 ENDIF(WIN32)
229
230 IF(SALOME_SMESH_ENABLE_MEFISTO)
231  SET(MEFISTO2D_NAME "MEFISTO_2D")
232 ELSE(SALOME_SMESH_ENABLE_MEFISTO)
233  SET(MEFISTO2D_NAME "NOT_FOUND")
234 ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
235
236 # Detection summary:
237 SALOME_PACKAGE_REPORT_AND_CHECK()
238
239 # Directories
240 # (default values taken from KERNEL)
241 # ===========
242 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
243 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
244 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
245 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
246 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH 
247    "Install path: SALOME scripts")
248 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH 
249    "Install path: SALOME script data")
250 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH 
251    "Install path: SALOME Python scripts")
252 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH 
253    "Install path: SALOME application skeleton - scripts")
254 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH 
255    "Install path: SALOME application skeleton - Python")
256 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
257 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH 
258    "Install path: SALOME Python shared modules")
259 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH 
260     "Install path: local SALOME CMake files") 
261 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
262   "Install path: local SALOME config files (obsolete, to be removed)")
263 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
264 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
265
266 # Specific to SMESH:
267 SET(SALOME_SMESH_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/smesh" CACHE PATH 
268     "Install path: SALOME SMESH specific data")
269 SET(SALOME_SMESH_INSTALL_PLUGINS share/salome/plugins/smesh CACHE PATH 
270     "Install path: SALOME SMESH plugins")
271     
272 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
273 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
274 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
275 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
276 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
277 MARK_AS_ADVANCED(SALOME_SMESH_INSTALL_RES_DATA SALOME_SMESH_INSTALL_PLUGINS)
278
279 # Accumulate environment variables for SMESH module
280 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
281                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
282                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
283 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) 
284
285 # Sources 
286 # ========
287
288 ADD_SUBDIRECTORY(idl)
289 ADD_SUBDIRECTORY(adm_local)
290 ADD_SUBDIRECTORY(resources)
291 ADD_SUBDIRECTORY(bin)
292 ADD_SUBDIRECTORY(src)
293 IF(SALOME_BUILD_DOC)
294   ADD_SUBDIRECTORY(doc)
295 ENDIF()
296 IF(SALOME_BUILD_TESTS)
297   ADD_SUBDIRECTORY(test)
298 ENDIF()
299
300 # Header configuration
301 # ====================
302 SALOME_XVERSION(${PROJECT_NAME})
303 SALOME_CONFIGURE_FILE(SMESH_version.h.in SMESH_version.h INSTALL ${SALOME_INSTALL_HEADERS})
304
305 # Configuration export
306 # (here only the level 1 prerequisites are exposed)
307 # ====================
308 INCLUDE(CMakePackageConfigHelpers)
309
310 # List of targets in this project we want to make visible to the rest of the world.
311 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
312 SET(_${PROJECT_NAME}_exposed_targets 
313   SMESHControls MeshDriver MeshDriverDAT MeshDriverGMF MeshDriverMED
314   MeshDriverSTL MeshDriverUNV MEDWrapper
315   SMDS SMESHimpl SMESHEngine SMESHClient SMESHDS
316   SMESHUtils StdMeshers StdMeshersEngine MeshJobManagerEngine
317   SPADDERPluginTesterEngine SalomeIDLSMESH SalomeIDLSPADDER
318 )
319
320 IF(SALOME_SMESH_ENABLE_MEFISTO)
321   LIST(APPEND _${PROJECT_NAME}_exposed_targets
322        MEFISTO2D) 
323 ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
324
325 IF(SALOME_BUILD_GUI)
326   LIST(APPEND _${PROJECT_NAME}_exposed_targets
327       SMESHObject SMESHFiltersSelection SMESH PluginUtils StdMeshersGUI
328   )
329 ENDIF(SALOME_BUILD_GUI)
330
331 IF(SALOME_SMESH_USE_CGNS)
332   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
333     MeshDriverCGNS
334   )
335 ENDIF(SALOME_SMESH_USE_CGNS)
336
337 # Add all targets to the build-tree export set
338 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
339   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
340
341 # Create the configuration files:
342 #   - in the build tree:
343
344 # Ensure the variables are always defined for the configure:
345 SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}")
346 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
347 SET(CGNS_ROOT_DIR "${CGNS_ROOT_DIR}")
348 SET(TBB_ROOT_DIR  "${TBB_ROOT_DIR}")
349  
350 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
351
352 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
353 SALOME_CONFIGURE_PREPARE(CGNS TBB MEDFile)
354
355 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
356     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
357     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
358     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
359     GEOM_ROOT_DIR MEDFILE_ROOT_DIR CGNS_ROOT_DIR TBB_ROOT_DIR)
360
361 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
362     VERSION ${${PROJECT_NAME_UC}_VERSION}
363     COMPATIBILITY AnyNewerVersion)
364
365 # Install the CMake configuration files:
366 INSTALL(FILES
367   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
368   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
369   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
370
371 # Install the export set for use with the install-tree
372 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" 
373   FILE ${PROJECT_NAME}Targets.cmake)