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)
25 # INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindXDR.cmake)
28 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
29 PROJECT(SalomeMED C CXX)
31 # Ensure a proper linker behavior:
32 CMAKE_POLICY(SET CMP0003 NEW)
36 # Project name, upper case
37 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
39 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
40 SET(${PROJECT_NAME_UC}_MINOR_VERSION 2)
41 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
42 SET(${PROJECT_NAME_UC}_VERSION
43 ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
44 # Temporary backward compatibility:
45 SET(VERSION ${${PROJECT_NAME_UC}_VERSION})
46 SET(XVERSION 0x0${${PROJECT_NAME_UC}_MAJOR_VERSION}0${${PROJECT_NAME_UC}_MINOR_VERSION}0${${PROJECT_NAME_UC}_PATCH_VERSION})
52 INCLUDE(CMakeDependentOption)
53 OPTION(SALOME_MED_STANDALONE "Build MED without CORBA bindings. When OFF, exchange to PARAVIS is disabled." OFF)
54 OPTION(SALOME_MED_MICROMED "Build MED without MED file dependancy." OFF)
55 OPTION(SALOME_MED_ENABLE_PYTHON "Build PYTHON bindings." ON)
56 OPTION(SALOME_MED_ENABLE_PARTITIONER "Build MEDPartitioner." 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)
61 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_METIS "Enable metis graph librarie in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;NOT SALOME_USE_MPI" OFF)
62 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_SCOTCH "Enable scotch graph librarie in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;NOT SALOME_USE_MPI" OFF)
63 CMAKE_DEPENDENT_OPTION(SALOME_MED_PARTITIONER_PARMETIS "Enable parmetis graph librarie in MEDPartitioner." ON "SALOME_MED_ENABLE_PARTITIONER;SALOME_USE_MPI" OFF)
66 # Set list of prerequisites
67 # =========================
69 IF(NOT SALOME_MED_STANDALONE)
70 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
71 IF(EXISTS ${KERNEL_ROOT_DIR})
72 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
74 FIND_PACKAGE(SalomeKERNEL REQUIRED)
75 ELSE(EXISTS ${KERNEL_ROOT_DIR})
76 MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_MED_STANDALONE to ON !")
77 ENDIF(EXISTS ${KERNEL_ROOT_DIR})
78 LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
79 FIND_PACKAGE(SalomeOmniORB REQUIRED)
80 ELSE(NOT SALOME_MED_STANDALONE)
81 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local_without_kernel/cmake_files")
83 ENDIF(NOT SALOME_MED_STANDALONE)
85 IF(NOT SALOME_MED_MICROMED)
86 FIND_PACKAGE(SalomeHDF5 REQUIRED)
87 FIND_PACKAGE(SalomeMEDFile REQUIRED)
88 IF(SALOME_MED_ENABLE_PARTITIONER)
89 FIND_PACKAGE(SalomeLibXml2 REQUIRED)
90 ENDIF(SALOME_MED_ENABLE_PARTITIONER)
91 ENDIF(NOT SALOME_MED_MICROMED)
94 IF(NOT SALOME_MED_STANDALONE)
95 SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
96 IF(EXISTS ${GUI_ROOT_DIR})
97 LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files")
98 FIND_PACKAGE(SalomeGUI REQUIRED)
99 ELSE(EXISTS ${GUI_ROOT_DIR})
100 MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
101 ENDIF(EXISTS ${GUI_ROOT_DIR})
102 FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
103 FIND_PACKAGE(SalomeCAS REQUIRED) # maybe one day it will disappear ...
104 ENDIF(NOT SALOME_MED_STANDALONE)
105 ENDIF(SALOME_BUILD_GUI)
107 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
109 IF(SALOME_BUILD_TESTS)
111 FIND_PACKAGE(SalomeCppUnit REQUIRED)
112 ENDIF(SALOME_BUILD_TESTS)
115 FIND_PACKAGE(SalomeMPI REQUIRED)
116 ENDIF(SALOME_USE_MPI)
119 FIND_PACKAGE(SalomeDoxygen REQUIRED)
120 FIND_PACKAGE(SalomeGraphviz) # Remains optional even here.
121 FIND_PACKAGE(SalomeSphinx REQUIRED)
122 ENDIF(SALOME_BUILD_DOC)
124 IF(SALOME_MED_ENABLE_PYTHON)
125 FIND_PACKAGE(SalomePython REQUIRED)
126 FIND_PACKAGE(SalomeSWIG REQUIRED)
127 ENDIF(SALOME_MED_ENABLE_PYTHON)
131 # Directories have to be given after prerequisites (to be able to use
132 # Python version string for example).
134 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
135 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
136 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
137 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
138 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH
139 "Install path: SALOME scripts")
140 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH
141 "Install path: SALOME script data")
142 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH
143 "Install path: SALOME Python scripts")
144 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
145 "Install path: SALOME application skeleton - scripts")
146 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH
147 "Install path: SALOME application skeleton - Python")
148 SET(SALOME_INSTALL_CMAKE adm_local/cmake_files CACHE PATH "Install path: SALOME CMake files")
149 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH
150 "Install path: local SALOME CMake files")
152 IF(SALOME_MED_ENABLE_PYTHON)
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 ENDIF(SALOME_MED_ENABLE_PYTHON)
159 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
163 SET(SALOME_MED_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific data")
164 SET(SALOME_MED_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific scripts")
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_MED_INSTALL_RES_DATA SALOME_MED_INSTALL_RES_SCRIPTS)
171 # Configuration of MED_version.h.in
173 SET(input ${PROJECT_SOURCE_DIR}/MED_version.h.in)
174 SET(output ${PROJECT_BINARY_DIR}/MED_version.h)
175 MESSAGE(STATUS "Creation of ${output}")
176 CONFIGURE_FILE(${input} ${output} @ONLY)
177 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/MED_version.h DESTINATION ${SALOME_INSTALL_HEADERS})
182 ADD_DEFINITIONS("-D_USE_MATH_DEFINES")
185 ADD_SUBDIRECTORY(src)
186 ADD_SUBDIRECTORY(bin)
187 ADD_SUBDIRECTORY(adm_local)
190 ADD_SUBDIRECTORY(doc)
191 ENDIF(SALOME_BUILD_DOC)
193 IF(NOT SALOME_MED_STANDALONE)
194 ADD_SUBDIRECTORY(idl)
195 ELSE(NOT SALOME_MED_STANDALONE)
196 ADD_SUBDIRECTORY(adm_local_without_kernel)
197 ENDIF(NOT SALOME_MED_STANDALONE)
199 IF(NOT SALOME_MED_MICROMED)
200 ADD_SUBDIRECTORY(resources)
201 ENDIF(NOT SALOME_MED_MICROMED)
203 # Configuration export
204 # ====================
205 INCLUDE(CMakePackageConfigHelpers)
207 # List of targets in this project we want to make visible to the rest of the world.
208 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
209 SET(_${PROJECT_NAME}_exposed_targets
210 interpkernel medcoupling medcouplingremapper)
212 IF(NOT SALOME_MED_MICROMED)
213 LIST(APPEND _${PROJECT_NAME}_exposed_targets
216 LIST(APPEND _${PROJECT_NAME}_exposed_targets
218 ENDIF(SALOME_USE_MPI)
219 ENDIF(NOT SALOME_MED_MICROMED)
222 LIST(APPEND _${PROJECT_NAME}_exposed_targets
224 ENDIF(SALOME_USE_MPI)
226 IF(NOT SALOME_MED_STANDALONE)
227 LIST(APPEND _${PROJECT_NAME}_exposed_targets
228 SalomeIDLMED medcouplingcorba )
229 ENDIF(NOT SALOME_MED_STANDALONE)
231 # Add all targets to the build-tree export set
233 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
234 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
236 # Create the configuration files:
237 # - in the build tree:
239 # Ensure the variables are always defined for the configure:
241 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
242 SET(HDF5_ROOT_DIR "${HDF5_ROOT_DIR}")
243 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
244 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
245 SET(PTHREAD_ROOT_DIR "${PTHREAD_ROOT_DIR}")
246 SET(SWIG_ROOT_DIR "${SWIG_ROOT_DIR}")
247 SET(PYTHON_ROOT_DIR "${PYTHON_ROOT_DIR}")
248 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
249 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
250 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
251 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
253 # - in the install tree:
254 # Get the relative path of the include directory so
255 # we can register it in the generated configuration files:
256 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
257 CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
258 ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
259 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
260 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
261 MEDFILE_ROOT_DIR HDF5_ROOT_DIR OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR
262 SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
265 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
266 VERSION ${${PROJECT_NAME_UC}_VERSION}
267 COMPATIBILITY AnyNewerVersion)
269 # Install the CMake configuration files:
271 "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
272 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
273 DESTINATION "${SALOME_INSTALL_CMAKE}")
275 # Install the export set for use with the install-tree
276 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}"
277 FILE ${PROJECT_NAME}Targets.cmake)