On my Ubuntu setup, compilation failes when using med.h, since

libmedc is built with openMPI, while freeCAD selects hdf5-serial.

libmed declares functions prototypes which has MPI parameters if
built for openMPI, causing compilation errors. Doing some online
searches reveals that some users manually changes the include-paths
to hdf5-openmpi if this error happens.

This patch tries to autodetect this situation.
This commit is contained in:
Stian Skjelstad
2018-12-21 02:27:05 +01:00
committed by Yorik van Havre
parent 2226da3a20
commit dccf48d3f4
2 changed files with 14 additions and 2 deletions

View File

@@ -703,12 +703,21 @@ endif()
list(REMOVE_ITEM VTK_LIBRARIES "optimized" "debug")
if(NOT FREECAD_USE_EXTERNAL_SMESH)
find_package(MEDFile REQUIRED)
# See https://www.hdfgroup.org/HDF5/release/cmakebuild.html
if (WIN32)
find_package(HDF5 COMPONENTS NO_MODULE REQUIRED static)
else()
find_package(PkgConfig)
pkg_search_module(HDF5 hdf5-serial)
FILE(READ ${meddotH} TMPTXT)
STRING(FIND "${TMPTXT}" "#define MED_HAVE_MPI" matchres)
if(${matchres} EQUAL -1)
message(STATUS "We guess that libmed was built using hdf5-serial version")
pkg_search_module(HDF5 hdf5-serial)
else()
message(STATUS "We guess that libmed was built using hdf5-openmpi version")
pkg_search_module(HDF5 hdf5-openmpi)
endif()
if(NOT HDF5_FOUND)
find_package(HDF5 REQUIRED)
else()
@@ -735,7 +744,6 @@ endif()
message( WARNING "mpi.h was not found. Check for error above.")
endif()
endif()
find_package(MEDFile REQUIRED)
set(SMESH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdParty/salomesmesh/inc)
else(NOT FREECAD_USE_EXTERNAL_SMESH)

View File

@@ -41,6 +41,10 @@ IF(MEDFILE_ROOT_DIR)
ENDIF(MEDFILE_ROOT_DIR)
FIND_PATH(MEDFILE_INCLUDE_DIRS med.h PATH_SUFFIXES med)
find_file(meddotH med.h PATHS ${MEDFILE_INCLUDE_DIRS} NO_DEFAULT_PATH)
if(NOT meddotH)
message( FATAL_ERROR "med.h not found in an error message above.")
endif()
#FIND_PROGRAM(MDUMP mdump)
FIND_LIBRARY(MEDFILE_C_LIBRARIES NAMES medC)
FIND_LIBRARY(MEDFILE_F_LIBRARIES NAMES med)