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