1 # Copyright (C) 2012-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)
22 PROJECT(SalomeYACS C CXX)
24 # Ensure a proper linker behavior:
25 CMAKE_POLICY(SET CMP0003 NEW)
27 CMAKE_POLICY(SET CMP0020 OLD) # disable automatic linking to qtmain.lib
32 # Project name, upper case
33 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
35 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 8)
36 SET(${PROJECT_NAME_UC}_MINOR_VERSION 2)
37 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
38 SET(${PROJECT_NAME_UC}_VERSION
39 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
40 SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
44 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
45 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
46 LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
49 MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
52 # Find KERNEL (optional)
54 OPTION(SALOME_YACS_USE_KERNEL "Use SALOME KERNEL" ON)
55 IF( SALOME_YACS_USE_KERNEL )
56 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
57 IF( EXISTS ${KERNEL_ROOT_DIR} )
58 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
59 FIND_PACKAGE(SalomeKERNEL REQUIRED)
60 KERNEL_WITH_CORBA() # check whether KERNEL builded with CORBA
61 ADD_DEFINITIONS(${KERNEL_DEFINITIONS} -DSALOME_KERNEL)
62 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
63 ELSE( EXISTS ${KERNEL_ROOT_DIR} )
64 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_YACS_USE_KERNEL to OFF !")
65 ENDIF( EXISTS ${KERNEL_ROOT_DIR} )
66 SALOME_LOG_OPTIONAL_PACKAGE(SalomeKERNEL SALOME_YACS_USE_KERNEL)
67 ELSE( SALOME_YACS_USE_KERNEL )
68 MESSAGE(STATUS "Option SALOME_YACS_USE_KERNEL is set to OFF, so YACS will be built without CORBA!!!")
69 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm/cmake")
71 ENDIF( SALOME_YACS_USE_KERNEL )
73 # Find SALOME GUI (optional)
75 CMAKE_DEPENDENT_OPTION(SALOME_BUILD_GUI "Build GUI of YACS" ON
76 "SALOME_YACS_USE_KERNEL" OFF)
78 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
79 IF(EXISTS ${GUI_ROOT_DIR})
80 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
81 FIND_PACKAGE(SalomeGUI)
82 SALOME_GUI_WITH_CORBA() # check whether GUI builded with CORBA
83 SALOME_GUI_MODE(SALOME_USE_QXGRAPHVIEWER) # check whether GUI is built with the QxGraphViewer
84 ELSE(EXISTS ${GUI_ROOT_DIR})
85 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
86 ENDIF(EXISTS ${GUI_ROOT_DIR})
87 SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
88 ENDIF(SALOME_BUILD_GUI)
92 INCLUDE(SalomeSetupPlatform) # From SalomeMacros
93 # Always build libraries as shared objects:
94 SET(BUILD_SHARED_LIBS TRUE)
96 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm/cmake")
98 # additional preprocessor / compiler flags
99 ADD_DEFINITIONS(-DCMAKE_BUILD)
101 ADD_DEFINITIONS(-DNOGDI)
106 OPTION(SALOME_BUILD_DOC "Generate SALOME YACS documentation" ON)
107 OPTION(SALOME_BUILD_TESTS "Build SALOME YACS tests" ON)
109 OPTION(SALOME_YACS_USE_SWIG "Enable Python wrapper" ON)
110 OPTION(SALOME_YACS_USE_DSC "Use DSC KERNEL extension" ON)
112 CMAKE_DEPENDENT_OPTION(SALOME_YACS_USE_PYEDITOR "Use built-in py editor" ON
113 "SALOME_USE_PYVIEWER" OFF)
115 IF(SALOME_YACS_USE_PYEDITOR)
116 ADD_DEFINITIONS(-DHAS_PYEDITOR)
117 ENDIF(SALOME_YACS_USE_PYEDITOR)
120 IF(SALOME_YACS_USE_KERNEL AND SALOME_YACS_USE_DSC)
121 IF(EXISTS ${KERNEL_ROOT_DIR}/idl/salome/DSC_Engines.idl)
122 ADD_DEFINITIONS(-DDSC_PORTS)
124 MESSAGE(FATAL_ERROR "We absolutely need a KERNEL DSC extension. Please rebuild KERNEL with DSC support or turn option SALOME_YACS_USE_DSC to OFF !")
130 # Find "big" prerequisites first - they reference themselves many others
131 # -> this can helps to find the smaller prerequisites and detect conflicts.
132 # In our case KERNEL may have already loaded many prerequisites which are also used in YACS:
139 FIND_PACKAGE(SalomePythonInterp REQUIRED)
140 FIND_PACKAGE(SalomePythonLibs REQUIRED)
141 FIND_PACKAGE(SalomeNumPySciPy)
142 FIND_PACKAGE(SalomePThread REQUIRED)
143 ADD_DEFINITIONS(-DYACS_PTHREAD)
144 FIND_PACKAGE(SalomeBoost REQUIRED)
145 FIND_PACKAGE(SalomeOmniORB REQUIRED)
146 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
147 ADD_DEFINITIONS(-DOMNIORB)
148 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
151 IF(SALOME_YACS_USE_SWIG)
152 FIND_PACKAGE(SalomeSWIG)
153 SALOME_LOG_OPTIONAL_PACKAGE(SWIG SALOME_YACS_USE_SWIG)
154 # ADD_DEFINITIONS(-DSWIG)
157 IF(SALOME_BUILD_TESTS)
159 FIND_PACKAGE(SalomeCppUnit)
160 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
164 FIND_PACKAGE(SalomeDoxygen)
165 FIND_PACKAGE(SalomeSphinx)
166 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
167 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
168 ADD_DEFINITIONS(-DDOXYGEN_IS_OK)
171 # Find optional GUI libraries
174 FIND_PACKAGE(SalomeGraphviz REQUIRED)
176 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
177 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
179 FIND_PACKAGE(SalomeQt5 REQUIRED)
181 ENDIF(SALOME_BUILD_GUI)
188 SALOME_PACKAGE_REPORT_AND_CHECK()
192 IF( SALOME_YACS_USE_KERNEL )
193 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
194 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
195 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
196 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
197 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
198 "Install path: SALOME scripts")
199 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
200 "Install path: SALOME script data")
201 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
202 "Install path: SALOME Python scripts")
203 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
204 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
205 "Install path: SALOME Python shared modules")
206 SET(SALOME_INSTALL_CMAKE_LOCAL adm/cmake CACHE PATH
207 "Install path: local SALOME CMake files")
208 SET(SALOME_INSTALL_AMCONFIG_LOCAL adm/unix CACHE PATH
209 "Install path: local SALOME config files (obsolete, to be removed)")
211 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
212 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
214 ELSE(SALOME_YACS_USE_KERNEL)
215 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
216 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
217 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
218 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
219 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
220 "Install path: SALOME scripts")
221 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
222 "Install path: SALOME script data")
223 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
224 "Install path: SALOME Python scripts")
225 SET(SALOME_INSTALL_CMAKE_LOCAL adm/cmake CACHE PATH
226 "Install path: local SALOME CMake files")
227 SET(SALOME_INSTALL_AMCONFIG_LOCAL adm/unix CACHE PATH
228 "Install path: local SALOME config files (obsolete, to be removed)")
230 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
231 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
232 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH
233 "Install path: SALOME Python shared modules")
235 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
237 SET(SALOME_INSTALL_DOC share/doc/salome CACHE PATH "Install path: SALOME documentation")
238 ENDIF(SALOME_YACS_USE_KERNEL)
241 SET(SALOME_YACS_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/yacs" CACHE PATH
242 "Install path: SALOME YACS specific data")
243 SET(SALOME_YACS_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/yacs" CACHE PATH
244 "Install path: SALOME YACS scripts")
245 SET(SALOME_YACS_INSTALL_SAMPLES share/salome/yacssamples CACHE PATH
246 "Install path: SALOME YACS samples")
247 SET(SALOME_YACS_INSTALL_SUPERV_SAMPLES share/salome/yacssupervsamples CACHE PATH
248 "Install path: SALOME YACS SUPERV samples")
249 SET(SALOME_INSTALL_HXX2SALOME bin/HXX2SALOME_Test CACHE PATH
250 "Install path: SALOME HXX2SALOME Test files")
251 SET(SALOME_YACS_INSTALL_TEST ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test CACHE PATH
252 "Install path: SALOME YACS Test files")
254 SALOME_YACS_INSTALL_RES_DATA
255 SALOME_YACS_INSTALL_RES_SCRIPTS
256 SALOME_YACS_INSTALL_SAMPLES
257 SALOME_YACS_INSTALL_SUPERV_SAMPLES
258 SALOME_INSTALL_HXX2SALOME
259 SALOME_YACS_INSTALL_TEST
262 # Accumulate environment variables for YACS module
263 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
264 ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON})
265 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
269 IF(SALOME_YACS_USE_KERNEL)
270 ADD_SUBDIRECTORY(idl)
273 ADD_SUBDIRECTORY(adm)
274 ADD_SUBDIRECTORY(src)
276 ADD_SUBDIRECTORY(doc)
278 ADD_SUBDIRECTORY(Demo)
280 # Header configuration
281 # ====================
282 SALOME_XVERSION(${PROJECT_NAME})
283 SALOME_CONFIGURE_FILE(YACS_version.h.in YACS_version.h INSTALL ${SALOME_INSTALL_HEADERS})
285 # Configuration export
286 # (here only the level 1 prerequisites are exposed)
287 # ====================
288 INCLUDE(CMakePackageConfigHelpers)
290 # List of targets in this project we want to make visible to the rest of the world.
291 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
292 SET(_${PROJECT_NAME}_exposed_targets
293 YACSBases YACSlibEngine
296 IF(SALOME_YACS_USE_KERNEL)
297 LIST(APPEND _${PROJECT_NAME}_exposed_targets
298 SalomeIDLYACS YACSRuntimeSALOME YACSloader YACSevalYFX
300 ENDIF(SALOME_YACS_USE_KERNEL)
302 IF(SALOME_BUILD_TESTS)
303 LIST(APPEND _${PROJECT_NAME}_exposed_targets
304 YACSDLTest PluginSimplex PluginOptEvTest1
306 IF(SALOME_YACS_USE_KERNEL)
307 LIST(APPEND _${PROJECT_NAME}_exposed_targets
308 TestComponentLocal yacsloader_echo
310 ENDIF(SALOME_YACS_USE_KERNEL)
311 ENDIF(SALOME_BUILD_TESTS)
314 LIST(APPEND _${PROJECT_NAME}_exposed_targets
315 HMI ydfxwidgets GenericGui YACS SalomeWrap
317 ENDIF(SALOME_BUILD_GUI)
319 # Add all targets to the build-tree export set
320 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
321 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
323 # Create the configuration files:
324 # - in the build tree:
326 # Ensure the variables are always defined for the configure:
327 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
328 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
329 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
330 SET(QT_ROOT_DIR "${QT4_ROOT_DIR}")
332 SET(QT_ROOT_DIR "${QT5_ROOT_DIR}")
335 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
337 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
338 IF(NOT SALOME_GUI_BUILD_WITH_QT5)
339 SALOME_CONFIGURE_PREPARE(Qt4)
341 SALOME_CONFIGURE_PREPARE(Qt5)
344 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
345 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
346 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
347 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
348 KERNEL_ROOT_DIR GUI_ROOT_DIR QT_ROOT_DIR)
350 # - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
351 # Get the relative path of the include directory so
352 # we can register it in the generated configuration files:
353 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
354 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
355 # ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
356 # INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
357 # PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
358 # KERNEL_ROOT_DIR GUI_ROOT_DIR QT_ROOT_DIR)
360 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
361 VERSION ${${PROJECT_NAME_UC}_VERSION}
362 COMPATIBILITY AnyNewerVersion)
364 # Install the CMake configuration files:
366 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
367 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
368 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
370 # Install the export set for use with the install-tree
371 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
372 FILE ${PROJECT_NAME}Targets.cmake)