1 # Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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(SalomeKERNEL C CXX)
24 # Ensure a proper linker behavior:
25 CMAKE_POLICY(SET CMP0003 NEW)
29 # Project name, upper case
30 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
32 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
33 SET(${PROJECT_NAME_UC}_MINOR_VERSION 2)
34 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
35 SET(${PROJECT_NAME_UC}_VERSION
36 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
38 SET(VERSION ${${PROJECT_NAME_UC}_VERSION})
41 # Our own set of macros:
42 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/salome_adm/cmake_files")
47 INCLUDE(SalomeSetupPlatform)
48 # Always build libraries as shared objects:
49 SET(BUILD_SHARED_LIBS TRUE)
50 # Temporary step instead of Find Calcium.cmake
51 SET(CALCIUM_IDL_INT_F77 long)
52 SET(CALCIUM_CORBA_INT_F77 CORBA::Long)
55 ADD_DEFINITIONS(-DSIZEOF_FORTRAN_INTEGER=4 -DSIZEOF_INT=4)
56 ## OmniORB already defines SIZEOF_LONG
57 # ADD_DEFINITIONS(-DSIZEOF_LONG=${SIZE_OF_LONG})
61 CMAKE_DEPENDENT_OPTION(SALOME_USE_MPI "Use MPI containers" OFF
62 "NOT SALOME_PACO_PARALLEL" ON)
63 OPTION(SALOME_BUILD_DOC "Generate SALOME KERNEL documentation" ON)
64 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
67 OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF)
68 OPTION(SALOME_USE_LIBBATCH "Use LibBatch in KERNEL" ON)
69 OPTION(SALOME_PACO_PARALLEL "Build with PACO (implies SALOME_USE_MPI)" OFF)
70 OPTION(SALOME_LAUNCHER_ONLY "Build only the Launcher part" OFF)
71 MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_PACO_PARALLEL SALOME_LAUNCHER_ONLY)
73 # Required prerequisites
74 # Find "big" prerequisites first - they reference themselves many others
75 # -> this can help finding the smaller prerequisites and detect conficts.
76 # =======================
78 # Exception: LibBatch is optional but is loaded first, as it can
79 # give Python, Pthread and SWIG:
80 IF(SALOME_USE_LIBBATCH)
81 FIND_PACKAGE(SalomeLibBatch REQUIRED)
84 FIND_PACKAGE(SalomePython REQUIRED)
85 FIND_PACKAGE(SalomePThread REQUIRED)
86 FIND_PACKAGE(SalomeSWIG REQUIRED)
87 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
88 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
89 FIND_PACKAGE(SalomeBoost REQUIRED)
91 # Optional prerequisites
92 # ======================
94 IF(NOT SALOME_LIGHT_ONLY)
95 FIND_PACKAGE(SalomeOmniORB REQUIRED)
96 FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
99 FIND_PACKAGE(SalomeMPI REQUIRED)
101 SALOME_ADD_MPI_TO_HDF5()
104 IF(SALOME_PACO_PARALLEL)
105 FIND_PACKAGE(SalomePaco REQUIRED)
107 IF(SALOME_BUILD_TESTS)
109 FIND_PACKAGE(SalomeCppUnit REQUIRED)
112 FIND_PACKAGE(SalomeDoxygen REQUIRED)
113 FIND_PACKAGE(SalomeGraphviz) # Remains optional even here.
114 FIND_PACKAGE(SalomeSphinx REQUIRED)
119 # Directories have to be given after prerequisites (to be able to use
120 # Python version string for example).
122 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
123 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
124 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
125 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
126 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
127 "Install path: SALOME scripts")
128 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
129 "Install path: SALOME script data")
130 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
131 "Install path: SALOME Python scripts")
132 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
133 "Install path: SALOME application skeleton - scripts")
134 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
135 "Install path: SALOME application skeleton - Python")
136 SET(SALOME_INSTALL_CMAKE salome_adm/cmake_files CACHE PATH "Install path: SALOME CMake files")
137 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH
138 "Install path: local SALOME CMake files")
140 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
141 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
142 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH
143 "Install path: SALOME Python shared modules")
145 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
148 SET(SALOME_KERNEL_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/kernel" CACHE PATH "Install path: SALOME KERNEL specific data")
149 SET(SALOME_KERNEL_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/kernel" CACHE PATH "Install path: SALOME KERNEL specific scripts")
151 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
152 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
153 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
154 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_KERNEL_INSTALL_RES_DATA SALOME_KERNEL_INSTALL_RES_SCRIPTS)
158 IF(NOT SALOME_LIGHT_ONLY)
159 ADD_SUBDIRECTORY(idl)
161 ADD_SUBDIRECTORY(src)
162 ADD_SUBDIRECTORY(resources)
163 ADD_SUBDIRECTORY(bin)
164 ADD_SUBDIRECTORY(salome_adm)
166 ADD_SUBDIRECTORY(doc)
169 # Header configuration
170 # ====================
171 EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; t=sys.argv[-1].split(\".\") ; t[:]=(int(elt) for elt in t) ; sys.stdout.write(\"0x%02x%02x%02x\"%tuple(t))" ${${PROJECT_NAME_UC}_VERSION}
172 OUTPUT_VARIABLE XVERSION)
173 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/KERNEL_version.h.in)
174 SET(output ${CMAKE_CURRENT_BINARY_DIR}/KERNEL_version.h)
175 MESSAGE(STATUS "Creation of ${output}")
176 CONFIGURE_FILE(${input} ${output} @ONLY)
177 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/KERNEL_version.h DESTINATION ${SALOME_INSTALL_HEADERS})
179 # Configuration export
180 # ====================
181 INCLUDE(CMakePackageConfigHelpers)
183 # List of targets in this project we want to make visible to the rest of the world.
184 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
185 SET(_${PROJECT_NAME}_exposed_targets
186 CalciumC SalomeCalcium DF Launcher
187 OpUtil Registry ResourcesManager SALOMEBasics SalomeCatalog SalomeCommunication
188 SalomeContainer SalomeDatastream SalomePalm SalomeDSCContainer SalomeDSClient
189 SalomeDSCSupervBasic SalomeDSCSuperv SalomeDSImpl
190 SalomeDS SalomeGenericObj SalomeHDFPersist SalomeIDLKernel
191 SalomeLauncher SalomeLifeCycleCORBA SALOMELocalTrace
192 SalomeLoggerServer SalomeNotification SalomeNS
193 SalomeResourcesManager
194 TOOLSDS with_loggerTraceCollector SalomeKernelHelpers)
196 # MPI specific targets:
198 LIST(APPEND _${PROJECT_NAME}_exposed_targets
199 SalomeMPIContainer SalomeTestMPIComponentEngine)
203 IF(SALOME_BUILD_TESTS)
204 LIST(APPEND _${PROJECT_NAME}_exposed_targets
205 LifeCycleCORBATest NamingServiceTest SALOMEDSImplTest SALOMEDSTest SALOMELocalTraceTest
206 SalomeTestComponentEngine SALOMETraceCollectorTest UtilsTest )
209 # Add all targets to the build-tree export set
210 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
211 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
213 # Create the configuration files:
214 # - in the build tree:
216 # Ensure the variables are always defined for the configure:
217 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
218 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
219 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
220 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
221 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
222 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
223 SET(OMNIORBPY_ROOT_DIR "${OMNIORBPY_ROOT_DIR}")
224 SET(LIBBATCH_ROOT_DIR "${LIBBATCH_ROOT_DIR}")
226 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
227 CONFIGURE_PACKAGE_CONFIG_FILE(salome_adm/cmake_files/${PROJECT_NAME}Config.cmake.in
228 ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
229 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
230 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
231 CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
232 SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
233 PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
234 PYTHON_ROOT_DIR SWIG_ROOT_DIR)
236 # - in the install tree:
237 # Get the relative path of the include directory so
238 # we can register it in the generated configuration files:
239 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
240 CONFIGURE_PACKAGE_CONFIG_FILE(salome_adm/cmake_files/${PROJECT_NAME}Config.cmake.in
241 ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
242 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
243 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
244 CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
245 SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
246 PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
247 PYTHON_ROOT_DIR SWIG_ROOT_DIR)
249 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
250 VERSION ${${PROJECT_NAME_UC}_VERSION}
251 COMPATIBILITY AnyNewerVersion)
253 # Install the CMake configuration files:
255 "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
256 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
257 DESTINATION "${SALOME_INSTALL_CMAKE}")
259 # Install the export set for use with the install-tree
260 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}"
261 FILE ${PROJECT_NAME}Targets.cmake)