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