1 # Copyright (C) 2012-2020 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)
26 # Project name, upper case
27 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
29 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 9)
30 SET(${PROJECT_NAME_UC}_MINOR_VERSION 5)
31 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
32 SET(${PROJECT_NAME_UC}_VERSION
33 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
34 SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
38 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
39 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
40 LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
41 INCLUDE(SalomeMacros NO_POLICY_SCOPE)
43 MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
46 # Find KERNEL (optional)
48 OPTION(SALOME_YACS_USE_KERNEL "Use SALOME KERNEL" ON)
49 IF( SALOME_YACS_USE_KERNEL )
50 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
51 IF( EXISTS ${KERNEL_ROOT_DIR} )
52 FIND_PACKAGE(SalomeKERNEL REQUIRED)
53 KERNEL_WITH_CORBA() # check whether KERNEL builded with CORBA
54 ADD_DEFINITIONS(${KERNEL_DEFINITIONS} -DSALOME_KERNEL)
55 INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
56 ELSE( EXISTS ${KERNEL_ROOT_DIR} )
57 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_YACS_USE_KERNEL to OFF !")
58 ENDIF( EXISTS ${KERNEL_ROOT_DIR} )
59 SALOME_LOG_OPTIONAL_PACKAGE(SalomeKERNEL SALOME_YACS_USE_KERNEL)
60 ELSE( SALOME_YACS_USE_KERNEL )
61 MESSAGE(STATUS "Option SALOME_YACS_USE_KERNEL is set to OFF, so YACS will be built without CORBA!!!")
62 ENDIF( SALOME_YACS_USE_KERNEL )
64 # Find SALOME GUI (optional)
66 CMAKE_DEPENDENT_OPTION(SALOME_BUILD_GUI "Build GUI of YACS" ON
67 "SALOME_YACS_USE_KERNEL" OFF)
69 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
70 IF(EXISTS ${GUI_ROOT_DIR})
71 FIND_PACKAGE(SalomeGUI)
72 SALOME_GUI_WITH_CORBA() # check whether GUI builded with CORBA
73 SALOME_GUI_MODE(SALOME_USE_QXGRAPHVIEWER) # check whether GUI is built with the QxGraphViewer
74 ELSE(EXISTS ${GUI_ROOT_DIR})
75 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
76 ENDIF(EXISTS ${GUI_ROOT_DIR})
77 SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
78 ENDIF(SALOME_BUILD_GUI)
82 INCLUDE(SalomeSetupPlatform) # From CONFIGURATION
83 # Always build libraries as shared objects:
84 SET(BUILD_SHARED_LIBS TRUE)
86 # additional preprocessor / compiler flags
87 ADD_DEFINITIONS(-DCMAKE_BUILD)
89 ADD_DEFINITIONS(-DNOGDI)
94 OPTION(SALOME_BUILD_DOC "Generate SALOME YACS documentation" ON)
95 OPTION(SALOME_BUILD_TESTS "Build SALOME YACS tests" ON)
97 OPTION(SALOME_YACS_USE_SWIG "Enable Python wrapper" ON)
98 OPTION(SALOME_YACS_USE_DSC "Use DSC KERNEL extension" ON)
100 CMAKE_DEPENDENT_OPTION(SALOME_YACS_USE_PYEDITOR "Use built-in py editor" ON
101 "SALOME_USE_PYVIEWER" OFF)
103 IF(SALOME_YACS_USE_PYEDITOR)
104 ADD_DEFINITIONS(-DHAS_PYEDITOR)
105 ENDIF(SALOME_YACS_USE_PYEDITOR)
108 IF(SALOME_YACS_USE_KERNEL AND SALOME_YACS_USE_DSC)
109 IF(EXISTS ${KERNEL_ROOT_DIR}/idl/salome/DSC_Engines.idl)
110 ADD_DEFINITIONS(-DDSC_PORTS)
112 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 !")
118 # Find "big" prerequisites first - they reference themselves many others
119 # -> this can helps to find the smaller prerequisites and detect conflicts.
120 # In our case KERNEL may have already loaded many prerequisites which are also used in YACS:
127 FIND_PACKAGE(SalomePythonInterp REQUIRED)
128 FIND_PACKAGE(SalomePythonLibs REQUIRED)
129 FIND_PACKAGE(SalomeNumPySciPy)
130 FIND_PACKAGE(SalomePThread REQUIRED)
131 ADD_DEFINITIONS(-DYACS_PTHREAD)
132 FIND_PACKAGE(SalomeBoost REQUIRED)
133 FIND_PACKAGE(SalomeOmniORB REQUIRED)
134 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
135 ADD_DEFINITIONS(-DOMNIORB)
136 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
139 IF(SALOME_YACS_USE_SWIG)
140 FIND_PACKAGE(SalomeSWIG)
141 SALOME_LOG_OPTIONAL_PACKAGE(SWIG SALOME_YACS_USE_SWIG)
142 # ADD_DEFINITIONS(-DSWIG)
145 IF(SALOME_BUILD_TESTS)
147 FIND_PACKAGE(SalomeCppUnit)
148 SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
152 FIND_PACKAGE(SalomeDoxygen)
153 FIND_PACKAGE(SalomeSphinx)
154 SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
155 SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
156 ADD_DEFINITIONS(-DDOXYGEN_IS_OK)
159 # Find optional GUI libraries
162 FIND_PACKAGE(SalomeGraphviz REQUIRED)
164 FIND_PACKAGE(SalomeQt5 REQUIRED)
165 ENDIF(SALOME_BUILD_GUI)
172 SALOME_PACKAGE_REPORT_AND_CHECK()
176 IF( SALOME_YACS_USE_KERNEL )
177 SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
178 SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
179 SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
180 SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
181 SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH
182 "Install path: SALOME scripts")
183 SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH
184 "Install path: SALOME script data")
185 SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH
186 "Install path: SALOME Python scripts")
187 SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
188 SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH
189 "Install path: SALOME Python shared modules")
190 SET(SALOME_INSTALL_CMAKE_LOCAL adm/cmake CACHE PATH
191 "Install path: local SALOME CMake files")
192 SET(SALOME_INSTALL_AMCONFIG_LOCAL adm/unix CACHE PATH
193 "Install path: local SALOME config files (obsolete, to be removed)")
195 SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
196 SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
198 ELSE(SALOME_YACS_USE_KERNEL)
199 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
200 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
201 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
202 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
203 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
204 "Install path: SALOME scripts")
205 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
206 "Install path: SALOME script data")
207 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
208 "Install path: SALOME Python scripts")
209 SET(SALOME_INSTALL_CMAKE_LOCAL adm/cmake CACHE PATH
210 "Install path: local SALOME CMake files")
211 SET(SALOME_INSTALL_AMCONFIG_LOCAL adm/unix CACHE PATH
212 "Install path: local SALOME config files (obsolete, to be removed)")
214 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
215 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
216 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH
217 "Install path: SALOME Python shared modules")
219 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
221 SET(SALOME_INSTALL_DOC share/doc/salome CACHE PATH "Install path: SALOME documentation")
222 ENDIF(SALOME_YACS_USE_KERNEL)
225 SET(SALOME_YACS_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/yacs" CACHE PATH
226 "Install path: SALOME YACS specific data")
227 SET(SALOME_YACS_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/yacs" CACHE PATH
228 "Install path: SALOME YACS scripts")
229 SET(SALOME_YACS_INSTALL_SAMPLES share/salome/yacssamples CACHE PATH
230 "Install path: SALOME YACS samples")
231 SET(SALOME_YACS_INSTALL_SUPERV_SAMPLES share/salome/yacssupervsamples CACHE PATH
232 "Install path: SALOME YACS SUPERV samples")
233 SET(SALOME_INSTALL_HXX2SALOME bin/HXX2SALOME_Test CACHE PATH
234 "Install path: SALOME HXX2SALOME Test files")
235 SET(SALOME_YACS_INSTALL_TEST ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test CACHE PATH
236 "Install path: SALOME YACS Test files")
238 SALOME_YACS_INSTALL_RES_DATA
239 SALOME_YACS_INSTALL_RES_SCRIPTS
240 SALOME_YACS_INSTALL_SAMPLES
241 SALOME_YACS_INSTALL_SUPERV_SAMPLES
242 SALOME_INSTALL_HXX2SALOME
243 SALOME_YACS_INSTALL_TEST
246 # Accumulate environment variables for YACS 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})
253 IF(SALOME_YACS_USE_KERNEL)
254 ADD_SUBDIRECTORY(idl)
257 ADD_SUBDIRECTORY(adm)
258 ADD_SUBDIRECTORY(src)
260 ADD_SUBDIRECTORY(doc)
262 ADD_SUBDIRECTORY(Demo)
264 # Header configuration
265 # ====================
266 SALOME_XVERSION(${PROJECT_NAME})
267 SALOME_CONFIGURE_FILE(YACS_version.h.in YACS_version.h INSTALL ${SALOME_INSTALL_HEADERS})
269 # Configuration export
270 # (here only the level 1 prerequisites are exposed)
271 # ====================
272 INCLUDE(CMakePackageConfigHelpers)
274 # List of targets in this project we want to make visible to the rest of the world.
275 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
276 SET(_${PROJECT_NAME}_exposed_targets
277 YACSBases YACSlibEngine
280 IF(SALOME_YACS_USE_KERNEL)
281 LIST(APPEND _${PROJECT_NAME}_exposed_targets
282 SalomeIDLYACS YACSRuntimeSALOME YACSloader YACSevalYFX
284 ENDIF(SALOME_YACS_USE_KERNEL)
286 IF(SALOME_BUILD_TESTS)
287 LIST(APPEND _${PROJECT_NAME}_exposed_targets
288 YACSDLTest PluginSimplex PluginOptEvTest1
290 IF(SALOME_YACS_USE_KERNEL)
291 LIST(APPEND _${PROJECT_NAME}_exposed_targets
292 TestComponentLocal yacsloader_echo
294 ENDIF(SALOME_YACS_USE_KERNEL)
295 ENDIF(SALOME_BUILD_TESTS)
298 LIST(APPEND _${PROJECT_NAME}_exposed_targets
299 HMI ydfxwidgets GenericGui YACS SalomeWrap
301 ENDIF(SALOME_BUILD_GUI)
303 # Add all targets to the build-tree export set
304 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
305 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
307 # Create the configuration files:
308 # - in the build tree:
310 # Ensure the variables are always defined for the configure:
311 SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
312 SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
313 SET(QT_ROOT_DIR "${QT5_ROOT_DIR}")
315 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
317 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
318 SALOME_CONFIGURE_PREPARE(Qt5)
320 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
321 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
322 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
323 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
324 KERNEL_ROOT_DIR GUI_ROOT_DIR QT_ROOT_DIR)
326 # - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
327 # Get the relative path of the include directory so
328 # we can register it in the generated configuration files:
329 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
330 #CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
331 # ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
332 # INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
333 # PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
334 # KERNEL_ROOT_DIR GUI_ROOT_DIR QT_ROOT_DIR)
336 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
337 VERSION ${${PROJECT_NAME_UC}_VERSION}
338 COMPATIBILITY AnyNewerVersion)
340 # Install the CMake configuration files:
342 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
343 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
344 DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
346 # Install the export set for use with the install-tree
347 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
348 FILE ${PROJECT_NAME}Targets.cmake)