]> SALOME platform Git repositories - modules/gui.git/blob - CMakeLists.txt
Salome HOME
8aa9812237db4bd0954e9056430afbdf1c0a8a22
[modules/gui.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(SalomeGUI 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   ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
45   INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
46 ELSE(EXISTS ${KERNEL_ROOT_DIR})
47   MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
48 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
49
50 # Platform setup
51 # ==============
52 INCLUDE(SalomeSetupPlatform)   # From KERNEL
53 # Always build libraries as shared objects:
54 SET(BUILD_SHARED_LIBS TRUE)
55 # Local macros:
56 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
57
58 # User options
59 # (some options have already been defined in KERNEL) 
60 # ============
61 OPTION(SALOME_BUILD_DOC "Generate SALOME GUI documentation" ON)
62 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
63
64 # Advanced options:
65 OPTION(SALOME_USE_VTKVIEWER "Enable VTK visualization (Mandatory in classic configurations)" ON)
66 OPTION(SALOME_USE_SALOMEOBJECT "Enable Salome Object (Mandatory in classic configurations)" ON)
67 OPTION(SALOME_USE_OCCVIEWER "Enable OCC visualization (Mandatory in classic configurations)" ON)
68 OPTION(SALOME_USE_GLVIEWER "Enable OpenGL visualization (Mandatory in classic configurations)" ON)
69 OPTION(SALOME_USE_GRAPHICSVIEW "Enable GraphicsView visualization (Mandatory in classic configurations)" ON)
70 OPTION(SALOME_USE_PLOT2DVIEWER "Enable Plot2D visualization (Mandatory in classic configurations)" ON)
71 OPTION(SALOME_USE_PYCONSOLE "Enable Python GUI interface (Mandatory in classic configurations)" ON)
72 OPTION(SALOME_USE_QXGRAPHVIEWER "Enable QX graph visualization (Mandatory in classic configurations)" ON)
73
74 MARK_AS_ADVANCED(SALOME_USE_VTKVIEWER SALOME_USE_VTKVIEWER SALOME_USE_GRAPHICSVIEW)
75 MARK_AS_ADVANCED(SALOME_USE_SALOMEOBJECT SALOME_USE_OCCVIEWER SALOME_USE_GLVIEWER SALOME_USE_PLOT2DVIEWER)
76 MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_QXGRAPHVIEWER)
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 which are also used in GUI:
83
84 ##
85 ## From KERNEL:
86 ##
87
88 # Various
89 FIND_PACKAGE(SalomePython REQUIRED)
90 FIND_PACKAGE(SalomePThread REQUIRED)
91 FIND_PACKAGE(SalomeSWIG REQUIRED)
92 #FIND_PACKAGE(SalomeLibXml2 REQUIRED)
93 FIND_PACKAGE(SalomeBoost REQUIRED)
94 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
95
96 # Other KERNEL optionals:
97 IF(NOT SALOME_LIGHT_ONLY)
98   FIND_PACKAGE(SalomeOmniORB REQUIRED)
99   FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
100 ENDIF() 
101 IF(SALOME_BUILD_TESTS)
102   ENABLE_TESTING()
103   FIND_PACKAGE(SalomeCppUnit)
104   SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)  
105 ENDIF()
106 IF(SALOME_BUILD_DOC)
107   FIND_PACKAGE(SalomeDoxygen)
108   FIND_PACKAGE(SalomeGraphviz)
109   FIND_PACKAGE(SalomeSphinx)
110   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
111   SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC)
112   SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
113 ENDIF()
114
115 ##
116 ## GUI specifics
117 ##
118
119 FIND_PACKAGE(SalomeSIP REQUIRED)  # should come after Python and before PyQt4
120
121 # Build with GUI observers feature
122 ADD_DEFINITIONS(-DWITH_SALOMEDS_OBSERVER)
123
124 # OCCT
125 FIND_PACKAGE(SalomeCAS REQUIRED)
126
127 # Qt4
128 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtWebKit QtOpenGL)
129 INCLUDE(${QT_USE_FILE})
130
131 FIND_PACKAGE(SalomePyQt4 REQUIRED)
132
133 # Optional prerequisites for GUI
134 IF(SALOME_USE_GLVIEWER)
135   FIND_PACKAGE(SalomeOpenGL)
136   SALOME_LOG_OPTIONAL_PACKAGE(OpenGL SALOME_USE_GLVIEWER) 
137 ENDIF()
138 IF(SALOME_USE_VTKVIEWER)
139   # Required components are listed in the FindSalomeVTK.cmake file: 
140   FIND_PACKAGE(SalomeVTK 6.0) 
141   SALOME_LOG_OPTIONAL_PACKAGE(VTK SALOME_USE_VTKVIEWER)
142 ENDIF()
143 IF(SALOME_USE_PLOT2DVIEWER)
144   FIND_PACKAGE(SalomeQwt)  
145   SALOME_LOG_OPTIONAL_PACKAGE(Qwt SALOME_USE_PLOT2DVIEWER)
146 ENDIF()
147
148 # Detection summary:
149 SALOME_PACKAGE_REPORT_AND_CHECK()
150
151 # Directories
152 # (default values taken from KERNEL)
153 # ===========
154 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
155 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
156 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
157 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
158 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH 
159    "Install path: SALOME scripts")
160 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH 
161    "Install path: SALOME script data")
162 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH 
163    "Install path: SALOME Python scripts")
164 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
165 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH 
166    "Install path: SALOME Python shared modules")
167 SET(SALOME_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE}" CACHE PATH "Install path: SALOME CMake files")
168 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH 
169     "Install path: local SALOME CMake files") 
170 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
171   "Install path: local SALOME config files (obsolete, to be removed)")
172
173 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
174 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
175
176 # Specific to GUI:
177 SET(SALOME_GUI_INSTALL_PARAVIEW_LIBS lib/paraview CACHE PATH 
178     "Install path: SALOME GUI ParaView libraries")
179 SET(SALOME_GUI_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/gui" CACHE PATH 
180     "Install path: SALOME GUI specific data")
181 SET(SALOME_GUI_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/gui" CACHE PATH 
182     "Install path: SALOME GUI scripts")
183 SET(SALOME_GUI_INSTALL_PLUGINS share/salome/plugins/gui CACHE PATH 
184     "Install path: SALOME GUI plugins")
185
186 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
187 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
188 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
189 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
190 MARK_AS_ADVANCED(SALOME_GUI_INSTALL_PARAVIEW_LIBS SALOME_GUI_INSTALL_RES_DATA SALOME_GUI_INSTALL_RES_SCRIPTS SALOME_GUI_INSTALL_PLUGINS)
191 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC)
192
193 # Accumulate environment variables for GUI module
194 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
195                                          ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
196                                          ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
197 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}
198                                               ${CMAKE_INSTALL_PREFIX}/${SALOME_GUI_INSTALL_PARAVIEW_LIBS}) 
199                                               
200 # Sources 
201 # ========
202 IF(NOT SALOME_LIGHT_ONLY)
203   ADD_SUBDIRECTORY(idl)
204 ENDIF()
205
206 ADD_SUBDIRECTORY(adm_local)
207 ADD_SUBDIRECTORY(resources)
208 ADD_SUBDIRECTORY(src)
209 IF(SALOME_BUILD_DOC)
210   ADD_SUBDIRECTORY(doc)
211 ENDIF()
212 ADD_SUBDIRECTORY(bin)
213 ADD_SUBDIRECTORY(tools)
214
215 # Header configuration
216 # ====================
217 SALOME_XVERSION(${PROJECT_NAME})
218 SALOME_CONFIGURE_FILE(GUI_version.h.in GUI_version.h INSTALL ${SALOME_INSTALL_HEADERS})
219
220 # Configuration export
221 # (here only the level 1 prerequisites are exposed)
222 # ====================
223 INCLUDE(CMakePackageConfigHelpers)
224
225 # List of targets in this project we want to make visible to the rest of the world.
226 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
227 SET(_${PROJECT_NAME}_exposed_targets 
228     caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser OpenGLUtils 
229     QDS qtx SalomeIDLGUI SalomePrs SalomeStyle std SUITApp suit ViewerTools  
230     vtkTools vtkEDFOverloads ImageComposer
231 )
232
233 # SALOME object specific targets:
234 IF(SALOME_USE_SALOMEOBJECT)
235   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
236        SalomeObject)
237 ENDIF(SALOME_USE_SALOMEOBJECT)
238
239 # GL specific targets:
240 IF(SALOME_USE_GLVIEWER)
241   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
242        GLViewer)
243 ENDIF(SALOME_USE_GLVIEWER)
244
245 # VTK specific targets:
246 IF(SALOME_USE_VTKVIEWER)
247   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
248        VTKViewer)
249   IF(SALOME_USE_SALOMEOBJECT)
250     LIST(APPEND _${PROJECT_NAME}_exposed_targets 
251          SVTK)
252   ENDIF(SALOME_USE_SALOMEOBJECT)
253 ENDIF(SALOME_USE_VTKVIEWER)
254
255 # OCC specific targets:
256 IF(SALOME_USE_OCCVIEWER)
257   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
258        OCCViewer)
259   IF(SALOME_USE_SALOMEOBJECT)
260     LIST(APPEND _${PROJECT_NAME}_exposed_targets 
261          SOCC)
262   ENDIF(SALOME_USE_SALOMEOBJECT)
263 ENDIF(SALOME_USE_OCCVIEWER)
264
265 # Plot2d specific targets:
266 IF(SALOME_USE_PLOT2DVIEWER)
267   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
268        Plot2d)
269   IF(SALOME_USE_SALOMEOBJECT)
270     LIST(APPEND _${PROJECT_NAME}_exposed_targets 
271          SPlot2d)
272   ENDIF(SALOME_USE_SALOMEOBJECT)
273 ENDIF(SALOME_USE_PLOT2DVIEWER)
274
275 # Qx specific targets:
276 IF(SALOME_USE_QXGRAPHVIEWER)
277   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
278        QxScene)
279 ENDIF(SALOME_USE_QXGRAPHVIEWER)
280
281 # GraphicsView specific targets:
282 IF(SALOME_USE_GRAPHICSVIEW)
283   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
284        GraphicsView)
285 ENDIF(SALOME_USE_GRAPHICSVIEW)
286
287 # Python-based packages specific targets:
288 IF(SALOME_USE_PYCONSOLE)
289   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
290        PyInterp PyConsole SalomePy SalomePyQtGUI SalomePyQtGUILight SalomePyQt)
291 ENDIF(SALOME_USE_PYCONSOLE)
292
293 # CORBA specific targets:
294 IF(NOT SALOME_LIGHT_ONLY)
295   LIST(APPEND _${PROJECT_NAME}_exposed_targets
296        SalomeSession SalomeApp SalomeGuiHelpers SalomeTreeData ToolsGUI)
297 ENDIF(NOT SALOME_LIGHT_ONLY)
298
299 # Add all targets to the build-tree export set
300 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
301   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
302
303 # Create the configuration files:
304 #   - in the build tree:
305
306 #      Ensure the variables are always defined for the configure:
307 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
308 SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}")
309 SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}")
310 SET(PYQT4_ROOT_DIR "${PYQT4_ROOT_DIR}")
311 SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}")
312 SET(OPENGL_ROOT_DIR "${OPENGL_ROOT_DIR}")
313 SET(VTK_ROOT_DIR "${VTK_ROOT_DIR}")
314 SET(QWT_ROOT_DIR "${QWT_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(CAS OpenGL PyQt4 Qt4 Qwt SIP VTK)
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        KERNEL_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR 
326        OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR)
327
328 #   - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
329 #       Get the relative path of the include directory so 
330 #       we can register it in the generated configuration files:
331 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
332 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in 
333 #    ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
334 #    INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
335 #    PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX 
336 #       KERNEL_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR 
337 #       OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR)
338
339 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
340     VERSION ${${PROJECT_NAME_UC}_VERSION}
341     COMPATIBILITY AnyNewerVersion)
342   
343 # Install the CMake configuration files:
344 INSTALL(FILES
345   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
346   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
347   DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
348
349 # Install the export set for use with the install-tree
350 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" 
351         FILE ${PROJECT_NAME}Targets.cmake)