]> SALOME platform Git repositories - modules/med.git/blob - CMakeLists.txt
Salome HOME
Enable Partitioner
[modules/med.git] / CMakeLists.txt
1 # Copyright (C) 2012-2013  CEA/DEN, EDF R&D
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
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 #IF(WIN32)
25 #  INCLUDE(${CMAKE_SOURCE_DIR}/adm_local/cmake_files/FindXDR.cmake)
26 #ENDIF(WIN32)
27
28 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
29 PROJECT(SalomeMED C CXX)
30
31 # Ensure a proper linker behavior:
32 CMAKE_POLICY(SET CMP0003 NEW)
33
34 # Versioning
35 # ===========
36 # Project name, upper case
37 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
38
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})
47 SET(VERSION_DEV "0")
48
49 #
50 # User options
51 # ============
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)
64 #
65 #
66 # Set list of prerequisites
67 # =========================
68
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")
73     INCLUDE(SalomeMacros)
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")
82   INCLUDE(SalomeMacros)
83 ENDIF(NOT SALOME_MED_STANDALONE)
84
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)
92
93 IF(SALOME_BUILD_GUI)
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)
106
107 LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files")
108
109 IF(SALOME_BUILD_TESTS)
110   ENABLE_TESTING()
111   FIND_PACKAGE(SalomeCppUnit REQUIRED)
112 ENDIF(SALOME_BUILD_TESTS)
113
114 IF(SALOME_USE_MPI)
115   FIND_PACKAGE(SalomeMPI REQUIRED)
116 ENDIF(SALOME_USE_MPI)
117
118 IF(SALOME_BUILD_DOC)
119   FIND_PACKAGE(SalomeDoxygen REQUIRED)
120   FIND_PACKAGE(SalomeGraphviz)          # Remains optional even here.
121   FIND_PACKAGE(SalomeSphinx REQUIRED)
122 ENDIF(SALOME_BUILD_DOC)
123
124 IF(SALOME_MED_ENABLE_PYTHON)
125   FIND_PACKAGE(SalomePython REQUIRED)
126   FIND_PACKAGE(SalomeSWIG REQUIRED)
127 ENDIF(SALOME_MED_ENABLE_PYTHON)
128
129 IF(NOT SALOME_MED_MICROMED)
130   FIND_PACKAGE(SalomeMEDFile REQUIRED)
131 ENDIF(NOT SALOME_MED_MICROMED)
132
133
134 # Directories
135 #
136 # Directories have to be given after prerequisites (to be able to use
137 # Python version string for example).
138 # ===========
139 SET(SALOME_INSTALL_BINS bin/salome CACHE PATH "Install path: SALOME binaries")
140 SET(SALOME_INSTALL_LIBS lib/salome CACHE PATH "Install path: SALOME libs")
141 SET(SALOME_INSTALL_IDLS idl/salome CACHE PATH "Install path: SALOME IDL files")
142 SET(SALOME_INSTALL_HEADERS include/salome CACHE PATH "Install path: SALOME headers")
143 SET(SALOME_INSTALL_SCRIPT_SCRIPTS ${SALOME_INSTALL_BINS} CACHE PATH 
144    "Install path: SALOME scripts")
145 SET(SALOME_INSTALL_SCRIPT_DATA ${SALOME_INSTALL_BINS} CACHE PATH 
146    "Install path: SALOME script data")
147 SET(SALOME_INSTALL_SCRIPT_PYTHON ${SALOME_INSTALL_BINS} CACHE PATH 
148    "Install path: SALOME Python scripts")
149 SET(SALOME_INSTALL_APPLISKEL_SCRIPTS ${SALOME_INSTALL_BINS}/appliskel CACHE PATH 
150    "Install path: SALOME application skeleton - scripts")
151 SET(SALOME_INSTALL_APPLISKEL_PYTHON ${SALOME_INSTALL_BINS}/appliskel CACHE PATH 
152    "Install path: SALOME application skeleton - Python")
153 SET(SALOME_INSTALL_CMAKE adm_local/cmake_files CACHE PATH "Install path: SALOME CMake files")
154 SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH 
155    "Install path: local SALOME CMake files")
156
157 IF(SALOME_MED_ENABLE_PYTHON)
158   SET(_pydir lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
159   SET(SALOME_INSTALL_PYTHON ${_pydir}/salome CACHE PATH "Install path: SALOME Python stuff")
160   SET(SALOME_INSTALL_PYTHON_SHARED ${SALOME_INSTALL_PYTHON}/shared_modules CACHE PATH 
161     "Install path: SALOME Python shared modules")
162 ENDIF(SALOME_MED_ENABLE_PYTHON)
163
164 SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources")
165
166 # Med specific:
167
168 SET(SALOME_MED_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific data")
169 SET(SALOME_MED_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/med" CACHE PATH "Install path: SALOME MED specific scripts")
170
171 MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS)
172 MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON)
173 MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS  SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES)
174 MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED SALOME_MED_INSTALL_RES_DATA SALOME_MED_INSTALL_RES_SCRIPTS)
175
176 # Configuration of MED_version.h.in
177
178 SET(input ${PROJECT_SOURCE_DIR}/MED_version.h.in)
179 SET(output ${PROJECT_BINARY_DIR}/MED_version.h)
180 MESSAGE(STATUS "Creation of ${output}")
181 CONFIGURE_FILE(${input} ${output} @ONLY)
182 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/MED_version.h DESTINATION ${SALOME_INSTALL_HEADERS})
183
184 # Sources 
185 # ========
186 IF(WIN32)
187   ADD_DEFINITIONS("-D_USE_MATH_DEFINES")
188 ENDIF(WIN32)
189
190 ADD_SUBDIRECTORY(src)
191 ADD_SUBDIRECTORY(bin)
192 ADD_SUBDIRECTORY(adm_local)
193
194 IF(SALOME_BUILD_DOC)
195   ADD_SUBDIRECTORY(doc)
196 ENDIF(SALOME_BUILD_DOC)
197
198 IF(NOT SALOME_MED_STANDALONE)
199   ADD_SUBDIRECTORY(idl)
200 ELSE(NOT SALOME_MED_STANDALONE)
201   ADD_SUBDIRECTORY(adm_local_without_kernel)
202 ENDIF(NOT SALOME_MED_STANDALONE)
203
204 IF(NOT SALOME_MED_MICROMED)
205   ADD_SUBDIRECTORY(resources)
206 ENDIF(NOT SALOME_MED_MICROMED)
207
208 # Configuration export
209 # ====================
210 INCLUDE(CMakePackageConfigHelpers)
211
212 # List of targets in this project we want to make visible to the rest of the world.
213 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
214 SET(_${PROJECT_NAME}_exposed_targets
215    interpkernel medcoupling medcouplingremapper)
216
217 IF(NOT SALOME_MED_MICROMED)
218   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
219     medloader)
220   IF(SALOME_USE_MPI)
221      LIST(APPEND _${PROJECT_NAME}_exposed_targets 
222        paramedloader)
223   ENDIF(SALOME_USE_MPI)
224 ENDIF(NOT SALOME_MED_MICROMED)
225
226 IF(SALOME_USE_MPI)
227   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
228     paramedmem)
229 ENDIF(SALOME_USE_MPI)
230
231 IF(NOT SALOME_MED_STANDALONE)
232   LIST(APPEND _${PROJECT_NAME}_exposed_targets 
233     SalomeIDLMED medcouplingcorba )
234 ENDIF(NOT SALOME_MED_STANDALONE)
235
236 # Add all targets to the build-tree export set
237
238 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
239   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
240
241 # Create the configuration files:
242 #   - in the build tree:
243
244 #      Ensure the variables are always defined for the configure:
245
246 SET(MEDFILE_ROOT_DIR "${MEDFILE_ROOT_DIR}")
247 SET(HDF5_ROOT_DIR "${HDF5_ROOT_DIR}")
248 SET(MPI_ROOT_DIR "${MPI_ROOT_DIR}")
249 SET(OMNIORB_ROOT_DIR "${OMNIORB_ROOT_DIR}")
250 SET(PTHREAD_ROOT_DIR "${PTHREAD_ROOT_DIR}")
251 SET(SWIG_ROOT_DIR "${SWIG_ROOT_DIR}")
252 SET(PYTHON_ROOT_DIR "${PYTHON_ROOT_DIR}")
253 SET(CPPUNIT_ROOT_DIR "${CPPUNIT_ROOT_DIR}")
254 SET(GRAPHVIZ_ROOT_DIR "${GRAPHVIZ_ROOT_DIR}")
255 SET(DOXYGEN_ROOT_DIR "${DOXYGEN_ROOT_DIR}")
256 SET(SPHINX_ROOT_DIR "${SPHINX_ROOT_DIR}")
257
258 #   - in the install tree:
259 #       Get the relative path of the include directory so 
260 #       we can register it in the generated configuration files:
261 SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
262 CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in 
263     ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake
264     INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE}"
265     PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE CMAKE_INSTALL_PREFIX 
266        MEDFILE_ROOT_DIR HDF5_ROOT_DIR OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR
267        SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR
268        SPHINX_ROOT_DIR)
269
270 WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
271     VERSION ${${PROJECT_NAME_UC}_VERSION}
272     COMPATIBILITY AnyNewerVersion)
273   
274 # Install the CMake configuration files:
275 INSTALL(FILES
276   "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake"
277   "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
278   DESTINATION "${SALOME_INSTALL_CMAKE}")
279
280 # Install the export set for use with the install-tree
281 INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE}" 
282         FILE ${PROJECT_NAME}Targets.cmake)