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