1 # Copyright (C) 2012-2014 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
20 INCLUDE(CMakeDependentOption)
22 PROJECT(SalomeGUI C CXX)
24 # Ensure a proper linker behavior:
25 CMAKE_POLICY(SET CMP0003 NEW)
29 # Project name, upper case
30 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
32 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
33 SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
34 SET(${PROJECT_NAME_UC}_PATCH_VERSION 1)
35 SET(${PROJECT_NAME_UC}_VERSION
36 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
37 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
41 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
42 IF(EXISTS ${KERNEL_ROOT_DIR})
43 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
45 FIND_PACKAGE(SalomeKERNEL REQUIRED)
46 ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
47 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
48 ELSE(EXISTS ${KERNEL_ROOT_DIR})
49 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
50 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
54 INCLUDE(SalomeSetupPlatform) # From KERNEL
55 # Always build libraries as shared objects:
56 SET(BUILD_SHARED_LIBS TRUE)
58 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
62 OPTION(SALOME_BUILD_DOC "Generate SALOME GUI documentation" ON)
63 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
64 OPTION(SALOME_GUI_USE_OBSERVERS "Use study observers in GUI (advanced)" ON)
67 CMAKE_DEPENDENT_OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF
68 "NOT SALOME_KERNEL_LIGHT_ONLY" ON)
69 OPTION(SALOME_USE_VTKVIEWER "Enable VTK visualization (Mandatory in classic configurations)" ON)
70 OPTION(SALOME_USE_OCCVIEWER "Enable OCC visualization (Mandatory in classic configurations)" ON)
71 OPTION(SALOME_USE_GLVIEWER "Enable OpenGL visualization (Mandatory in classic configurations)" ON)
72 OPTION(SALOME_USE_GRAPHICSVIEW "Enable GraphicsView visualization (Mandatory in classic configurations)" ON)
73 OPTION(SALOME_USE_PLOT2DVIEWER "Enable Plot2D visualization (Mandatory in classic configurations)" ON)
74 OPTION(SALOME_USE_PYCONSOLE "Enable Python GUI interface (Mandatory in classic configurations)" ON)
75 OPTION(SALOME_USE_QXGRAPHVIEWER "Enable QX graph visualization (Mandatory in classic configurations)" ON)
76 CMAKE_DEPENDENT_OPTION(SALOME_USE_SALOMEOBJECT "Enable Salome Object (Mandatory in classic configurations)" ON
77 "SALOME_LIGHT_ONLY" ON)
78 OPTION(SALOME_USE_SINGLE_DESKTOP "Enable multiple document interface" ON)
80 MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_VTKVIEWER SALOME_USE_GRAPHICSVIEW)
81 MARK_AS_ADVANCED(SALOME_USE_SALOMEOBJECT SALOME_USE_OCCVIEWER SALOME_USE_GLVIEWER SALOME_USE_PLOT2DVIEWER)
82 MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_QXGRAPHVIEWER)
83 MARK_AS_ADVANCED(SALOME_USE_SINGLE_DESKTOP)
87 # Find "big" prerequisites first - they reference themselves many others
88 # -> this can help finding the smaller prerequisites and detect conficts.
89 # In our case KERNEL has already loaded many prereq which are also used in GUI:
96 FIND_PACKAGE(SalomePython REQUIRED)
97 FIND_PACKAGE(SalomePThread REQUIRED)
98 FIND_PACKAGE(SalomeSWIG REQUIRED)
99 FIND_PACKAGE(SalomeBoost REQUIRED)
100 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
102 # Other KERNEL optionals:
103 IF(NOT SALOME_LIGHT_ONLY)
104 FIND_PACKAGE(SalomeOmniORB REQUIRED)
105 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
107 ADD_DEFINITIONS("-DGUI_DISABLE_CORBA")
109 IF(SALOME_BUILD_TESTS)
111 FIND_PACKAGE(SalomeCppUnit)
112 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
115 FIND_PACKAGE(SalomeDoxygen)
116 FIND_PACKAGE(SalomeGraphviz)
117 FIND_PACKAGE(SalomeSphinx)
118 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
119 SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC)
120 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
127 FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt4
129 # Build with GUI observers feature
130 IF(SALOME_GUI_USE_OBSERVERS)
131 ADD_DEFINITIONS(-DWITH_SALOMEDS_OBSERVER)
134 IF(SALOME_USE_SINGLE_DESKTOP)
135 ADD_DEFINITIONS(-DSINGLE_DESKTOP)
139 FIND_PACKAGE(SalomeCAS REQUIRED)
140 IF(NOT SALOME_USE_OCCVIEWER)
141 ADD_DEFINITIONS("-DDISABLE_OCCVIEWER")
145 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtWebKit QtOpenGL)
146 INCLUDE(${QT_USE_FILE})
148 FIND_PACKAGE(SalomePyQt4 REQUIRED)
150 # Optional prerequisites for GUI
151 IF(SALOME_USE_GLVIEWER)
152 FIND_PACKAGE(SalomeOpenGL)
153 SALOME_LOG_OPTIONAL_PACKAGE(OpenGL SALOME_USE_GLVIEWER)
155 ADD_DEFINITIONS("-DDISABLE_GLVIEWER")
157 IF(SALOME_USE_VTKVIEWER)
158 # Required components are listed in the FindSalomeVTK.cmake file:
159 FIND_PACKAGE(SalomeVTK)
160 SALOME_LOG_OPTIONAL_PACKAGE(VTK SALOME_USE_VTKVIEWER)
162 ADD_DEFINITIONS("-DDISABLE_VTKVIEWER")
164 IF(SALOME_USE_PLOT2DVIEWER)
165 FIND_PACKAGE(SalomeQwt)
166 SALOME_LOG_OPTIONAL_PACKAGE(Qwt SALOME_USE_PLOT2DVIEWER)
168 ADD_DEFINITIONS("-DDISABLE_PLOT2DVIEWER")
170 IF (NOT SALOME_USE_GRAPHICSVIEW)
171 ADD_DEFINITIONS("-DDISABLE_GRAPHICSVIEW")
173 IF(SALOME_USE_PYCONSOLE)
174 # Build with obsolete Python module's methods
175 ADD_DEFINITIONS(-DCALL_OLD_METHODS)
177 ADD_DEFINITIONS("-DDISABLE_PYCONSOLE")
179 IF(NOT SALOME_USE_QXGRAPHVIEWER)
180 ADD_DEFINITIONS("-DDISABLE_QXGRAPHVIEWER")
182 IF(NOT SALOME_USE_SALOMEOBJECT)
183 ADD_DEFINITIONS("-DDISABLE_SALOMEOBJECT")
187 SALOME_PACKAGE_REPORT_AND_CHECK()
190 # (default values taken from KERNEL)
192 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
193 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
194 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
195 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
196 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
197 "Install path: SALOME scripts")
198 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
199 "Install path: SALOME script data")
200 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
201 "Install path: SALOME Python scripts")
202 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
203 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
204 "Install path: SALOME Python shared modules")
205 SET(SALOME_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE}" CACHE PATH "Install path: SALOME CMake files")
206 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH
207 "Install path: local SALOME CMake files")
208 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
209 "Install path: local SALOME config files (obsolete, to be removed)")
211 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
212 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
215 SET(SALOME_GUI_INSTALL_PARAVIEW_LIBS lib/paraview CACHE PATH
216 "Install path: SALOME GUI ParaView libraries")
217 SET(SALOME_GUI_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/gui" CACHE PATH
218 "Install path: SALOME GUI specific data")
219 SET(SALOME_GUI_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/gui" CACHE PATH
220 "Install path: SALOME GUI scripts")
221 SET(SALOME_GUI_INSTALL_PLUGINS share/salome/plugins/gui CACHE PATH
222 "Install path: SALOME GUI plugins")
224 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
225 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
226 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
227 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
228 MARK_AS_ADVANCED(SALOME_GUI_INSTALL_PARAVIEW_LIBS SALOME_GUI_INSTALL_RES_DATA SALOME_GUI_INSTALL_RES_SCRIPTS SALOME_GUI_INSTALL_PLUGINS)
229 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
231 # Accumulate environment variables for GUI module
232 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
233 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
234 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
235 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}
236 ${CMAKE_INSTALL_PREFIX}/${SALOME_GUI_INSTALL_PARAVIEW_LIBS})
240 IF(NOT SALOME_LIGHT_ONLY)
241 ADD_SUBDIRECTORY(idl)
244 ADD_SUBDIRECTORY(adm_local)
245 ADD_SUBDIRECTORY(resources)
246 ADD_SUBDIRECTORY(src)
248 ADD_SUBDIRECTORY(doc)
250 ADD_SUBDIRECTORY(bin)
251 ADD_SUBDIRECTORY(tools)
253 # Header configuration
254 # ====================
255 SALOME_XVERSION(${PROJECT_NAME})
256 SALOME_CONFIGURE_FILE(GUI_version.h.in GUI_version.h INSTALL ${SALOME_INSTALL_HEADERS})
258 # Configuration export
259 # (here only the level 1 prerequisites are exposed)
260 # ====================
261 INCLUDE(CMakePackageConfigHelpers)
263 # List of targets in this project we want to make visible to the rest of the world.
264 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
265 SET(_${PROJECT_NAME}_exposed_targets
266 caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser OpenGLUtils
267 QDS qtx SalomePrs SalomeStyle std SUITApp suit ViewerTools ViewerData
271 # SALOME object specific targets:
272 IF(SALOME_USE_SALOMEOBJECT)
273 LIST(APPEND _${PROJECT_NAME}_exposed_targets
275 ENDIF(SALOME_USE_SALOMEOBJECT)
277 # GL specific targets:
278 IF(SALOME_USE_GLVIEWER)
279 LIST(APPEND _${PROJECT_NAME}_exposed_targets
281 ENDIF(SALOME_USE_GLVIEWER)
283 # VTK specific targets:
284 IF(SALOME_USE_VTKVIEWER)
285 LIST(APPEND _${PROJECT_NAME}_exposed_targets
286 VTKViewer vtkTools vtkEDFOverloads)
287 IF(SALOME_USE_SALOMEOBJECT)
288 LIST(APPEND _${PROJECT_NAME}_exposed_targets
290 ENDIF(SALOME_USE_SALOMEOBJECT)
291 ENDIF(SALOME_USE_VTKVIEWER)
293 # OCC specific targets:
294 IF(SALOME_USE_OCCVIEWER)
295 LIST(APPEND _${PROJECT_NAME}_exposed_targets
297 IF(SALOME_USE_SALOMEOBJECT)
298 LIST(APPEND _${PROJECT_NAME}_exposed_targets
300 ENDIF(SALOME_USE_SALOMEOBJECT)
301 ENDIF(SALOME_USE_OCCVIEWER)
303 # Plot2d specific targets:
304 IF(SALOME_USE_PLOT2DVIEWER)
305 LIST(APPEND _${PROJECT_NAME}_exposed_targets
307 IF(SALOME_USE_SALOMEOBJECT)
308 LIST(APPEND _${PROJECT_NAME}_exposed_targets
310 ENDIF(SALOME_USE_SALOMEOBJECT)
311 ENDIF(SALOME_USE_PLOT2DVIEWER)
313 # Qx specific targets:
314 IF(SALOME_USE_QXGRAPHVIEWER)
315 LIST(APPEND _${PROJECT_NAME}_exposed_targets
317 ENDIF(SALOME_USE_QXGRAPHVIEWER)
319 # GraphicsView specific targets:
320 IF(SALOME_USE_GRAPHICSVIEW)
321 LIST(APPEND _${PROJECT_NAME}_exposed_targets
323 ENDIF(SALOME_USE_GRAPHICSVIEW)
325 # Python-based packages specific targets:
326 IF(SALOME_USE_PYCONSOLE)
327 LIST(APPEND _${PROJECT_NAME}_exposed_targets
328 PyInterp PyConsole SalomePyQtGUILight)
329 IF(SALOME_USE_PLOT2DVIEWER)
330 LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomePyQt)
332 IF(NOT SALOME_LIGHT_ONLY)
333 LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomePyQtGUI)
335 IF(SALOME_USE_VTKVIEWER)
336 LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomePy)
337 ENDIF(SALOME_USE_VTKVIEWER)
338 ENDIF(SALOME_USE_PYCONSOLE)
340 # CORBA specific targets:
341 IF(NOT SALOME_LIGHT_ONLY)
342 LIST(APPEND _${PROJECT_NAME}_exposed_targets
343 SalomeIDLGUI SalomeSession SalomeApp SalomeGuiHelpers SalomeTreeData ToolsGUI)
344 ENDIF(NOT SALOME_LIGHT_ONLY)
346 # Add all targets to the build-tree export set
347 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
348 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
350 # Create the configuration files:
351 # - in the build tree:
353 # Ensure the variables are always defined for the configure:
354 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
355 SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}")
356 SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}")
357 SET(PYQT4_ROOT_DIR "${PYQT4_ROOT_DIR}")
358 SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}")
359 SET(OPENGL_ROOT_DIR "${OPENGL_ROOT_DIR}")
360 SET(VTK_ROOT_DIR "${VTK_ROOT_DIR}")
361 SET(QWT_ROOT_DIR "${QWT_ROOT_DIR}")
363 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
365 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
366 SALOME_CONFIGURE_PREPARE(CAS OpenGL PyQt4 Qt4 Qwt SIP VTK)
368 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
369 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
370 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
371 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
372 KERNEL_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR
373 OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR)
375 # - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
376 # Get the relative path of the include directory so
377 # we can register it in the generated configuration files:
378 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
379 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
380 # ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
381 # INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
382 # PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
383 # KERNEL_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR
384 # OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR)
386 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
387 VERSION ${${PROJECT_NAME_UC}_VERSION}
388 COMPATIBILITY AnyNewerVersion)
390 # Install the CMake configuration files:
392 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
393 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
394 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
396 # Install the export set for use with the install-tree
397 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
398 FILE ${PROJECT_NAME}Targets.cmake)