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_SUBDIRECTORY(src)
182 ADD_SUBDIRECTORY(bin)
183 ADD_SUBDIRECTORY(adm_local)
186 ADD_SUBDIRECTORY(doc)
187 ENDIF(SALOME_BUILD_DOC)
189 IF(NOT SALOME_MED_STANDALONE)
190 ADD_SUBDIRECTORY(idl)
191 ELSE(NOT SALOME_MED_STANDALONE)
192 ADD_SUBDIRECTORY(adm_local_without_kernel)
193 ENDIF(NOT SALOME_MED_STANDALONE)
195 IF(NOT SALOME_MED_MICROMED)
196 ADD_SUBDIRECTORY(resources)
197 ENDIF(NOT SALOME_MED_MICROMED)
199 # Configuration export
200 # ====================
201 INCLUDE(CMakePackageConfigHelpers)
203 # List of targets in this project we want to make visible to the rest of the world.
204 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
205 SET(_${PROJECT_NAME}_exposed_targets
206 interpkernel medcoupling)
208 IF(NOT SALOME_MED_MICROMED)
209 LIST(APPEND _${PROJECT_NAME}_exposed_targets
212 LIST(APPEND _${PROJECT_NAME}_exposed_targets
214 ENDIF(SALOME_USE_MPI)
215 ENDIF(NOT SALOME_MED_MICROMED)
218 LIST(APPEND _${PROJECT_NAME}_exposed_targets
220 ENDIF(SALOME_USE_MPI)
222 IF(NOT SALOME_MED_STANDALONE)
223 LIST(APPEND _${PROJECT_NAME}_exposed_targets
224 SalomeIDLMED medcouplingcorba )
225 ENDIF(NOT SALOME_MED_STANDALONE)
227 # Add all targets to the build-tree export set
229 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
230 FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
232 # Create the configuration files:
233 # - in the build tree:
235 # Ensure the variables are always defined for the configure:
237 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
238 SET(HDF5_ROOT_DIR "${HDF5_ROOT_DIR}")
239 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
240 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
241 SET(PTHREAD_ROOT_DIR "${PTHREAD_ROOT_DIR}")
242 SET(SWIG_ROOT_DIR "${SWIG_ROOT_DIR}")
243 SET(PYTHON_ROOT_DIR "${PYTHON_ROOT_DIR}")
244 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
245 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
246 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
247 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
249 # - in the install tree:
250 # Get the relative path of the include directory so
251 # we can register it in the generated configuration files:
252 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
253 CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in
254 ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
255 INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
256 PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX
257 MEDFILE_ROOT_DIR HDF5_ROOT_DIR OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR
258 SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
261 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
262 VERSION ${${PROJECT_NAME_UC}_VERSION}
263 COMPATIBILITY AnyNewerVersion)
265 # Install the CMake configuration files:
267 "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
268 "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
269 DESTINATION "${SALOME_INSTALL_CMAKE}")
271 # Install the export set for use with the install-tree
272 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}"
273 FILE ${PROJECT_NAME}Targets.cmake)
277 MACRO(INSTALL_AND_COMPILE_PYTHON_FILE PYFILE2COMPINST PYFILELOC)
278 INSTALL(CODE "SET(PYTHON_FILE ${f})")
279 FOREACH(input ${PYFILE2COMPINST})
280 GET_FILENAME_COMPONENT(inputname ${input} NAME)
281 INSTALL(FILES ${input} DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYFILELOC})
282 INSTALL(CODE "MESSAGE(STATUS \"py compiling ${CMAKE_INSTALL_PREFIX}/${PYFILELOC}/${inputname}\")")
283 INSTALL(CODE "SET(CMD \"import py_compile ; py_compile.compile('${CMAKE_INSTALL_PREFIX}/${PYFILELOC}/${inputname}')\")")
284 INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c \"\${CMD}\")")
285 INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c \"\${CMD}\")")
286 ENDFOREACH(input ${PYFILE2COMPINST})
287 ENDMACRO(INSTALL_AND_COMPILE_PYTHON_FILE PYFILE2COMPINST PYFILELOC)