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