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 7)
37 SET(${PROJECT_NAME_UC}_MINOR_VERSION 6)
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")
64 # Detect GUI root dir (but doesn't find GUI yet! See below)
66 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
67 IF(EXISTS ${GUI_ROOT_DIR})
68 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
70 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR")
75 OPTION(SALOME_BUILD_DOC "Generate SALOME GUI documentation" ON)
76 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
77 OPTION(SALOME_PARAVIS_ALL_TEST "Add all tests for Salome PARAVIS module" OFF)
78 OPTION(SALOME_PARAVIS_BUILD_PLUGINS "Build PARAVIS plugins (MEDReader, etc ...)" ON)
79 OPTION(SALOME_PARAVIS_USE_GEOM_SOURCE "Import a GEOMETRY object to PARAVIS via its Corba IOR" ON )
80 OPTION(SALOME_PARAVIS_USE_SMESH_SOURCE "Import a MESH object to PARAVIS via its Corba IOR" ON)
81 CMAKE_DEPENDENT_OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF
82 "NOT SALOME_KERNEL_LIGHT_ONLY" ON)
84 IF(SALOME_BUILD_TESTS)
90 # Find "big" prerequisites first - they reference themselves many others
91 # -> this can help finding the smaller prerequisites and detect conficts.
92 # In our case KERNEL has already loaded many prereq which are also used in GUI:
98 FIND_PACKAGE(SalomePython REQUIRED)
99 FIND_PACKAGE(SalomeHDF5 REQUIRED)
100 FIND_PACKAGE(SalomeSWIG REQUIRED)
103 FIND_PACKAGE(SalomeDoxygen)
104 FIND_PACKAGE(SalomeGraphviz)
105 FIND_PACKAGE(SalomeSphinx)
106 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
107 SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC)
108 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
112 ## From GUI: part 1 (Qt must be checked before ParaView)
114 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui QtXml QtHelp)
115 # This search for qhelpgenerator is required here
116 # to avoid detecting native one due to bug in ParaViewMacros.cmake
117 FIND_PROGRAM(QT_HELP_GENERATOR
119 PATHS "${QT_BINARY_DIR}"
120 NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
121 DOC "qhelpgenerator used to compile Qt help project files")
122 MARK_AS_ADVANCED(QT_HELP_GENERATOR)
125 ## Specific to ParaViS:
127 FIND_PACKAGE(SalomeParaView REQUIRED)
129 # GUI itself has to be loaded AFTER ParaView: the ParaView config doesn't mix
130 # well with the VTK one (and GUI loads VTK):
131 FIND_PACKAGE(SalomeGUI REQUIRED)
132 SALOME_GUI_WITH_CORBA() # check whether GUI builded with CORBA
133 SALOME_GUI_MODE(SALOME_USE_SALOMEOBJECT SALOME_USE_PVVIEWER)
134 ADD_DEFINITIONS(${GUI_DEFINITIONS})
135 INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS})
140 FIND_PACKAGE(SalomeCAS REQUIRED) # [ABN] I wish I could avoid that ...
145 IF(SALOME_PARAVIS_BUILD_PLUGINS)
146 SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR} CACHE PATH "Path to the Salome MED module")
147 IF(EXISTS ${MED_ROOT_DIR})
148 LIST(APPEND CMAKE_MODULE_PATH "${MED_ROOT_DIR}/adm_local/cmake_files")
149 FIND_PACKAGE(SalomeMED REQUIRED)
151 MESSAGE(FATAL_ERROR "We absolutely need the Salome MED module to build plugins, please define MED_ROOT_DIR")
153 IF(SALOME_MED_STANDALONE OR SALOME_MED_MICROMED)
154 MESSAGE(FATAL_ERROR "We absolutely need a Salome MED with KERNEL and with MED file dependancy,
155 please set SALOME_MED_STANDALONE=OFF and SALOME_MED_MICROMED=OFF in MED module
156 or SALOME_PARAVIS_BUILD_PLUGINS=OFF in PARAVIS module")
158 FIND_PACKAGE(SalomeMEDFile)
159 SALOME_LOG_OPTIONAL_PACKAGE(MEDFile SALOME_PARAVIS_BUILD_PLUGINS)
166 IF(SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_GEOM_SOURCE)
167 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
168 IF(EXISTS ${GEOM_ROOT_DIR})
169 LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
170 FIND_PACKAGE(SalomeGEOM REQUIRED COMPONENTS GEOMClient SalomeIDLGEOM OCC2VTK)
172 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM to import GEOM objects to PARAVIS, please define GEOM_ROOT_DIR
173 or set SALOME_PARAVIS_USE_GEOM_SOURCE=OFF")
175 ELSEIF(NOT SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_GEOM_SOURCE)
176 MESSAGE(FATAL_ERROR "We absolutely need to build PARAVIS plugins to use the import of GEOM objects to PARAVIS,
177 please set SALOME_PARAVIS_BUILD_PLUGINS=ON
178 or SALOME_PARAVIS_USE_GEOM_SOURCE=OFF")
184 IF(SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_SMESH_SOURCE)
185 IF(NOT SALOME_PARAVIS_USE_GEOM_SOURCE)
186 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
187 IF(EXISTS ${GEOM_ROOT_DIR})
188 LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files")
189 FIND_PACKAGE(SalomeGEOM REQUIRED COMPONENTS SalomeIDLGEOM )
191 MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM to import MESH objects to PARAVIS, please define GEOM_ROOT_DIR
192 or set SALOME_PARAVIS_USE_SMESH_SOURCE=OFF")
195 SET(SMESH_ROOT_DIR $ENV{SMESH_ROOT_DIR} CACHE PATH "Path to the Salome SMESH")
196 IF(EXISTS ${SMESH_ROOT_DIR})
197 LIST(APPEND CMAKE_MODULE_PATH "${SMESH_ROOT_DIR}/adm_local/cmake_files")
198 FIND_PACKAGE(SalomeSMESH REQUIRED)
200 MESSAGE(FATAL_ERROR "We absolutely need a Salome MESH to import MESH objects to PARAVIS, please define SMESH_ROOT_DIR
201 or set SALOME_PARAVIS_USE_SMESH_SOURCE=OFF")
203 ELSEIF(NOT SALOME_PARAVIS_BUILD_PLUGINS AND SALOME_PARAVIS_USE_SMESH_SOURCE)
204 MESSAGE(FATAL_ERROR "We absolutely need to build PARAVIS plugins to use the import of MESH objects to PARAVIS,
205 please set SALOME_PARAVIS_BUILD_PLUGINS=ON
206 or SALOME_PARAVIS_USE_SMESH_SOURCE=OFF")
209 ## Detection summary:
210 SALOME_PACKAGE_REPORT_AND_CHECK()
213 # (default values taken from KERNEL)
215 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
216 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
217 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
218 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
219 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
220 "Install path: SALOME scripts")
221 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
222 "Install path: SALOME script data")
223 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
224 "Install path: SALOME Python scripts")
225 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
226 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
227 "Install path: SALOME Python shared modules")
228 SET(SALOME_INSTALL_CMAKE "${SALOME_INSTALL_CMAKE}" CACHE PATH "Install path: SALOME CMake files")
229 SET(SALOME_INSTALL_CMAKE_LOCAL "${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH
230 "Install path: local SALOME CMake files")
231 SET(SALOME_INSTALL_AMCONFIG_LOCAL "${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH
232 "Install path: local SALOME config files (obsolete, to be removed)")
234 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
235 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
237 # Specific to PARAVIS:
238 SET(SALOME_PARAVIS_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/paravis" CACHE PATH "Install path: SALOME PARAVIS specific data")
240 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
241 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
242 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
243 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED)
244 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC SALOME_PARAVIS_INSTALL_RES_DATA)
246 # Accumulate environment variables for PARAVIS module
247 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
248 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
249 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
250 SALOME_ACCUMULATE_ENVIRONMENT(PV_PLUGIN_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/lib/paraview)
254 ADD_SUBDIRECTORY(src)
255 ADD_SUBDIRECTORY(adm_local)
256 ADD_SUBDIRECTORY(resources)
259 ADD_SUBDIRECTORY(doc)
261 IF(SALOME_BUILD_TESTS AND NOT SALOME_LIGHT_ONLY)
262 ADD_SUBDIRECTORY(test)
264 ADD_SUBDIRECTORY(bin)
265 ADD_SUBDIRECTORY(examples)
267 # Header configuration
268 # ====================
269 SALOME_XVERSION(${PROJECT_NAME})
270 SALOME_CONFIGURE_FILE(PARAVIS_version.h.in PARAVIS_version.h INSTALL ${SALOME_INSTALL_HEADERS})
272 # Configuration export
273 # (here only the level 1 prerequisites are exposed)
274 # ====================
275 INCLUDE(CMakePackageConfigHelpers)
277 # List of targets in this project we want to make visible to the rest of the world.
278 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
279 IF(NOT SALOME_LIGHT_ONLY)
280 SET(_${PROJECT_NAME}_exposed_targets PARAVIS)
282 # Add all targets to the build-tree export set
283 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
284 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
287 # Create the configuration files:
288 # - in the build tree:
290 # Ensure the variables are always defined for the configure:
291 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
292 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
293 SET(MED_ROOT_DIR "${MED_ROOT_DIR}")
294 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
295 SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}")
296 SET(SMESH_ROOT_DIR "${SMESH_ROOT_DIR}")
298 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
300 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
301 SALOME_CONFIGURE_PREPARE(MEDFile)
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 GUI_ROOT_DIR MED_ROOT_DIR MEDFILE_ROOT_DIR GEOM_ROOT_DIR SMESH_ROOT_DIR)
309 # - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
310 # Get the relative path of the include directory so
311 # we can register it in the generated configuration files:
312 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
313 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
314 # ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
315 # INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
316 # PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
317 # KERNEL_ROOT_DIR GUI_ROOT_DIR MED_ROOT_DIR MEDFILE_ROOT_DIR)
319 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
320 VERSION ${${PROJECT_NAME_UC}_VERSION}
321 COMPATIBILITY AnyNewerVersion)
323 # Install the CMake configuration files:
325 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
326 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
327 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
329 IF(NOT SALOME_LIGHT_ONLY)
330 # Install the export set for use with the install-tree
331 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
332 FILE ${PROJECT_NAME}Targets.cmake)