Salome HOME
Add tests for connection with SHAPERSTUDY
[modules/smesh.git] / CMakeLists.txt
1 # Copyright (C) 2012-2019  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 4)
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 OPTION(SMESH_USE_MESHGEMS_HYPOSET "Prefer MeshGems algorithms in sets of hypotheses" OFF)
84 CMAKE_DEPENDENT_OPTION(SALOME_SMESH_BUILD_FRENCH_DOC "Generate SALOME SMESH French documentation" OFF
85                        "SALOME_BUILD_DOC" OFF)
86
87 IF(SALOME_SMESH_DYNLOAD_LOCAL)
88   ADD_DEFINITIONS(-DDYNLOAD_LOCAL)
89 ENDIF(SALOME_SMESH_DYNLOAD_LOCAL)
90
91 IF(SMESH_USE_MESHGEMS_HYPOSET)
92   SET(SMESH_USE_MESHGEMS_HYPOSET_VAR "true")
93 ELSE(SMESH_USE_MESHGEMS_HYPOSET)
94   SET(SMESH_USE_MESHGEMS_HYPOSET_VAR "false")
95 ENDIF(SMESH_USE_MESHGEMS_HYPOSET)
96
97 #On Linux use Fortran to compile MEFISTO2D
98 IF(NOT WIN32)
99   ENABLE_LANGUAGE(Fortran)
100   SET(SALOME_SMESH_ENABLE_MEFISTO ON)
101   ADD_DEFINITIONS(-DENABLE_MEFISTO)
102 ENDIF(NOT WIN32)
103
104 MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_SMESH_USE_CGNS SALOME_SMESH_USE_TBB SALOME_SMESH_DYNLOAD_LOCAL SMESH_USE_MESHGEMS_HYPOSET)
105
106 # Prerequisites
107 # =============
108 # Find "big" prerequisites first - they reference themselves many others
109 #   -> this can help finding the smaller prerequisites and detect conflicts.
110 # In our case KERNEL has already loaded many prereq:
111
112 ##
113 ## From KERNEL:
114 ##
115
116 # Various
117 # Python
118 FIND_PACKAGE(SalomePythonInterp REQUIRED)
119 FIND_PACKAGE(SalomePythonLibs REQUIRED)
120 # PThread
121 FIND_PACKAGE(SalomePThread REQUIRED)
122 # SWIG
123 FIND_PACKAGE(SalomeSWIG REQUIRED)
124 # Boost
125 FIND_PACKAGE(SalomeBoost REQUIRED)
126 # CORBA
127 FIND_PACKAGE(SalomeOmniORB REQUIRED)
128 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
129 # LibXml2
130 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
131 # HDF5
132 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
133
134 # Other KERNEL optionals:
135 IF(SALOME_BUILD_TESTS)
136   ENABLE_TESTING()
137   FIND_PACKAGE(SalomeCppUnit)
138   SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
139 ENDIF()
140 IF(SALOME_BUILD_DOC)
141   FIND_PACKAGE(SalomeDoxygen)
142   SET(Sphinx_EXTENSIONS sphinxcontrib.napoleon)
143   FIND_PACKAGE(SalomeSphinx)
144   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
145   SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
146 ENDIF()
147
148 # Find GUI
149 IF(SALOME_BUILD_GUI)
150   SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
151   IF(EXISTS ${GUI_ROOT_DIR})
152     LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
153     FIND_PACKAGE(SalomeGUI)
154     SALOME_GUI_WITH_CORBA() #check whether GUI built with CORBA
155     SALOME_GUI_MODE(SALOME_USE_VTKVIEWER SALOME_USE_SALOMEOBJECT 
156                     OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_PYCONSOLE)
157     ##
158     ## Prerequisites From GUI:
159     ##
160     # Qt
161     FIND_PACKAGE(SalomeQt5 REQUIRED)
162     # SIP
163     FIND_PACKAGE(SalomeSIP REQUIRED)  # should come after Python and before PyQt5
164     # PyQt
165     FIND_PACKAGE(SalomePyQt5 REQUIRED)
166     # Qwt
167     FIND_PACKAGE(SalomeQwt REQUIRED)
168   ELSE(EXISTS ${GUI_ROOT_DIR})
169     MESSAGE(FATAL_ERROR "GUI_ROOT_DIR is not well defined, SMESH will be built without GUI!!!")
170   ENDIF(EXISTS ${GUI_ROOT_DIR})
171   SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
172 ENDIF(SALOME_BUILD_GUI)
173
174 # Find GEOM
175 # ===========
176 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
177 IF(EXISTS ${GEOM_ROOT_DIR})
178   LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
179   FIND_PACKAGE(SalomeGEOM REQUIRED)
180   ADD_DEFINITIONS(${GEOM_DEFINITIONS})
181   INCLUDE_DIRECTORIES(${GEOM_INCLUDE_DIRS})
182   IF(SALOME_BUILD_GUI)
183     IF(NOT SALOME_GEOM_BUILD_GUI)
184       MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM with GUI, please set SALOME_BUILD_GUI=ON in GEOM module")
185     ENDIF(NOT SALOME_GEOM_BUILD_GUI)
186   ENDIF(SALOME_BUILD_GUI)
187 ELSE(EXISTS ${GEOM_ROOT_DIR})
188   MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR")
189 ENDIF(EXISTS ${GEOM_ROOT_DIR})
190
191 # Find SHAPERSTUDY
192 # ================
193 SET(WITH_SHAPER_STUDY OFF)
194 SET(SHAPERSTUDY_ROOT_DIR $ENV{SHAPERSTUDY_ROOT_DIR} CACHE PATH "Path to the Salome SHAPERSTUDY")
195 IF(EXISTS ${SHAPERSTUDY_ROOT_DIR})
196   LIST(APPEND CMAKE_MODULE_PATH "${SHAPERSTUDY_ROOT_DIR}/adm_local/cmake_files")
197   FIND_PACKAGE(SalomeSHAPERSTUDY)
198   IF(SalomeSHAPERSTUDY_FOUND)
199     SET(WITH_SHAPER_STUDY ON)
200   ENDIF()
201 ENDIF(EXISTS ${SHAPERSTUDY_ROOT_DIR})
202 IF(NOT WITH_SHAPER_STUDY AND SALOME_BUILD_TESTS)
203   MESSAGE(WARNING "SHAPERSTUDY is not found; the corresponding tests will be omitted")
204 ENDIF()
205
206 ##
207 ## SMESH specifics
208 ##
209
210 # VTK is obligatiry for the SMESH
211 FIND_PACKAGE(SalomeVTK REQUIRED)
212
213 FIND_PACKAGE(SalomeOpenCASCADE REQUIRED) 
214
215 IF(SALOME_SMESH_USE_CGNS)
216   FIND_PACKAGE(SalomeCGNS)
217   SALOME_LOG_OPTIONAL_PACKAGE(CGNS SALOME_SMESH_USE_CGNS)
218   ADD_DEFINITIONS(-DWITH_CGNS)
219 ENDIF(SALOME_SMESH_USE_CGNS)
220
221 IF(SALOME_SMESH_USE_TBB)
222   FIND_PACKAGE(SalomeTBB)
223   SALOME_LOG_OPTIONAL_PACKAGE(TBB SALOME_SMESH_USE_TBB)
224   ADD_DEFINITIONS(-DWITH_TBB)
225 ENDIF(SALOME_SMESH_USE_TBB)
226
227 FIND_PACKAGE(SalomeMEDFile REQUIRED)
228
229 #On Windows use f2c to generate C MEFISTO2D code
230 IF(WIN32)
231   SET(SALOME_SMESH_ENABLE_MEFISTO OFF)
232   FIND_PACKAGE(Salomef2c QUIET)
233   IF(${F2C_FOUND})
234     ADD_DEFINITIONS(-DENABLE_MEFISTO)
235     SET(SALOME_SMESH_ENABLE_MEFISTO ON)
236     MESSAGE(STATUS "Build MEFISTO2D mesher using Fortran to C generator")
237   ELSE(${F2C_FOUND})
238     MESSAGE(STATUS "Fortran to C generator is not found: MEFISTO2D mesher will be unavailable.")
239   ENDIF(${F2C_FOUND})  
240 ENDIF(WIN32)
241
242 IF(SALOME_SMESH_ENABLE_MEFISTO)
243  SET(MEFISTO2D_NAME "MEFISTO_2D")
244 ELSE(SALOME_SMESH_ENABLE_MEFISTO)
245  SET(MEFISTO2D_NAME "NOT_FOUND")
246 ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
247
248 # Detection summary:
249 SALOME_PACKAGE_REPORT_AND_CHECK()
250
251 # Directories
252 # (default values taken from KERNEL)
253 # ===========
254 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
255 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
256 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
257 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
258 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH 
259    "Install path: SALOME scripts")
260 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH 
261    "Install path: SALOME script data")
262 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH 
263    "Install path: SALOME Python scripts")
264 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH 
265    "Install path: SALOME application skeleton - scripts")
266 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH 
267    "Install path: SALOME application skeleton - Python")
268 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
269 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH 
270    "Install path: SALOME Python shared modules")
271 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH 
272     "Install path: local SALOME CMake files") 
273 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
274   "Install path: local SALOME config files (obsolete, to be removed)")
275 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
276 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
277
278 # Specific to SMESH:
279 SET(SALOME_SMESH_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/smesh" CACHE PATH 
280     "Install path: SALOME SMESH specific data")
281 SET(SALOME_SMESH_INSTALL_PLUGINS share/salome/plugins/smesh CACHE PATH 
282     "Install path: SALOME SMESH plugins")
283     
284 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
285 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
286 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
287 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
288 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
289 MARK_AS_ADVANCED(SALOME_SMESH_INSTALL_RES_DATA SALOME_SMESH_INSTALL_PLUGINS)
290
291 # Accumulate environment variables for SMESH module
292 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
293                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
294                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
295 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) 
296
297 # Sources 
298 # ========
299
300 ADD_SUBDIRECTORY(idl)
301 ADD_SUBDIRECTORY(adm_local)
302 ADD_SUBDIRECTORY(resources)
303 ADD_SUBDIRECTORY(bin)
304 ADD_SUBDIRECTORY(src)
305 IF(SALOME_BUILD_DOC)
306   ADD_SUBDIRECTORY(doc)
307 ENDIF()
308 IF(SALOME_BUILD_TESTS)
309   ADD_SUBDIRECTORY(test)
310 ENDIF()
311
312 # Header configuration
313 # ====================
314 SALOME_XVERSION(${PROJECT_NAME})
315 SALOME_CONFIGURE_FILE(SMESH_version.h.in SMESH_version.h INSTALL ${SALOME_INSTALL_HEADERS})
316
317 # Configuration export
318 # (here only the level 1 prerequisites are exposed)
319 # ====================
320 INCLUDE(CMakePackageConfigHelpers)
321
322 # List of targets in this project we want to make visible to the rest of the world.
323 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
324 SET(_${PROJECT_NAME}_exposed_targets 
325   SMESHControls MeshDriver MeshDriverDAT MeshDriverGMF MeshDriverMED
326   MeshDriverSTL MeshDriverUNV MEDWrapper
327   SMDS SMESHimpl SMESHEngine SMESHClient SMESHDS
328   SMESHUtils StdMeshers StdMeshersEngine MeshJobManagerEngine
329   SPADDERPluginTesterEngine SalomeIDLSMESH SalomeIDLSPADDER
330 )
331
332 IF(SALOME_SMESH_ENABLE_MEFISTO)
333   LIST(APPEND _${PROJECT_NAME}_exposed_targets
334        MEFISTO2D) 
335 ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
336
337 IF(SALOME_BUILD_GUI)
338   LIST(APPEND _${PROJECT_NAME}_exposed_targets
339       SMESHObject SMESHFiltersSelection SMESH PluginUtils StdMeshersGUI
340   )
341 ENDIF(SALOME_BUILD_GUI)
342
343 IF(SALOME_SMESH_USE_CGNS)
344   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
345     MeshDriverCGNS
346   )
347 ENDIF(SALOME_SMESH_USE_CGNS)
348
349 # Add all targets to the build-tree export set
350 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
351   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
352
353 # Create the configuration files:
354 #   - in the build tree:
355
356 # Ensure the variables are always defined for the configure:
357 SET(GEOM_ROOT_DIR "${GEOM_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}")
361  
362 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
363
364 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
365 SALOME_CONFIGURE_PREPARE(CGNS TBB MEDFile)
366
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 MEDFILE_ROOT_DIR CGNS_ROOT_DIR TBB_ROOT_DIR)
372
373 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
374     VERSION ${${PROJECT_NAME_UC}_VERSION}
375     COMPATIBILITY AnyNewerVersion)
376
377 # Install the CMake configuration files:
378 INSTALL(FILES
379   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
380   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
381   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
382
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)