]> SALOME platform Git repositories - modules/kernel.git/blob - CMakeLists.txt
Salome HOME
CMake: restoring FindKERNEL.cmake for compatibility with AutoTools
[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 PROJECT(SalomeKERNEL C CXX)
21
22 # Ensure a proper linker behavior:
23 CMAKE_POLICY(SET CMP0003 NEW)
24
25 # Versioning
26 # ===========
27 # Project name, upper case
28 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
29
30 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
31 SET(${PROJECT_NAME_UC}_MINOR_VERSION 2)
32 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
33 SET(${PROJECT_NAME_UC}_VERSION
34   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
35 # Temporary backward compatibility:
36 SET(VERSION ${${PROJECT_NAME_UC}_VERSION})
37 SET(VERSION_DEV "0")
38
39 # Our own set of macros:
40 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/salome_adm/cmake_files")
41 INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/SalomeMacros.cmake)
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 OPTION(SALOME_USE_MPI "Use MPI containers" OFF)
60 OPTION(SALOME_BUILD_DOC "Generate SALOME KERNEL documentation" ON)
61 OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
62
63 # Advanced:
64 OPTION(SALOME_LIGHT_ONLY "Build SALOME Light only (no CORBA)" OFF)
65 OPTION(SALOME_USE_LIBBATCH "Use LibBatch in KERNEL" ON)
66 OPTION(SALOME_PACO_PARALLEL "Build with PACO in parallel" OFF)
67 OPTION(SALOME_LAUNCHER_ONLY "Build only the Launcher part" OFF)
68 MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_LIBBATCH SALOME_PACO_PARALLEL SALOME_LAUNCHER_ONLY)
69
70 # Required prerequisites
71 #   Find "big" prerequisites first - they reference themselves many others
72 #   -> this can help finding the smaller prerequisites and detect conficts.
73 # =======================
74
75 # Exception: LibBatch is optional but is loaded first, as it can
76 # give Python, Pthread and SWIG:
77 IF(SALOME_USE_LIBBATCH)
78   FIND_PACKAGE(SalomeLibBatch REQUIRED)
79 ENDIF()
80
81 FIND_PACKAGE(SalomePython REQUIRED)
82 FIND_PACKAGE(SalomePThread REQUIRED)
83 FIND_PACKAGE(SalomeSWIG REQUIRED)
84 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
85 FIND_PACKAGE(SalomeHDF5 REQUIRED COMPONENTS C)
86 FIND_PACKAGE(SalomeBoost REQUIRED)
87
88 # Optional prerequisites
89 # ======================
90
91 IF(NOT SALOME_LIGHT_ONLY)
92   FIND_PACKAGE(SalomeOmniORB REQUIRED)
93 ENDIF() 
94 IF(SALOME_USE_MPI)
95   FIND_PACKAGE(SalomeMPI REQUIRED)
96 ENDIF()
97 IF(SALOME_BUILD_TESTS)
98   ENABLE_TESTING()
99   FIND_PACKAGE(SalomeCppUnit REQUIRED)  
100 ENDIF()
101 IF(SALOME_BUILD_DOC)
102   FIND_PACKAGE(SalomeDoxygen REQUIRED)
103   FIND_PACKAGE(SalomeGraphviz)          # Remains optional even here.
104   FIND_PACKAGE(SalomeSphinx REQUIRED)
105 ENDIF()
106
107 # Directories
108 #
109 # Directories have to be given after prerequisites (to be able to use
110 # Python version string for example).
111 # ===========
112 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
113 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
114 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
115 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
116 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH 
117    "Install path: SALOME scripts")
118 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH 
119    "Install path: SALOME script data")
120 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH 
121    "Install path: SALOME Python scripts")
122 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH 
123    "Install path: SALOME application skeleton - scripts")
124 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH 
125    "Install path: SALOME application skeleton - Python")
126 SET(SALOME_INSTALL_CMAKE salome_adm/cmake_files CACHE PATH "Install path: SALOME CMake files")
127 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH 
128    "Install path: local SALOME CMake files")
129
130 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
131 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
132 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH 
133    "Install path: SALOME Python shared modules")
134
135 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
136
137 # Kernel specific:
138 SET(SALOME_KERNEL_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/kernel" CACHE PATH "Install path: SALOME KERNEL specific data")
139 SET(SALOME_KERNEL_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/kernel" CACHE PATH "Install path: SALOME KERNEL specific scripts")
140
141 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
142 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
143 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
144 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_KERNEL_INSTALL_RES_DATA SALOME_KERNEL_INSTALL_RES_SCRIPTS)
145
146 # Sources 
147 # ========
148 IF(NOT SALOME_LIGHT_ONLY)
149   ADD_SUBDIRECTORY(idl)
150 ENDIF()
151 ADD_SUBDIRECTORY(src)
152 ADD_SUBDIRECTORY(resources)
153 ADD_SUBDIRECTORY(bin)
154 ADD_SUBDIRECTORY(salome_adm)
155 IF(SALOME_BUILD_DOC)
156   ADD_SUBDIRECTORY(doc)
157 ENDIF()
158
159 # Header configuration
160 # ====================
161 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}
162   OUTPUT_VARIABLE XVERSION)
163 SET(input ${CMAKE_CURRENT_SOURCE_DIR}/KERNEL_version.h.in)
164 SET(output ${CMAKE_CURRENT_BINARY_DIR}/KERNEL_version.h)
165 MESSAGE(STATUS "Creation of ${output}")
166 CONFIGURE_FILE(${input} ${output} @ONLY)
167 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/KERNEL_version.h DESTINATION ${SALOME_INSTALL_HEADERS})
168
169 # Configuration export
170 # ====================
171 INCLUDE(CMakePackageConfigHelpers)
172
173 # List of targets in this project we want to make visible to the rest of the world.
174 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
175 SET(_${PROJECT_NAME}_exposed_targets
176   CalciumC SalomeCalcium DF Launcher LifeCycleCORBATest NamingServiceTest
177   OpUtil Registry ResourcesManager SALOMEBasics SalomeCatalog SalomeCommunication
178   SalomeContainer SalomeDatastream SalomePalm SalomeDSCContainer SalomeDSClient
179   SalomeDSCSupervBasic SalomeDSCSuperv SalomeDSImpl SALOMEDSImplTest
180   SalomeDS SALOMEDSTest SalomeGenericObj SalomeHDFPersist SalomeIDLKernel
181   SalomeLauncher  SalomeLifeCycleCORBA  SALOMELocalTrace SALOMELocalTraceTest
182   SalomeLoggerServer SalomeNotification SalomeNS
183   SalomeResourcesManager SalomeTestComponentEngine 
184   SALOMETraceCollectorTest TOOLSDS UtilsTest with_loggerTraceCollector SalomeKernelHelpers)
185   
186 # MPI specific targets:
187 IF(SALOME_USE_MPI)
188   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
189        SalomeMPIContainer SalomeTestMPIComponentEngine)
190 ENDIF()
191
192 # Add all targets to the build-tree export set
193 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
194   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
195
196 # Create the configuration files:
197 #   - in the build tree:
198
199 #      Ensure the variables are always defined for the configure:
200 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
201 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
202 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
203 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
204 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
205 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
206 SET(LIBBATCH_ROOT_DIR "${LIBBATCH_ROOT_DIR}")
207  
208 SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
209 CONFIGURE_PACKAGE_CONFIG_FILE(salome_adm/cmake_files/${PROJECT_NAME}Config.cmake.in 
210     ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
211     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
212     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
213        CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
214        SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR LIBBATCH_ROOT_DIR
215        PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
216        PYTHON_ROOT_DIR SWIG_ROOT_DIR)
217
218 #   - in the install tree:
219 #       Get the relative path of the include directory so 
220 #       we can register it in the generated configuration files:
221 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
222 CONFIGURE_PACKAGE_CONFIG_FILE(salome_adm/cmake_files/${PROJECT_NAME}Config.cmake.in 
223     ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
224     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
225     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX 
226        CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
227        SPHINX_ROOT_DIR MPI_ROOT_DIR OMNIORB_ROOT_DIR LIBBATCH_ROOT_DIR
228        PTHREAD_ROOT_DIR BOOST_ROOT_DIR HDF5_ROOT_DIR LIBXML2_ROOT_DIR
229        PYTHON_ROOT_DIR SWIG_ROOT_DIR)
230
231 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
232     VERSION ${${PROJECT_NAME_UC}_VERSION}
233     COMPATIBILITY AnyNewerVersion)
234   
235 # Install the CMake configuration files:
236 INSTALL(FILES
237   "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
238   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
239   DESTINATION "${SALOME_INSTALL_CMAKE}")
240
241 # Install the export set for use with the install-tree
242 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}" 
243         FILE ${PROJECT_NAME}Targets.cmake)