1 # Copyright (C) 2012-2013 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.
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
20 # TODO: write those in the new format, and load them via FIND_PACKAGE():
21 #INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindPARMETIS.cmake)
22 #INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindMETIS.cmake)
23 #INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindSCOTCH.cmake)
24 #INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindSPLITTER.cmake)
25 #INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindRENUMBER.cmake)
27 # INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindXDR.cmake)
30 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
31 PROJECT(SalomeMED C CXX)
33 # Ensure a proper linker behavior:
34 CMAKE_POLICY(SET CMP0003 NEW)
38 # Project name, upper case
39 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
41 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
42 SET(${PROJECT_NAME_UC}_MINOR_VERSION 2)
43 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
44 SET(${PROJECT_NAME_UC}_VERSION
45 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
46 # Temporary backward compatibility:
47 SET(VERSION ${${PROJECT_NAME_UC}_VERSION})
48 SET(XVERSION 0x0${${PROJECT_NAME_UC}_MAJOR_VERSION}0${${PROJECT_NAME_UC}_MINOR_VERSION}0${${PROJECT_NAME_UC}_PATCH_VERSION})
54 OPTION(SALOME_MED_STANDALONE "Build MED without CORBA bindings. When OFF, exchange to PARAVIS is disabled." OFF)
55 OPTION(SALOME_MED_MICROMED "Build MED without MED file dependancy." OFF)
56 OPTION(SALOME_MED_ENABLE_PYTHON "Build PYTHON bindings." ON)
57 OPTION(SALOME_USE_MPI "To build ParaMEDMEM." OFF)
58 OPTION(SALOME_BUILD_GUI "Build GUI of MED." ON)
59 OPTION(SALOME_BUILD_TESTS "Build MED tests." ON)
60 OPTION(SALOME_BUILD_DOC "Build MED doc." ON)
63 # Set list of prerequisites
64 # =========================
66 IF(NOT SALOME_MED_STANDALONE)
67 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
68 IF(EXISTS ${KERNEL_ROOT_DIR})
69 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
71 FIND_PACKAGE(SalomeKERNEL REQUIRED)
72 ELSE(EXISTS ${KERNEL_ROOT_DIR})
73 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_MED_STANDALONE to ON !")
74 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
75 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
76 FIND_PACKAGE(SalomeOmniORB REQUIRED)
77 ELSE(NOT SALOME_MED_STANDALONE)
78 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local_without_kernel/cmake_files")
80 ENDIF(NOT SALOME_MED_STANDALONE)
82 IF(NOT SALOME_MED_MICROMED)
83 FIND_PACKAGE(SalomeHDF5 REQUIRED)
84 FIND_PACKAGE(SalomeMedfile REQUIRED)
85 ENDIF(NOT SALOME_MED_MICROMED)
88 IF(NOT SALOME_MED_STANDALONE)
89 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
90 IF(EXISTS ${GUI_ROOT_DIR})
91 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
92 FIND_PACKAGE(SalomeGUI REQUIRED)
93 ELSE(EXISTS ${GUI_ROOT_DIR})
94 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
95 ENDIF(EXISTS ${GUI_ROOT_DIR})
96 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
97 FIND_PACKAGE(SalomeCAS REQUIRED) # maybe one day it will disappear ...
98 ENDIF(NOT SALOME_MED_STANDALONE)
99 ENDIF(SALOME_BUILD_GUI)
101 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
103 IF(SALOME_BUILD_TESTS)
105 FIND_PACKAGE(SalomeCppUnit REQUIRED)
106 ENDIF(SALOME_BUILD_TESTS)
109 FIND_PACKAGE(SalomeMPI REQUIRED)
110 ENDIF(SALOME_USE_MPI)
113 FIND_PACKAGE(SalomeDoxygen REQUIRED)
114 FIND_PACKAGE(SalomeGraphviz) # Remains optional even here.
115 FIND_PACKAGE(SalomeSphinx REQUIRED)
116 ENDIF(SALOME_BUILD_DOC)
118 IF(SALOME_MED_ENABLE_PYTHON)
119 FIND_PACKAGE(SalomePython REQUIRED)
120 FIND_PACKAGE(SalomeSWIG REQUIRED)
121 ENDIF(SALOME_MED_ENABLE_PYTHON)
123 IF(NOT SALOME_MED_MICROMED)
124 FIND_PACKAGE(SalomeMedfile REQUIRED)
125 ENDIF(NOT SALOME_MED_MICROMED)
130 # Directories have to be given after prerequisites (to be able to use
131 # Python version string for example).
133 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
134 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
135 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
136 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
137 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
138 "Install path: SALOME scripts")
139 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
140 "Install path: SALOME script data")
141 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
142 "Install path: SALOME Python scripts")
143 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
144 "Install path: SALOME application skeleton - scripts")
145 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
146 "Install path: SALOME application skeleton - Python")
147 SET(SALOME_INSTALL_CMAKE adm_local/cmake_files CACHE PATH "Install path: SALOME CMake files")
148 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH
149 "Install path: local SALOME CMake files")
151 IF(SALOME_MED_ENABLE_PYTHON)
152 SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
153 SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
154 SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH
155 "Install path: SALOME Python shared modules")
156 ENDIF(SALOME_MED_ENABLE_PYTHON)
158 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
162 SET(SALOME_MED_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific data")
163 SET(SALOME_MED_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific scripts")
165 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
166 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
167 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
168 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_MED_INSTALL_RES_DATA SALOME_MED_INSTALL_RES_SCRIPTS)
170 # Configuration of MED_version.h.in
172 SET(input ${PROJECT_SOURCE_DIR}/MED_version.h.in)
173 SET(output ${PROJECT_BINARY_DIR}/MED_version.h)
174 MESSAGE(STATUS "Creation of ${output}")
175 CONFIGURE_FILE(${input} ${output} @ONLY)
176 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/MED_version.h DESTINATION ${SALOME_INSTALL_HEADERS})
181 ADD_DEFINITIONS("-D_USE_MATH_DEFINES")
184 ADD_SUBDIRECTORY(src)
185 ADD_SUBDIRECTORY(bin)
186 ADD_SUBDIRECTORY(adm_local)
189 ADD_SUBDIRECTORY(doc)
190 ENDIF(SALOME_BUILD_DOC)
192 IF(NOT SALOME_MED_STANDALONE)
193 ADD_SUBDIRECTORY(idl)
194 ELSE(NOT SALOME_MED_STANDALONE)
195 ADD_SUBDIRECTORY(adm_local_without_kernel)
196 ENDIF(NOT SALOME_MED_STANDALONE)
198 IF(NOT SALOME_MED_MICROMED)
199 ADD_SUBDIRECTORY(resources)
200 ENDIF(NOT SALOME_MED_MICROMED)
202 # Configuration export
203 # ====================
204 INCLUDE(CMakePackageConfigHelpers)
206 # List of targets in this project we want to make visible to the rest of the world.
207 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
208 SET(_${PROJECT_NAME}_exposed_targets
209 interpkernel medcoupling)
211 IF(NOT SALOME_MED_MICROMED)
212 LIST(APPEND _${PROJECT_NAME}_exposed_targets
215 LIST(APPEND _${PROJECT_NAME}_exposed_targets
217 ENDIF(SALOME_USE_MPI)
218 ENDIF(NOT SALOME_MED_MICROMED)
221 LIST(APPEND _${PROJECT_NAME}_exposed_targets
223 ENDIF(SALOME_USE_MPI)
225 IF(NOT SALOME_MED_STANDALONE)
226 LIST(APPEND _${PROJECT_NAME}_exposed_targets
227 SalomeIDLMED medcouplingcorba )
228 ENDIF(NOT SALOME_MED_STANDALONE)
230 # Add all targets to the build-tree export set
232 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
233 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
235 # Create the configuration files:
236 # - in the build tree:
238 # Ensure the variables are always defined for the configure:
240 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
241 SET(HDF5_ROOT_DIR "${HDF5_ROOT_DIR}")
242 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
243 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
244 SET(PTHREAD_ROOT_DIR "${PTHREAD_ROOT_DIR}")
245 SET(SWIG_ROOT_DIR "${SWIG_ROOT_DIR}")
246 SET(PYTHON_ROOT_DIR "${PYTHON_ROOT_DIR}")
247 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
248 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
249 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
250 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
252 # - in the install tree:
253 # Get the relative path of the include directory so
254 # we can register it in the generated configuration files:
255 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
256 CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
257 ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
258 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
259 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
260 MEDFILE_ROOT_DIR HDF5_ROOT_DIR OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR
261 SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
264 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
265 VERSION ${${PROJECT_NAME_UC}_VERSION}
266 COMPATIBILITY AnyNewerVersion)
268 # Install the CMake configuration files:
270 "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
271 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
272 DESTINATION "${SALOME_INSTALL_CMAKE}")
274 # Install the export set for use with the install-tree
275 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}"
276 FILE ${PROJECT_NAME}Targets.cmake)