]> SALOME platform Git repositories - modules/kernel.git/blob - CMakeLists.txt
Salome HOME
12fe6d711e1d35a244a953c8eae462f62cae8583
[modules/kernel.git] / CMakeLists.txt
1 # Copyright (C) 2012-2024  CEA, EDF, OPEN CASCADE
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
20 INCLUDE(CMakeDependentOption)
21
22 # Project name
23 # ============
24 # original
25 PROJECT(SalomeKERNEL C CXX)
26 # upper case
27 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
28
29 # Common CMake macros
30 # ===================
31 SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
32 IF(EXISTS ${CONFIGURATION_ROOT_DIR})
33   LIST(APPEND CMAKE_MODULE_PATH "${CONFIGURATION_ROOT_DIR}/cmake")
34   INCLUDE(SalomeMacros NO_POLICY_SCOPE)
35 ELSE()
36   MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
37 ENDIF()
38
39 # Versioning
40 # ===========
41 SALOME_SETUP_VERSION(9.12.0)
42 MESSAGE(STATUS "Building ${PROJECT_NAME_UC} ${${PROJECT_NAME_UC}_VERSION} from \"${${PROJECT_NAME_UC}_GIT_SHA1}\"")
43
44 # Platform setup
45 # ==============
46 INCLUDE(SalomeSetupPlatform)
47 # Always build libraries as shared objects:
48 SET(BUILD_SHARED_LIBS TRUE)
49 # Temporary step instead of Find Calcium.cmake
50 SET(CALCIUM_IDL_INT_F77 long)
51 SET(CALCIUM_CORBA_INT_F77 CORBA::Long)
52 SET(LONG_OR_INT int)
53
54 # User options
55 # ============
56 OPTION(SALOME_BUILD_DOC "Generate SALOME KERNEL documentation" ON)
57 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
58
59 # Advanced:
60 OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF)
61 OPTION(SALOME_USE_LIBBATCH "Use LibBatch in KERNEL" OFF)
62 OPTION(SALOME_USE_64BIT_IDS "Size of IDs to refer cells and nodes. 32 bits when OFF (default), 64 bits when ON." OFF)
63 CMAKE_DEPENDENT_OPTION(SALOME_PACO_PARALLEL "Build with PACO (implies SALOME_USE_MPI)" OFF
64                        "NOT SALOME_LIGHT_ONLY" OFF)
65 CMAKE_DEPENDENT_OPTION(SALOME_USE_MPI "Use MPI containers" OFF
66                        "NOT SALOME_PACO_PARALLEL" ON)
67 CMAKE_DEPENDENT_OPTION(SALOME_USE_MPI "Use MPI containers" ${SALOME_USE_MPI}
68                        "NOT SALOME_LIGHT_ONLY" OFF)
69 MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_PACO_PARALLEL)
70
71 # Required prerequisites
72 #   Find "big" prerequisites first - they reference themselves many others
73 #   -> this can help finding the smaller prerequisites and detect conflicts.
74 # =======================
75
76 # Exception: LibBatch is optional but is loaded first, as it can
77 # give Python, Pthread and SWIG:
78 IF(SALOME_USE_LIBBATCH)
79   FIND_PACKAGE(SalomeLibBatch)
80   SALOME_LOG_OPTIONAL_PACKAGE(LibBatch SALOME_USE_LIBBATCH)
81 ENDIF()
82
83 FIND_PACKAGE(SalomePythonInterp REQUIRED)
84 FIND_PACKAGE(SalomePythonLibs REQUIRED)
85 FIND_PACKAGE(SalomeNumPySciPy)
86 FIND_PACKAGE(SalomePsutil REQUIRED)
87 FIND_PACKAGE(SalomePThread REQUIRED)
88 FIND_PACKAGE(SalomeSWIG REQUIRED)
89 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
90 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
91 FIND_PACKAGE(SalomeBoost REQUIRED)
92
93 # Optional prerequisites
94 # ======================
95
96 IF(NOT SALOME_LIGHT_ONLY)
97   FIND_PACKAGE(SalomeOmniORB REQUIRED)
98   FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
99 ENDIF()
100 IF(SALOME_USE_MPI)
101   FIND_PACKAGE(SalomeMPI REQUIRED)
102   IF(HDF5_IS_PARALLEL)
103     SALOME_ADD_MPI_TO_HDF5()
104   ENDIF()
105 ENDIF()
106 IF(SALOME_PACO_PARALLEL)
107   FIND_PACKAGE(SalomePaco REQUIRED)
108 ENDIF()
109 IF(SALOME_BUILD_TESTS)
110   ENABLE_TESTING()
111   FIND_PACKAGE(SalomeCppUnit)
112   SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)
113 ENDIF()
114 IF(SALOME_BUILD_DOC)
115   FIND_PACKAGE(SalomeDoxygen)
116   FIND_PACKAGE(SalomeGraphviz)
117   FIND_PACKAGE(SalomeSphinx)
118   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
119   SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC)
120   SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
121 ENDIF()
122
123 # Detection summary:
124 SALOME_PACKAGE_REPORT_AND_CHECK()
125
126 # Directories
127 #
128 # Directories have to be given after prerequisites (to be able to use
129 # Python version string for example).
130 # ===========
131 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
132 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
133 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
134 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
135 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
136    "Install path: SALOME scripts")
137 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
138    "Install path: SALOME script data")
139 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
140    "Install path: SALOME Python scripts")
141 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
142    "Install path: SALOME application skeleton - scripts")
143 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
144    "Install path: SALOME application skeleton - Python")
145 SET(SALOME_INSTALL_CMAKE salome_adm/cmake_files CACHE PATH "Install path: SALOME CMake files")
146 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH
147    "Install path: local SALOME CMake files")
148 SET(SALOME_INSTALL_AMCONFIG salome_adm/unix CACHE PATH
149    "Install path: SALOME config files (obsolete, to be removed)")
150 SET(SALOME_INSTALL_AMCONFIG_LOCAL adm_local/unix CACHE PATH
151    "Install path: local SALOME config files (obsolete, to be removed)")
152
153 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
154 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
155 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH
156    "Install path: SALOME Python shared modules")
157
158 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
159
160 SET(SALOME_INSTALL_DOC share/doc/salome CACHE PATH "Install path: SALOME documentation")
161
162 # Kernel specific:
163 SET(SALOME_KERNEL_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/kernel" CACHE PATH "Install path: SALOME KERNEL specific data")
164 SET(SALOME_KERNEL_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/kernel" CACHE PATH "Install path: SALOME KERNEL specific scripts")
165
166 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
167 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
168 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
169 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_KERNEL_INSTALL_RES_DATA SALOME_KERNEL_INSTALL_RES_SCRIPTS SALOME_INSTALL_DOC)
170 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG SALOME_INSTALL_AMCONFIG_LOCAL)
171
172 # Accumulate environment variables for KERNEL module
173 SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_BINS}
174                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}
175                                                  ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON_SHARED})
176 SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS})
177
178 # For salome test
179 SET(KERNEL_TEST_DIR ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test)
180 SET(KERNEL_TEST_LIB ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/lib)
181 CONFIGURE_FILE(CTestTestfileInstall.cmake.in CTestTestfileInstall.cmake @ONLY)
182 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileInstall.cmake
183         DESTINATION ${KERNEL_TEST_DIR}
184         RENAME CTestTestfile.cmake)
185
186
187 IF(SALOME_LIGHT_ONLY)
188   ADD_DEFINITIONS(-DSALOME_LIGHT)
189 ENDIF()
190
191 # Sources
192 # ========
193 IF(NOT SALOME_LIGHT_ONLY)
194   ADD_SUBDIRECTORY(idl)
195 ENDIF()
196 ADD_SUBDIRECTORY(src)
197 ADD_SUBDIRECTORY(resources)
198 ADD_SUBDIRECTORY(bin)
199 ADD_SUBDIRECTORY(salome_adm)
200 IF(SALOME_BUILD_DOC)
201   ADD_SUBDIRECTORY(doc)
202 ENDIF()
203
204 # Header configuration
205 # ====================
206 SALOME_CONFIGURE_FILE(KERNEL_version.h.in KERNEL_version.h INSTALL ${SALOME_INSTALL_HEADERS})
207
208 # Configuration export
209 # ====================
210 INCLUDE(CMakePackageConfigHelpers)
211
212 # List of targets in this project we want to make visible to the rest of the world.
213 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
214
215 SET(_${PROJECT_NAME}_exposed_targets
216   SALOMELog SALOMEBasics ArgvKeeper SALOMELocalTrace SalomeHDFPersist OpUtil)
217
218 # CORBA specific targets:
219 IF(NOT SALOME_LIGHT_ONLY)
220   LIST(APPEND _${PROJECT_NAME}_exposed_targets
221     DF SalomeLoggerServer with_loggerTraceCollector SalomeNS SalomeGenericObj
222     Registry SalomeCatalog ResourcesManager SalomeResourcesManager
223     SalomeNotification SalomeContainer SalomeSDS Launcher SalomeLauncher
224     SalomeLifeCycleCORBA SalomeDSClient TOOLSDS SalomeKernelHelpers SalomeORB
225     SalomeDSImpl SalomeDS SalomeCommunication SalomeDSCContainer)
226   # Temporary solution for package src\DSC on windows
227   IF(NOT WIN32)
228     LIST(APPEND _${PROJECT_NAME}_exposed_targets
229       CalciumC SalomeCalcium SalomeDatastream SalomePalm SalomeDSCSupervBasic
230       SalomeDSCSuperv)
231     IF(SALOME_PACO_PARALLEL)
232       LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomeParallelDSCContainer)
233     ENDIF()
234   ENDIF()
235 ENDIF()
236
237 # MPI specific targets:
238 IF(SALOME_USE_MPI)
239   LIST(APPEND _${PROJECT_NAME}_exposed_targets
240     SalomeMPIContainer SalomeTestMPIComponentEngine)
241 ENDIF()
242
243 # Test targets:
244 IF(SALOME_BUILD_TESTS)
245   LIST(APPEND _${PROJECT_NAME}_exposed_targets SALOMELocalTraceTest UnitTests)
246   IF(NOT SALOME_LIGHT_ONLY)
247     LIST(APPEND _${PROJECT_NAME}_exposed_targets
248       SALOMETraceCollectorTest UtilsTest NamingServiceTest SalomeTestComponentEngine
249       LifeCycleCORBATest SalomeKernelHelpersTest SALOMEDSImplTest SALOMEDSTest)
250   ENDIF()
251 ENDIF()
252
253 # PACO specific targets:
254 IF(SALOME_PACO_PARALLEL)
255   LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomeParallelContainer)
256 ENDIF()
257
258 IF(NOT SALOME_LIGHT_ONLY)
259   LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomeIDLKernel)
260   IF(SALOME_PACO_PARALLEL)
261     LIST(APPEND _${PROJECT_NAME}_exposed_targets SalomeParallelIDLKernel)
262   ENDIF()
263 ENDIF()
264
265 # Add all targets to the build-tree export set
266 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
267   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
268
269 # Create the configuration files:
270 #   - in the build tree:
271
272 #      Ensure the variables are always defined for the configure:
273 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
274 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
275 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
276 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
277 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
278 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
279 SET(OMNIORBPY_ROOT_DIR "${OMNIORBPY_ROOT_DIR}")
280 SET(LIBBATCH_ROOT_DIR "${LIBBATCH_ROOT_DIR}")
281
282 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
283
284 # Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
285 SALOME_CONFIGURE_PREPARE(CppUnit Graphviz Doxygen Sphinx MPI omniORB LibBatch
286                          PThread Boost HDF5 libXml2 Python)
287
288 CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
289     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
290     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
291     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
292        CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
293        SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
294        PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
295        PYTHON_ROOT_DIR SWIG_ROOT_DIR)
296
297 #   - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
298 #       Get the relative path of the include directory so
299 #       we can register it in the generated configuration files:
300 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
301 #CONFIGURE_PACKAGE_CONFIG_FILE(salome_adm/cmake_files/${PROJECT_NAME}Config.cmake.in
302 #    ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
303 #    INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
304 #    PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
305 #       CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
306 #       SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
307 #       PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
308 #       PYTHON_ROOT_DIR SWIG_ROOT_DIR)
309
310 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
311     VERSION ${${PROJECT_NAME_UC}_VERSION}
312     COMPATIBILITY AnyNewerVersion)
313
314 # Install the CMake configuration files:
315 INSTALL(FILES
316   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
317   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
318   DESTINATION "${SALOME_INSTALL_CMAKE}")
319
320 # Install the export set for use with the install-tree
321 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}"
322         FILE ${PROJECT_NAME}Targets.cmake)