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