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