1 # Copyright (C) 2010-2016 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 7)
37 SET(${PROJECT_NAME_UC}_MINOR_VERSION 7)
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:
85 FIND_PACKAGE(SalomePythonInterp REQUIRED)
86 FIND_PACKAGE(SalomePythonLibs 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 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtHelp)
125 ## Specific to ParaViS:
128 FIND_PACKAGE(SalomeParaView REQUIRED)
131 ## From MEDCoupling / MEDFile / or MEDModule (if CORBA plugin required):
134 IF(SALOME_PARAVIS_BUILD_PLUGINS)
135 # If CORBA plugins required, take in MED module
136 IF(SALOME_PARAVIS_BUILD_CORBA_PLUGINS)
137 SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR} CACHE PATH "Path to the SALOME MED module")
138 IF(EXISTS ${MED_ROOT_DIR})
139 LIST(APPEND CMAKE_MODULE_PATH "${MED_ROOT_DIR}/adm_local/cmake_files")
140 FIND_PACKAGE(SalomeMED)
141 SALOME_LOG_OPTIONAL_PACKAGE(SalomeMED SALOME_PARAVIS_BUILD_CORBA_PLUGINS)
143 ELSE(SALOME_PARAVIS_BUILD_CORBA_PLUGINS)
144 SET(MEDCOUPLING_ROOT_DIR $ENV{MEDCOUPLING_ROOT_DIR} CACHE PATH "Path to the MEDCoupling tool")
145 IF(EXISTS ${MEDCOUPLING_ROOT_DIR})
146 LIST(APPEND CMAKE_MODULE_PATH "${MEDCOUPLING_ROOT_DIR}/cmake_files")
148 FIND_PACKAGE(SalomeMEDCoupling) # will load MEDFile
149 SALOME_LOG_OPTIONAL_PACKAGE(MEDCoupling SALOME_PARAVIS_BUILD_PLUGINS)
151 ENDIF(SALOME_PARAVIS_BUILD_PLUGINS)
157 IF(SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_GEOM_SOURCE)
158 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
159 IF(EXISTS ${GEOM_ROOT_DIR})
160 LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
161 FIND_PACKAGE(SalomeGEOM REQUIRED COMPONENTS GEOMClient SalomeIDLGEOM OCC2VTK)
163 MESSAGE(WARNING "Salome GEOM is absolutely needed to import GEOM objects to PARAVIS.
164 As we do not find it, we set the variable SALOME_PARAVIS_USE_GEOM_SOURCE=OFF.
165 If you really need Salome GEOM, please define GEOM_ROOT_DIR and re-run configuration script.")
166 SET(SALOME_PARAVIS_USE_GEOM_SOURCE OFF)
168 ELSEIF(NOT SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_GEOM_SOURCE)
169 MESSAGE(WARNING "PARAVIS plugins must be built to use the import of GEOM objects to PARAVIS.
170 As plugins are not built, we set the variable SALOME_PARAVIS_USE_GEOM_SOURCE=OFF.
171 If you really want to use Salome GEOM, please set SALOME_PARAVIS_BUILD_PLUGINS=ON and re-run configuration script.")
172 SET(SALOME_PARAVIS_USE_GEOM_SOURCE OFF)
179 IF(SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_SMESH_SOURCE)
180 IF(NOT SALOME_PARAVIS_USE_GEOM_SOURCE)
181 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
182 IF(EXISTS ${GEOM_ROOT_DIR})
183 LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
184 FIND_PACKAGE(SalomeGEOM REQUIRED COMPONENTS SalomeIDLGEOM )
186 MESSAGE(WARNING "Salome GEOM is absolutely needed to import MESH objects to PARAVIS.
187 As we do not find it, we set the variable SALOME_PARAVIS_USE_SMESH_SOURCE=OFF.
188 If you really want to use Salome MESH, please define GEOM_ROOT_DIR and re-run configuration script.")
189 SET(SALOME_PARAVIS_USE_GEOM_SOURCE OFF)
190 SET(SALOME_PARAVIS_USE_SMESH_SOURCE OFF)
193 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR} CACHE PATH "Path to the Salome SMESH")
194 IF(SALOME_PARAVIS_USE_GEOM_SOURCE AND EXISTS ${SMESH_ROOT_DIR})
195 LIST(APPEND CMAKE_MODULE_PATH "${SMESH_ROOT_DIR}/adm_local/cmake_files")
196 FIND_PACKAGE(SalomeSMESH REQUIRED)
198 MESSAGE(WARNING "Salome MESH is absolutely needed to import MESH objects to PARAVIS.
199 As we do not find it, we set the variable SALOME_PARAVIS_USE_SMESH_SOURCE=OFF.
200 If you really need Salome MESH, please define SMESH_ROOT_DIR and re-run configuration script.")
201 SET(SALOME_PARAVIS_USE_SMESH_SOURCE OFF)
203 ELSEIF(NOT SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_SMESH_SOURCE)
204 MESSAGE(WARNING "PARAVIS plugins must be built to use the import of MESH objects to PARAVIS.
205 As plugins are not built, we set the variable SALOME_PARAVIS_USE_SMESH_SOURCE=OFF.
206 If you really want to use Salome MESH, please set SALOME_PARAVIS_BUILD_PLUGINS=ON and re-run configuration script.")
207 SET(SALOME_PARAVIS_USE_SMESH_SOURCE OFF)
210 IF(SALOME_BUILD_TESTS)
212 FIND_PACKAGE(SalomeCppUnit)
213 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
216 ## Detection summary:
217 SALOME_PACKAGE_REPORT_AND_CHECK()
220 # (default values taken from KERNEL)
222 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
223 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
224 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
225 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
226 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
227 "Install path: SALOME scripts")
228 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
229 "Install path: SALOME script data")
230 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
231 "Install path: SALOME Python scripts")
232 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
233 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
234 "Install path: SALOME Python shared modules")
235 SET(SALOME_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE}" CACHE PATH "Install path: SALOME CMake files")
236 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH
237 "Install path: local SALOME CMake files")
238 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
239 "Install path: local SALOME config files (obsolete, to be removed)")
241 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
242 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
244 # Specific to PARAVIS:
245 SET(SALOME_PARAVIS_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/paravis" CACHE PATH "Install path: SALOME PARAVIS specific data")
247 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
248 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
249 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
250 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
251 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC SALOME_PARAVIS_INSTALL_RES_DATA)
253 # Accumulate environment variables for PARAVIS module
254 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
255 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
256 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
257 SALOME_ACCUMULATE_ENVIRONMENT(PV_PLUGIN_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/lib/paraview)
261 ADD_SUBDIRECTORY(src)
262 ADD_SUBDIRECTORY(adm_local)
263 ADD_SUBDIRECTORY(resources)
266 ADD_SUBDIRECTORY(doc)
268 IF(SALOME_BUILD_TESTS AND NOT SALOME_LIGHT_ONLY)
269 ADD_SUBDIRECTORY(test)
271 ADD_SUBDIRECTORY(bin)
272 ADD_SUBDIRECTORY(examples)
274 # Header configuration
275 # ====================
276 SALOME_XVERSION(${PROJECT_NAME})
277 SALOME_CONFIGURE_FILE(PARAVIS_version.h.in PARAVIS_version.h INSTALL ${SALOME_INSTALL_HEADERS})
279 # Configuration export
280 # (here only the level 1 prerequisites are exposed)
281 # ====================
282 INCLUDE(CMakePackageConfigHelpers)
284 # List of targets in this project we want to make visible to the rest of the world.
285 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
286 IF(NOT SALOME_LIGHT_ONLY)
287 SET(_${PROJECT_NAME}_exposed_targets PARAVIS)
289 # Add all targets to the build-tree export set
290 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
291 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
294 # Create the configuration files:
295 # - in the build tree:
297 # Ensure the variables are always defined for the configure:
298 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
299 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
300 SET(MED_ROOT_DIR "${MED_ROOT_DIR}")
301 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
302 SET(MEDCOUPLING_ROOT_DIR "${MEDCOUPLING_ROOT_DIR}")
303 SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}")
304 SET(SMESH_ROOT_DIR "${SMESH_ROOT_DIR}")
306 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
308 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
309 SALOME_CONFIGURE_PREPARE(MEDFile)
311 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
312 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
313 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
314 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
315 KERNEL_ROOT_DIR GUI_ROOT_DIR MED_ROOT_DIR MEDFILE_ROOT_DIR MEDCOUPLING_ROOT_DIR GEOM_ROOT_DIR SMESH_ROOT_DIR)
317 # - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
318 # Get the relative path of the include directory so
319 # we can register it in the generated configuration files:
320 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
321 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
322 # ${PROJECT_BINARY_DIR}/to_install/${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 GUI_ROOT_DIR MED_ROOT_DIR MEDFILE_ROOT_DIR)
327 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
328 VERSION ${${PROJECT_NAME_UC}_VERSION}
329 COMPATIBILITY AnyNewerVersion)
331 # Install the CMake configuration files:
333 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
334 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
335 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
337 IF(NOT SALOME_LIGHT_ONLY)
338 # Install the export set for use with the install-tree
339 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
340 FILE ${PROJECT_NAME}Targets.cmake)