]> SALOME platform Git repositories - modules/kernel.git/blob - CMakeLists.txt
Salome HOME
CMake: reverting to the previous behaviour for optional prerequisites.
[modules/kernel.git] / CMakeLists.txt
1 # Copyright (C) 2012-2013  CEA/DEN, EDF R&D, 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.
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(SalomeKERNEL C CXX)
23
24 # Ensure a proper linker behavior:
25 CMAKE_POLICY(SET CMP0003 NEW)
26
27 # Versioning
28 # ===========
29 # Project name, upper case
30 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
31
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})
37 SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
38
39 # Our own set of macros:
40 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/salome_adm/cmake_files")
41 INCLUDE(SalomeMacros)
42
43 # Platform setup
44 # ==============
45 INCLUDE(SalomeSetupPlatform)
46 # Always build libraries as shared objects:
47 SET(BUILD_SHARED_LIBS TRUE)
48 # Temporary step instead of Find Calcium.cmake
49 SET(CALCIUM_IDL_INT_F77 long)
50 SET(CALCIUM_CORBA_INT_F77 CORBA::Long)
51 SET(LONG_OR_INT int)
52 # Global definitions
53 ADD_DEFINITIONS(-DSIZEOF_FORTRAN_INTEGER=4 -DSIZEOF_INT=4)
54 ## OmniORB already defines SIZEOF_LONG 
55 # ADD_DEFINITIONS(-DSIZEOF_LONG=${SIZE_OF_LONG})
56
57 # User options
58 # ============
59 CMAKE_DEPENDENT_OPTION(SALOME_USE_MPI "Use MPI containers" OFF
60                        "NOT SALOME_PACO_PARALLEL" ON)
61 OPTION(SALOME_BUILD_DOC "Generate SALOME KERNEL documentation" ON)
62 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
63
64 # Advanced:
65 OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF)
66 OPTION(SALOME_USE_LIBBATCH "Use LibBatch in KERNEL" ON)
67 OPTION(SALOME_PACO_PARALLEL "Build with PACO (implies SALOME_USE_MPI)" OFF)
68 OPTION(SALOME_LAUNCHER_ONLY "Build only the Launcher part" OFF)
69 MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_PACO_PARALLEL SALOME_LAUNCHER_ONLY)
70
71 # Required prerequisites
72 #   Find "big" prerequisites first - they reference themselves many others
73 #   -> this can help finding the smaller prerequisites and detect conficts.
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(SalomePython REQUIRED)
84 FIND_PACKAGE(SalomePThread REQUIRED)
85 FIND_PACKAGE(SalomeSWIG REQUIRED)
86 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
87 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
88 FIND_PACKAGE(SalomeBoost REQUIRED)
89
90 # Optional prerequisites
91 # ======================
92
93 IF(NOT SALOME_LIGHT_ONLY)
94   FIND_PACKAGE(SalomeOmniORB REQUIRED)
95   FIND_PACKAGE(SalomeOmniORBPy REQUIRED)
96 ENDIF() 
97 IF(SALOME_USE_MPI)
98   FIND_PACKAGE(SalomeMPI REQUIRED)
99   IF(HDF5_IS_PARALLEL)
100     SALOME_ADD_MPI_TO_HDF5()
101   ENDIF()
102 ENDIF()
103 IF(SALOME_PACO_PARALLEL)
104   FIND_PACKAGE(SalomePaco REQUIRED)
105 ENDIF()
106 IF(SALOME_BUILD_TESTS)
107   ENABLE_TESTING()
108   FIND_PACKAGE(SalomeCppUnit)
109   SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)  
110 ENDIF()
111 IF(SALOME_BUILD_DOC)
112   FIND_PACKAGE(SalomeDoxygen)
113   FIND_PACKAGE(SalomeGraphviz)
114   FIND_PACKAGE(SalomeSphinx)
115   SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
116   SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC)
117   SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
118 ENDIF()
119
120 # Detection summary:
121 SALOME_PACKAGE_REPORT_AND_CHECK()
122
123 # Directories
124 #
125 # Directories have to be given after prerequisites (to be able to use
126 # Python version string for example).
127 # ===========
128 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
129 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
130 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
131 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
132 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH 
133    "Install path: SALOME scripts")
134 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH 
135    "Install path: SALOME script data")
136 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH 
137    "Install path: SALOME Python scripts")
138 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH 
139    "Install path: SALOME application skeleton - scripts")
140 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH 
141    "Install path: SALOME application skeleton - Python")
142 SET(SALOME_INSTALL_CMAKE salome_adm/cmake_files CACHE PATH "Install path: SALOME CMake files")
143 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH 
144    "Install path: local SALOME CMake files")
145 SET(SALOME_INSTALL_AMCONFIG salome_adm/unix CACHE PATH 
146    "Install path: SALOME config files (obsolete, to be removed)")
147 SET(SALOME_INSTALL_AMCONFIG_LOCAL adm_local/unix CACHE PATH 
148    "Install path: local SALOME config files (obsolete, to be removed)")
149
150 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
151 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
152 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH 
153    "Install path: SALOME Python shared modules")
154
155 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
156
157 SET(SALOME_INSTALL_DOC share/doc/salome CACHE PATH "Install path: SALOME documentation")
158
159 # Kernel specific:
160 SET(SALOME_KERNEL_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/kernel" CACHE PATH "Install path: SALOME KERNEL specific data")
161 SET(SALOME_KERNEL_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/kernel" CACHE PATH "Install path: SALOME KERNEL specific scripts")
162
163 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
164 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
165 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
166 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_KERNEL_INSTALL_RES_DATA SALOME_KERNEL_INSTALL_RES_SCRIPTS SALOME_INSTALL_DOC)
167 MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG SALOME_INSTALL_AMCONFIG_LOCAL)
168
169 # Sources 
170 # ========
171 IF(NOT SALOME_LIGHT_ONLY)
172   ADD_SUBDIRECTORY(idl)
173 ENDIF()
174 ADD_SUBDIRECTORY(src)
175 ADD_SUBDIRECTORY(resources)
176 ADD_SUBDIRECTORY(bin)
177 ADD_SUBDIRECTORY(salome_adm)
178 IF(SALOME_BUILD_DOC)
179   ADD_SUBDIRECTORY(doc)
180 ENDIF()
181
182 # Header configuration
183 # ====================
184 SALOME_XVERSION(${PROJECT_NAME})
185 SALOME_CONFIGURE_FILE(KERNEL_version.h.in KERNEL_version.h INSTALL ${SALOME_INSTALL_HEADERS})
186
187 # Configuration export
188 # ====================
189 INCLUDE(CMakePackageConfigHelpers)
190
191 # List of targets in this project we want to make visible to the rest of the world.
192 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
193
194 # Temporary solution for pakage src\DSC on windows
195 IF(NOT WINDOWS)
196   SET(DSC_TGS CalciumC SalomeCalcium SalomeDatastream 
197   SalomePalm SalomeDSCSupervBasic SalomeDSCSuperv)
198 ENDIF(NOT WINDOWS)
199
200 SET(_${PROJECT_NAME}_exposed_targets
201   ${DSC_TGS} DF Launcher OpUtil Registry ResourcesManager 
202   SALOMEBasics SalomeCatalog SalomeCommunication SalomeContainer 
203   SalomeDSCContainer SalomeDSClient SalomeDSImpl 
204   SalomeDS SalomeGenericObj SalomeHDFPersist SalomeIDLKernel
205   SalomeLauncher SalomeLifeCycleCORBA SALOMELocalTrace 
206   SalomeLoggerServer SalomeNotification SalomeNS
207   SalomeResourcesManager TOOLSDS with_loggerTraceCollector 
208   SalomeKernelHelpers)
209   
210 # MPI specific targets:
211 IF(SALOME_USE_MPI)
212   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
213        SalomeMPIContainer SalomeTestMPIComponentEngine)
214 ENDIF()
215
216 # Test targets:
217 IF(SALOME_BUILD_TESTS)
218   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
219       LifeCycleCORBATest NamingServiceTest SALOMEDSImplTest SALOMEDSTest SALOMELocalTraceTest
220       SalomeTestComponentEngine SALOMETraceCollectorTest UtilsTest )
221 ENDIF()
222
223 # Add all targets to the build-tree export set
224 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
225   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
226
227 # Create the configuration files:
228 #   - in the build tree:
229
230 #      Ensure the variables are always defined for the configure:
231 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
232 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
233 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
234 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
235 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
236 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
237 SET(OMNIORBPY_ROOT_DIR "${OMNIORBPY_ROOT_DIR}")
238 SET(LIBBATCH_ROOT_DIR "${LIBBATCH_ROOT_DIR}")
239  
240 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
241 CONFIGURE_PACKAGE_CONFIG_FILE(salome_adm/cmake_files/${PROJECT_NAME}Config.cmake.in 
242     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
243     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
244     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
245        CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
246        SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
247        PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
248        PYTHON_ROOT_DIR SWIG_ROOT_DIR)
249
250 #   - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
251 #       Get the relative path of the include directory so 
252 #       we can register it in the generated configuration files:
253 #SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
254 #CONFIGURE_PACKAGE_CONFIG_FILE(salome_adm/cmake_files/${PROJECT_NAME}Config.cmake.in 
255 #    ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
256 #    INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
257 #    PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX 
258 #       CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
259 #       SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR OMNIORBPY_ROOT_DIR LIBBATCH_ROOT_DIR
260 #       PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
261 #       PYTHON_ROOT_DIR SWIG_ROOT_DIR)
262
263 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
264     VERSION ${${PROJECT_NAME_UC}_VERSION}
265     COMPATIBILITY AnyNewerVersion)
266   
267 # Install the CMake configuration files:
268 INSTALL(FILES
269   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
270   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
271   DESTINATION "${SALOME_INSTALL_CMAKE}")
272
273 # Install the export set for use with the install-tree
274 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}" 
275         FILE ${PROJECT_NAME}Targets.cmake)