Salome HOME
Merge branch 'V8_4_BR'
[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 8)
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 builded 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                        "NOT 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   FIND_PACKAGE(SalomeSphinx)
136   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
137   SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
138 ENDIF()
139
140 # Find GUI
141 IF(SALOME_BUILD_GUI)
142   SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
143   IF(EXISTS ${GUI_ROOT_DIR})
144     LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
145     FIND_PACKAGE(SalomeGUI)
146     SALOME_GUI_WITH_CORBA() #check whether GUI builded with CORBA
147     SALOME_GUI_MODE(SALOME_USE_VTKVIEWER SALOME_USE_SALOMEOBJECT 
148                     OPTIONAL SALOME_USE_PLOT2DVIEWER SALOME_USE_PYCONSOLE)
149     ##
150     ## Prerequisites From GUI:
151     ##
152     # Qt
153     IF(NOT SALOME_GUI_BUILD_WITH_QT5)
154       FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml)
155     ELSE()
156       FIND_PACKAGE(SalomeQt5 REQUIRED)
157     ENDIF()
158     # SIP
159     FIND_PACKAGE(SalomeSIP REQUIRED)  # should come after Python and before PyQt5
160     # PyQt
161     IF (NOT SALOME_GUI_BUILD_WITH_QT5)
162       FIND_PACKAGE(SalomePyQt4 REQUIRED)
163     ELSE()
164       FIND_PACKAGE(SalomePyQt5 REQUIRED)
165     ENDIF()
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 ##
192 ## SMESH specifics
193 ##
194
195 # VTK is obligatiry for the SMESH
196 FIND_PACKAGE(SalomeVTK REQUIRED)
197
198 FIND_PACKAGE(SalomeOpenCASCADE REQUIRED) 
199
200 IF(SALOME_SMESH_USE_CGNS)
201   FIND_PACKAGE(SalomeCGNS)
202   SALOME_LOG_OPTIONAL_PACKAGE(CGNS SALOME_SMESH_USE_CGNS)
203   ADD_DEFINITIONS(-DWITH_CGNS)
204 ENDIF(SALOME_SMESH_USE_CGNS)
205
206 IF(SALOME_SMESH_USE_TBB)
207   FIND_PACKAGE(SalomeTBB)
208   SALOME_LOG_OPTIONAL_PACKAGE(TBB SALOME_SMESH_USE_TBB)
209   ADD_DEFINITIONS(-DWITH_TBB)
210 ENDIF(SALOME_SMESH_USE_TBB)
211
212 FIND_PACKAGE(SalomeMEDFile REQUIRED)
213
214 #On Windows use f2c to generate C MEFISTO2D code
215 IF(WIN32)
216   SET(SALOME_SMESH_ENABLE_MEFISTO OFF)
217   FIND_PACKAGE(Salomef2c QUIET)
218   IF(${F2C_FOUND})
219     ADD_DEFINITIONS(-DENABLE_MEFISTO)
220     SET(SALOME_SMESH_ENABLE_MEFISTO ON)
221     MESSAGE(STATUS "Build MEFISTO2D mesher using Fortran to C generator")
222   ELSE(${F2C_FOUND})
223     MESSAGE(STATUS "Fortran to C generator is not found: MEFISTO2D mesher will be unavailable.")
224   ENDIF(${F2C_FOUND})  
225 ENDIF(WIN32)
226
227 IF(SALOME_SMESH_ENABLE_MEFISTO)
228  SET(MEFISTO2D_NAME "MEFISTO_2D")
229 ELSE(SALOME_SMESH_ENABLE_MEFISTO)
230  SET(MEFISTO2D_NAME "NOT_FOUND")
231 ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
232
233 # Detection summary:
234 SALOME_PACKAGE_REPORT_AND_CHECK()
235
236 # Directories
237 # (default values taken from KERNEL)
238 # ===========
239 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
240 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
241 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
242 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
243 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH 
244    "Install path: SALOME scripts")
245 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH 
246    "Install path: SALOME script data")
247 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH 
248    "Install path: SALOME Python scripts")
249 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH 
250    "Install path: SALOME application skeleton - scripts")
251 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH 
252    "Install path: SALOME application skeleton - Python")
253 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
254 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH 
255    "Install path: SALOME Python shared modules")
256 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH 
257     "Install path: local SALOME CMake files") 
258 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
259   "Install path: local SALOME config files (obsolete, to be removed)")
260 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
261 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
262
263 # Specific to SMESH:
264 SET(SALOME_SMESH_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/smesh" CACHE PATH 
265     "Install path: SALOME SMESH specific data")
266 SET(SALOME_SMESH_INSTALL_PLUGINS share/salome/plugins/smesh CACHE PATH 
267     "Install path: SALOME SMESH plugins")
268     
269 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
270 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
271 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
272 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
273 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
274 MARK_AS_ADVANCED(SALOME_SMESH_INSTALL_RES_DATA SALOME_SMESH_INSTALL_PLUGINS)
275
276 # Accumulate environment variables for SMESH module
277 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
278                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
279                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
280 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) 
281
282 # Sources 
283 # ========
284
285 ADD_SUBDIRECTORY(idl)
286 ADD_SUBDIRECTORY(adm_local)
287 ADD_SUBDIRECTORY(resources)
288 ADD_SUBDIRECTORY(bin)
289 ADD_SUBDIRECTORY(src)
290 IF(SALOME_BUILD_DOC)
291   ADD_SUBDIRECTORY(doc)
292 ENDIF()
293
294 # Header configuration
295 # ====================
296 SALOME_XVERSION(${PROJECT_NAME})
297 SALOME_CONFIGURE_FILE(SMESH_version.h.in SMESH_version.h INSTALL ${SALOME_INSTALL_HEADERS})
298
299 # Configuration export
300 # (here only the level 1 prerequisites are exposed)
301 # ====================
302 INCLUDE(CMakePackageConfigHelpers)
303
304 # List of targets in this project we want to make visible to the rest of the world.
305 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
306 SET(_${PROJECT_NAME}_exposed_targets 
307   SMESHControls MeshDriver MeshDriverDAT MeshDriverGMF MeshDriverMED
308   MeshDriverSTL MeshDriverUNV MEDWrapperBase MEDWrapper MEDWrapper_V2_2
309   SMDS SMESHimpl SMESHEngine SMESHClient SMESHDS
310   SMESHUtils StdMeshers StdMeshersEngine MeshJobManagerEngine
311   SPADDERPluginTesterEngine SalomeIDLSMESH SalomeIDLSPADDER
312 )
313
314 IF(SALOME_SMESH_ENABLE_MEFISTO)
315   LIST(APPEND _${PROJECT_NAME}_exposed_targets
316        MEFISTO2D) 
317 ENDIF(SALOME_SMESH_ENABLE_MEFISTO)
318
319 IF(SALOME_BUILD_GUI)
320   LIST(APPEND _${PROJECT_NAME}_exposed_targets
321       SMESHObject SMESHFiltersSelection SMESH PluginUtils StdMeshersGUI
322   )
323 ENDIF(SALOME_BUILD_GUI)
324
325 IF(SALOME_SMESH_USE_CGNS)
326   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
327     MeshDriverCGNS
328   )
329 ENDIF(SALOME_SMESH_USE_CGNS)
330
331 # Add all targets to the build-tree export set
332 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
333   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
334
335 # Create the configuration files:
336 #   - in the build tree:
337
338 # Ensure the variables are always defined for the configure:
339 SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}")
340 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
341 SET(CGNS_ROOT_DIR "${CGNS_ROOT_DIR}")
342 SET(TBB_ROOT_DIR  "${TBB_ROOT_DIR}")
343  
344 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
345
346 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
347 SALOME_CONFIGURE_PREPARE(CGNS TBB MEDFile)
348
349 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
350     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
351     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
352     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
353     GEOM_ROOT_DIR MEDFILE_ROOT_DIR CGNS_ROOT_DIR TBB_ROOT_DIR)
354
355 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
356     VERSION ${${PROJECT_NAME_UC}_VERSION}
357     COMPATIBILITY AnyNewerVersion)
358
359 # Install the CMake configuration files:
360 INSTALL(FILES
361   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
362   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
363   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
364
365 # Install the export set for use with the install-tree
366 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" 
367   FILE ${PROJECT_NAME}Targets.cmake)