1 # Copyright (C) 2012-2013 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.
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 PROJECT(SalomeGUI C CXX)
22 # Ensure a proper linker behavior:
23 CMAKE_POLICY(SET CMP0003 NEW)
25 #set(CMAKE_PREFIX_PATH "")
26 #set(_compo QtCore QtGui)
27 #find_package(Qt4 REQUIRED COMPONENTS _compo)
31 # Project name, upper case
32 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
34 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
35 SET(${PROJECT_NAME_UC}_MINOR_VERSION 2)
36 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
37 SET(${PROJECT_NAME_UC}_VERSION
38 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
39 # Temporary backward compatibility:
40 SET(VERSION ${${PROJECT_NAME_UC}_VERSION})
45 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
46 IF(EXISTS ${KERNEL_ROOT_DIR})
47 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
49 FIND_PACKAGE(SalomeKERNEL REQUIRED)
50 ELSE(EXISTS ${KERNEL_ROOT_DIR})
51 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
52 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
57 INCLUDE(SalomeSetupPlatform) # From KERNEL
58 # Always build libraries as shared objects:
59 SET(BUILD_SHARED_LIBS TRUE)
61 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
64 # (some options have already been defined in KERNEL)
66 OPTION(SALOME_USE_MPI "Use MPI containers" ${SALOME_USE_MPI})
67 OPTION(SALOME_BUILD_DOC "Generate SALOME GUI documentation" ${SALOME_BUILD_DOC})
68 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ${SALOME_BUILD_TESTS})
71 OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" ${SALOME_LIGHT_ONLY})
73 OPTION(SALOME_USE_VTKVIEWER "Enable VTK visualization (Mandatory in classic configurations)" ON)
74 OPTION(SALOME_USE_SALOMEOBJECT "Enable Salome Object (Mandatory in classic configurations)" ON)
75 OPTION(SALOME_USE_OCCVIEWER "Enable OCC visualization (Mandatory in classic configurations)" ON)
76 OPTION(SALOME_USE_GLVIEWER "Enable OpenGL visualization (Mandatory in classic configurations)" ON)
77 OPTION(SALOME_USE_PLOT2DVIEWER "Enable Plot2D visualization (Mandatory in classic configurations)" ON)
78 OPTION(SALOME_USE_PYCONSOLE "Enable Python GUI interface (Mandatory in classic configurations)" ON)
79 OPTION(SALOME_USE_SUPERVGRAPHVIEWER "Enable Supervision visualization (Mandatory in classic configurations)" ON)
80 OPTION(SALOME_USE_QXGRAPHVIEWER "Enable QX graph visualization (Mandatory in classic configurations)" ON)
82 MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_USE_VTKVIEWER SALOME_USE_VTKVIEWER)
83 MARK_AS_ADVANCED(SALOME_USE_SALOMEOBJECT SALOME_USE_OCCVIEWER SALOME_USE_GLVIEWER SALOME_USE_PLOT2DVIEWER)
84 MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_SUPERVGRAPHVIEWER SALOME_USE_QXGRAPHVIEWER)
88 # Find "big" prerequisites first - they reference themselves many others
89 # -> this can help finding the smaller prerequisites and detect conficts.
90 # In our case KERNEL has already loaded many prereq:
97 FIND_PACKAGE(SalomePython REQUIRED)
98 FIND_PACKAGE(SalomePThread REQUIRED)
99 FIND_PACKAGE(SalomeSWIG REQUIRED)
100 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
101 FIND_PACKAGE(SalomeBoost REQUIRED)
102 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
104 # Other KERNEL optionals:
106 FIND_PACKAGE(SalomeMPI REQUIRED)
108 SALOME_ADD_MPI_TO_HDF5()
111 IF(NOT SALOME_LIGHT_ONLY)
112 FIND_PACKAGE(SalomeOmniORB REQUIRED)
113 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
115 IF(SALOME_BUILD_TESTS)
117 FIND_PACKAGE(SalomeCppUnit REQUIRED)
120 FIND_PACKAGE(SalomeDoxygen REQUIRED)
121 FIND_PACKAGE(SalomeGraphviz) # Remains optional even here.
122 FIND_PACKAGE(SalomeSphinx REQUIRED)
129 FIND_PACKAGE(SalomeSIP REQUIRED) # should come after Python and before PyQt4
132 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtWebKit QtOpenGL)
133 INCLUDE(${QT_USE_FILE})
135 FIND_PACKAGE(SalomePyQt4 REQUIRED)
137 # Optional prerequisites for GUI
138 IF(SALOME_USE_OCCVIEWER)
139 FIND_PACKAGE(SalomeCAS REQUIRED)
141 IF(SALOME_USE_GLVIEWER)
142 FIND_PACKAGE(SalomeOpenGL REQUIRED)
144 IF(SALOME_USE_VTKVIEWER)
145 # Required components are listed in the FindSalomeVTK.cmake file:
146 FIND_PACKAGE(SalomeVTK 6.0 REQUIRED)
148 IF(SALOME_USE_PLOT2DVIEWER)
149 FIND_PACKAGE(SalomeQwt REQUIRED)
153 # (default values taken from KERNEL)
155 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
156 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
157 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
158 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
159 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
160 "Install path: SALOME scripts")
161 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
162 "Install path: SALOME script data")
163 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
164 "Install path: SALOME Python scripts")
165 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH
166 "Install path: SALOME application skeleton - scripts")
167 SET(SALOME_INSTALL_APPLISKEL_PYTHON "${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH
168 "Install path: SALOME application skeleton - Python")
169 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
170 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
171 "Install path: SALOME Python shared modules")
172 SET(SALOME_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE}" CACHE PATH "Install path: SALOME CMake files")
173 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH
174 "Install path: local SALOME CMake files")
176 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
179 SET(SALOME_GUI_INSTALL_PARAVIEW_LIBS lib/paraview CACHE PATH
180 "Install path: SALOME GUI ParaView libraries")
181 SET(SALOME_GUI_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/gui" CACHE PATH
182 "Install path: SALOME GUI specific data")
183 SET(SALOME_GUI_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/gui" CACHE PATH
184 "Install path: SALOME GUI scripts")
185 SET(SALOME_GUI_INSTALL_PLUGINS share/salome/plugins/gui CACHE PATH
186 "Install path: SALOME GUI plugins")
188 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
189 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
190 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
191 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
192 MARK_AS_ADVANCED(SALOME_GUI_INSTALL_PARAVIEW_LIBS SALOME_GUI_INSTALL_RES_DATA SALOME_GUI_INSTALL_RES_SCRIPTS SALOME_GUI_INSTALL_PLUGINS)
196 IF(NOT SALOME_LIGHT_ONLY)
209 FOREACH(dir ${SUBDIRS})
210 ADD_SUBDIRECTORY(${dir})
211 ENDFOREACH(dir ${SUBDIRS})
213 # Header configuration
214 # ====================
215 EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; t=sys.argv[-1].split(\".\") ; t[:]=(int(elt) for elt in t) ; sys.stdout.write(\"0x%02x%02x%02x\"%tuple(t))" ${${PROJECT_NAME_UC}_VERSION}
216 OUTPUT_VARIABLE XVERSION)
218 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/GUI_version.h.in)
219 SET(output ${CMAKE_CURRENT_BINARY_DIR}/GUI_version.h)
220 MESSAGE(STATUS "Creation of ${output}")
221 CONFIGURE_FILE(${input} ${output} @ONLY)
222 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/GUI_version.h DESTINATION ${SALOME_INSTALL_HEADERS})
224 # Configuration export
225 # (here only the level 1 prerequisites are exposed)
226 # ====================
227 INCLUDE(CMakePackageConfigHelpers)
229 # List of targets in this project we want to make visible to the rest of the world.
230 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
231 SET(_${PROJECT_NAME}_exposed_targets
232 caf CAM CASCatch DDS Event GLViewer LightApp LogWindow ObjBrowser
233 OCCViewer OpenGLUtils Plot2d PyConsole PyInterp QDS qtx QxScene SalomeApp
234 SalomeIDLGUI SalomeObject SalomePrs SalomePyQtGUILight SalomePyQtGUI
235 SalomePyQt SalomePy SalomeSession SalomeStyle SOCC SPlot2d std SUITApp suit
236 SUPERVGraph SVTK ToolsGUI ViewerTools VTKViewer vtkTools vtkEDFOverloads SalomeGuiHelpers
240 IF(SALOME_BUILD_TESTS)
241 LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomeAppTest)
244 # Add all targets to the build-tree export set
245 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
246 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
248 # Create the configuration files:
249 # - in the build tree:
251 # Ensure the variables are always defined for the configure:
252 SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}")
253 SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}")
254 SET(PYQT4_ROOT_DIR "${PYQT4_ROOT_DIR}")
255 SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}")
256 SET(OPENGL_ROOT_DIR "${OPENGL_ROOT_DIR}")
257 SET(VTK_ROOT_DIR "${VTK_ROOT_DIR}")
258 SET(QWT_ROOT_DIR "${QWT_ROOT_DIR}")
260 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
261 CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
262 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
263 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
264 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
265 KERNEL_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR
266 OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR)
268 # - in the install tree:
269 # Get the relative path of the include directory so
270 # we can register it in the generated configuration files:
271 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
272 CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
273 ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
274 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
275 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
276 KERNEL_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR
277 OPENGL_ROOT_DIR VTK_ROOT_DIR QWT_ROOT_DIR)
279 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
280 VERSION ${${PROJECT_NAME_UC}_VERSION}
281 COMPATIBILITY AnyNewerVersion)
283 # Install the CMake configuration files:
285 "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
286 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
287 DESTINATION "${SALOME_INSTALL_CMAKE}")
289 # Install the export set for use with the install-tree
290 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}"
291 FILE ${PROJECT_NAME}Targets.cmake)