]> SALOME platform Git repositories - modules/gui.git/blob - CMakeLists.txt
Salome HOME
afa24800cefa6ea82123124a0df2fac7e3dea4fe
[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 REQUIRED)
103   SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)  
104 ENDIF()
105 IF(SALOME_BUILD_DOC)
106   FIND_PACKAGE(SalomeDoxygen REQUIRED)
107   FIND_PACKAGE(SalomeGraphviz REQUIRED)
108   FIND_PACKAGE(SalomeSphinx REQUIRED)
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 REQUIRED)
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 REQUIRED) 
140   SALOME_LOG_OPTIONAL_PACKAGE(VTK SALOME_USE_VTKVIEWER)
141 ENDIF()
142 IF(SALOME_USE_PLOT2DVIEWER)
143   FIND_PACKAGE(SalomeQwt REQUIRED)  
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 # Sources 
193 # ========
194 IF(NOT SALOME_LIGHT_ONLY)
195   ADD_SUBDIRECTORY(idl)
196 ENDIF()
197
198 ADD_SUBDIRECTORY(adm_local)
199 ADD_SUBDIRECTORY(resources)
200 ADD_SUBDIRECTORY(src)
201 IF(SALOME_BUILD_DOC)
202   ADD_SUBDIRECTORY(doc)
203 ENDIF()
204 ADD_SUBDIRECTORY(bin)
205 ADD_SUBDIRECTORY(tools)
206
207 # Header configuration
208 # ====================
209 SALOME_XVERSION(${PROJECT_NAME})
210 SALOME_CONFIGURE_FILE(GUI_version.h.in GUI_version.h INSTALL ${SALOME_INSTALL_HEADERS})
211
212 # Configuration export
213 # (here only the level 1 prerequisites are exposed)
214 # ====================
215 INCLUDE(CMakePackageConfigHelpers)
216
217 # List of targets in this project we want to make visible to the rest of the world.
218 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
219 SET(_${PROJECT_NAME}_exposed_targets 
220     caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser OpenGLUtils 
221     QDS qtx SalomeIDLGUI SalomePrs SalomeStyle std SUITApp suit ViewerTools  
222     vtkTools vtkEDFOverloads     
223 )
224
225 # SALOME object specific targets:
226 IF(SALOME_USE_SALOMEOBJECT)
227   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
228        SalomeObject)
229 ENDIF(SALOME_USE_SALOMEOBJECT)
230
231 # GL specific targets:
232 IF(SALOME_USE_GLVIEWER)
233   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
234        GLViewer)
235 ENDIF(SALOME_USE_GLVIEWER)
236
237 # VTK specific targets:
238 IF(SALOME_USE_VTKVIEWER)
239   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
240        VTKViewer)
241   IF(SALOME_USE_SALOMEOBJECT)
242     LIST(APPEND _${PROJECT_NAME}_exposed_targets 
243          SVTK)
244   ENDIF(SALOME_USE_SALOMEOBJECT)
245 ENDIF(SALOME_USE_VTKVIEWER)
246
247 # OCC specific targets:
248 IF(SALOME_USE_OCCVIEWER)
249   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
250        OCCViewer)
251   IF(SALOME_USE_SALOMEOBJECT)
252     LIST(APPEND _${PROJECT_NAME}_exposed_targets 
253          SOCC)
254   ENDIF(SALOME_USE_SALOMEOBJECT)
255 ENDIF(SALOME_USE_OCCVIEWER)
256
257 # Plot2d specific targets:
258 IF(SALOME_USE_PLOT2DVIEWER)
259   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
260        Plot2d)
261   IF(SALOME_USE_SALOMEOBJECT)
262     LIST(APPEND _${PROJECT_NAME}_exposed_targets 
263          SPlot2d)
264   ENDIF(SALOME_USE_SALOMEOBJECT)
265 ENDIF(SALOME_USE_PLOT2DVIEWER)
266
267 # Qx specific targets:
268 IF(SALOME_USE_QXGRAPHVIEWER)
269   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
270        QxScene)
271 ENDIF(SALOME_USE_QXGRAPHVIEWER)
272
273 # Python-based packages specific targets:
274 IF(SALOME_USE_PYCONSOLE)
275   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
276        PyInterp PyConsole SalomePy SalomePyQtGUI SalomePyQtGUILight SalomePyQt)
277 ENDIF(SALOME_USE_PYCONSOLE)
278
279 # CORBA specific targets:
280 IF(NOT SALOME_LIGHT_ONLY)
281   LIST(APPEND _${PROJECT_NAME}_exposed_targets
282        SalomeSession SalomeApp SalomeGuiHelpers SalomeTreeData ToolsGUI)
283 ENDIF(NOT SALOME_LIGHT_ONLY)
284
285 # Add all targets to the build-tree export set
286 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
287   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
288
289 # Create the configuration files:
290 #   - in the build tree:
291
292 #      Ensure the variables are always defined for the configure:
293 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
294 SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}")
295 SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}")
296 SET(PYQT4_ROOT_DIR "${PYQT4_ROOT_DIR}")
297 SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}")
298 SET(OPENGL_ROOT_DIR "${OPENGL_ROOT_DIR}")
299 SET(VTK_ROOT_DIR "${VTK_ROOT_DIR}")
300 SET(QWT_ROOT_DIR "${QWT_ROOT_DIR}")
301  
302 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
303 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in 
304     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
305     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
306     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
307        KERNEL_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR 
308        OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR)
309
310 #   - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
311 #       Get the relative path of the include directory so 
312 #       we can register it in the generated configuration files:
313 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
314 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in 
315 #    ${PROJECT_BINARY_DIR}/to_install/${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 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)