1 # Copyright (C) 2010-2015 CEA/DEN, EDF R&D
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)
21 PROJECT(SalomePARAVIS C CXX)
24 STRING( REPLACE "INCREMENTAL:YES" "INCREMENTAL:NO" replacementFlags ${CMAKE_SHARED_LINKER_FLAGS_DEBUG} )
25 SET( CMAKE_SHARED_LINKER_FLAGS_DEBUG "${replacementFlags}" )
28 # Ensure a proper linker behavior:
29 CMAKE_POLICY(SET CMP0003 NEW)
33 # Project name, upper case
34 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
36 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 8)
37 SET(${PROJECT_NAME_UC}_MINOR_VERSION 0)
38 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
39 SET(${PROJECT_NAME_UC}_VERSION
40 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
41 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
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 ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
51 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
52 ELSE(EXISTS ${KERNEL_ROOT_DIR})
53 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
54 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
58 INCLUDE(SalomeSetupPlatform) # From KERNEL
59 # Always build libraries as shared objects:
60 SET(BUILD_SHARED_LIBS TRUE)
62 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
66 OPTION(SALOME_BUILD_DOC "Generate SALOME GUI documentation" ON)
67 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
68 OPTION(SALOME_PARAVIS_ALL_TEST "Add all tests for Salome PARAVIS module" OFF)
69 OPTION(SALOME_PARAVIS_BUILD_PLUGINS "Build PARAVIS plugins (MEDReader, etc ...)" ON)
70 OPTION(SALOME_PARAVIS_BUILD_CORBA_PLUGINS "Build PARAVIS CORBA plugins (ParaMEDCorba -- this requires the SALOME MED module)" ON)
71 OPTION(SALOME_PARAVIS_USE_GEOM_SOURCE "Import a GEOMETRY object to PARAVIS via its Corba IOR" OFF)
72 OPTION(SALOME_PARAVIS_USE_SMESH_SOURCE "Import a MESH object to PARAVIS via its Corba IOR" OFF)
73 CMAKE_DEPENDENT_OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF
74 "NOT SALOME_KERNEL_LIGHT_ONLY" ON)
78 # Find "big" prerequisites first - they reference themselves many others
79 # -> this can help finding the smaller prerequisites and detect conficts.
80 # In our case KERNEL has already loaded many prereq which are also used in GUI:
86 FIND_PACKAGE(SalomePython REQUIRED)
88 IF(NOT SALOME_LIGHT_ONLY)
89 FIND_PACKAGE(SalomeOmniORB REQUIRED)
93 FIND_PACKAGE(SalomeDoxygen)
94 FIND_PACKAGE(SalomeGraphviz)
95 FIND_PACKAGE(SalomeSphinx)
96 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
97 SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC)
98 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
102 # ===================
103 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
104 IF(EXISTS ${GUI_ROOT_DIR})
105 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
106 # We should skip detection of VTK (done automatically from GUI) as we need to detect ParaView instead;
107 # otherwise ParaView targets are not found
108 SET(OMIT_DETECT_PACKAGE_VTK ON)
109 FIND_PACKAGE(SalomeGUI REQUIRED)
110 SALOME_GUI_WITH_CORBA() # check whether GUI builded with CORBA
111 SALOME_GUI_MODE(SALOME_USE_SALOMEOBJECT SALOME_USE_PVVIEWER)
112 ADD_DEFINITIONS(${GUI_DEFINITIONS})
113 INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
115 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR")
122 IF (NOT SALOME_GUI_BUILD_WITH_QT5)
123 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtHelp)
125 FIND_PACKAGE(SalomeQt5 REQUIRED)
129 ## Specific to ParaViS:
132 FIND_PACKAGE(SalomeParaView REQUIRED)
135 ## From MEDCoupling / MEDFile / or MEDModule (if CORBA plugin required):
138 IF(SALOME_PARAVIS_BUILD_PLUGINS)
139 # If CORBA plugins required, take in MED module
140 IF(SALOME_PARAVIS_BUILD_CORBA_PLUGINS)
141 SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR} CACHE PATH "Path to the SALOME MED module")
142 IF(EXISTS ${MED_ROOT_DIR})
143 LIST(APPEND CMAKE_MODULE_PATH "${MED_ROOT_DIR}/adm_local/cmake_files")
144 FIND_PACKAGE(SalomeMED)
145 SALOME_LOG_OPTIONAL_PACKAGE(SalomeMED SALOME_PARAVIS_BUILD_CORBA_PLUGINS)
147 ELSE(SALOME_PARAVIS_BUILD_CORBA_PLUGINS)
148 SET(MEDCOUPLING_ROOT_DIR $ENV{MEDCOUPLING_ROOT_DIR} CACHE PATH "Path to the MEDCoupling tool")
149 IF(EXISTS ${MEDCOUPLING_ROOT_DIR})
150 LIST(APPEND CMAKE_MODULE_PATH "${MEDCOUPLING_ROOT_DIR}/cmake_files")
152 FIND_PACKAGE(SalomeMEDCoupling) # will load MEDFile
153 SALOME_LOG_OPTIONAL_PACKAGE(MEDCoupling SALOME_PARAVIS_BUILD_PLUGINS)
155 ENDIF(SALOME_PARAVIS_BUILD_PLUGINS)
161 IF(SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_GEOM_SOURCE)
162 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
163 IF(EXISTS ${GEOM_ROOT_DIR})
164 LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
165 FIND_PACKAGE(SalomeGEOM REQUIRED COMPONENTS GEOMClient SalomeIDLGEOM OCC2VTK)
167 MESSAGE(WARNING "Salome GEOM is absolutely needed to import GEOM objects to PARAVIS.
168 As we do not find it, we set the variable SALOME_PARAVIS_USE_GEOM_SOURCE=OFF.
169 If you really need Salome GEOM, please define GEOM_ROOT_DIR and re-run configuration script.")
170 SET(SALOME_PARAVIS_USE_GEOM_SOURCE OFF)
172 ELSEIF(NOT SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_GEOM_SOURCE)
173 MESSAGE(WARNING "PARAVIS plugins must be built to use the import of GEOM objects to PARAVIS.
174 As plugins are not built, we set the variable SALOME_PARAVIS_USE_GEOM_SOURCE=OFF.
175 If you really want to use Salome GEOM, please set SALOME_PARAVIS_BUILD_PLUGINS=ON and re-run configuration script.")
176 SET(SALOME_PARAVIS_USE_GEOM_SOURCE OFF)
183 IF(SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_SMESH_SOURCE)
184 IF(NOT SALOME_PARAVIS_USE_GEOM_SOURCE)
185 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
186 IF(EXISTS ${GEOM_ROOT_DIR})
187 LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
188 FIND_PACKAGE(SalomeGEOM REQUIRED COMPONENTS SalomeIDLGEOM )
190 MESSAGE(WARNING "Salome GEOM is absolutely needed to import MESH objects to PARAVIS.
191 As we do not find it, we set the variable SALOME_PARAVIS_USE_SMESH_SOURCE=OFF.
192 If you really want to use Salome MESH, please define GEOM_ROOT_DIR and re-run configuration script.")
193 SET(SALOME_PARAVIS_USE_GEOM_SOURCE OFF)
194 SET(SALOME_PARAVIS_USE_SMESH_SOURCE OFF)
197 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR} CACHE PATH "Path to the Salome SMESH")
198 IF(SALOME_PARAVIS_USE_GEOM_SOURCE AND EXISTS ${SMESH_ROOT_DIR})
199 LIST(APPEND CMAKE_MODULE_PATH "${SMESH_ROOT_DIR}/adm_local/cmake_files")
200 FIND_PACKAGE(SalomeSMESH REQUIRED)
202 MESSAGE(WARNING "Salome MESH is absolutely needed to import MESH objects to PARAVIS.
203 As we do not find it, we set the variable SALOME_PARAVIS_USE_SMESH_SOURCE=OFF.
204 If you really need Salome MESH, please define SMESH_ROOT_DIR and re-run configuration script.")
205 SET(SALOME_PARAVIS_USE_SMESH_SOURCE OFF)
207 ELSEIF(NOT SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_SMESH_SOURCE)
208 MESSAGE(WARNING "PARAVIS plugins must be built to use the import of MESH objects to PARAVIS.
209 As plugins are not built, we set the variable SALOME_PARAVIS_USE_SMESH_SOURCE=OFF.
210 If you really want to use Salome MESH, please set SALOME_PARAVIS_BUILD_PLUGINS=ON and re-run configuration script.")
211 SET(SALOME_PARAVIS_USE_SMESH_SOURCE OFF)
214 IF(SALOME_BUILD_TESTS)
216 FIND_PACKAGE(SalomeCppUnit)
217 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
220 ## Detection summary:
221 SALOME_PACKAGE_REPORT_AND_CHECK()
224 # (default values taken from KERNEL)
226 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
227 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
228 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
229 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
230 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
231 "Install path: SALOME scripts")
232 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
233 "Install path: SALOME script data")
234 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
235 "Install path: SALOME Python scripts")
236 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
237 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
238 "Install path: SALOME Python shared modules")
239 SET(SALOME_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE}" CACHE PATH "Install path: SALOME CMake files")
240 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH
241 "Install path: local SALOME CMake files")
242 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
243 "Install path: local SALOME config files (obsolete, to be removed)")
245 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
246 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
248 # Specific to PARAVIS:
249 SET(SALOME_PARAVIS_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/paravis" CACHE PATH "Install path: SALOME PARAVIS specific data")
251 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
252 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
253 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
254 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
255 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC SALOME_PARAVIS_INSTALL_RES_DATA)
257 # Accumulate environment variables for PARAVIS module
258 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
259 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
260 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
261 SALOME_ACCUMULATE_ENVIRONMENT(PV_PLUGIN_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/lib/paraview)
265 ADD_SUBDIRECTORY(src)
266 ADD_SUBDIRECTORY(adm_local)
267 ADD_SUBDIRECTORY(resources)
270 ADD_SUBDIRECTORY(doc)
272 IF(SALOME_BUILD_TESTS AND NOT SALOME_LIGHT_ONLY)
273 ADD_SUBDIRECTORY(test)
275 ADD_SUBDIRECTORY(bin)
276 ADD_SUBDIRECTORY(examples)
278 # Header configuration
279 # ====================
280 SALOME_XVERSION(${PROJECT_NAME})
281 SALOME_CONFIGURE_FILE(PARAVIS_version.h.in PARAVIS_version.h INSTALL ${SALOME_INSTALL_HEADERS})
283 # Configuration export
284 # (here only the level 1 prerequisites are exposed)
285 # ====================
286 INCLUDE(CMakePackageConfigHelpers)
288 # List of targets in this project we want to make visible to the rest of the world.
289 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
290 IF(NOT SALOME_LIGHT_ONLY)
291 SET(_${PROJECT_NAME}_exposed_targets PARAVIS)
293 # Add all targets to the build-tree export set
294 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
295 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
298 # Create the configuration files:
299 # - in the build tree:
301 # Ensure the variables are always defined for the configure:
302 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
303 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
304 SET(MED_ROOT_DIR "${MED_ROOT_DIR}")
305 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
306 SET(MEDCOUPLING_ROOT_DIR "${MEDCOUPLING_ROOT_DIR}")
307 SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}")
308 SET(SMESH_ROOT_DIR "${SMESH_ROOT_DIR}")
310 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
312 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
313 SALOME_CONFIGURE_PREPARE(MEDFile)
315 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
316 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
317 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
318 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
319 KERNEL_ROOT_DIR GUI_ROOT_DIR MED_ROOT_DIR MEDFILE_ROOT_DIR MEDCOUPLING_ROOT_DIR GEOM_ROOT_DIR SMESH_ROOT_DIR)
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 GUI_ROOT_DIR MED_ROOT_DIR MEDFILE_ROOT_DIR)
331 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
332 VERSION ${${PROJECT_NAME_UC}_VERSION}
333 COMPATIBILITY AnyNewerVersion)
335 # Install the CMake configuration files:
337 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
338 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
339 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
341 IF(NOT SALOME_LIGHT_ONLY)
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)