From 5b8bcf5efdedf02f567486d1b50c5b5f2bf268c9 Mon Sep 17 00:00:00 2001 From: TotoGaz <49004943+TotoGaz@users.noreply.github.com> Date: Wed, 1 Nov 2023 16:53:48 -0700 Subject: [PATCH 1/7] Revert "Revert "Build hdf5 using CMake instead of Autogen" (#247)" This reverts commit dbf21a59a5f03bba12154a48fd98bd49da500490. --- CMakeLists.txt | 50 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3081cf19..ca732388 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,29 +186,35 @@ message(STATUS "Building HDF5 found at ${HDF5_URL}") if( ${ENABLE_MPI} ) set( HDF5_C_COMPILER ${MPI_C_COMPILER} ) set( HDF5_CXX_COMPILER ${MPI_CXX_COMPILER} ) - set( HDF5_ENABLE_PARALLEL "--enable-parallel") else() set( HDF5_C_COMPILER ${CMAKE_C_COMPILER} ) set( HDF5_CXX_COMPILER ${CMAKE_CXX_COMPILER} ) - set( HDF5_ENABLE_PARALLEL "") endif() -set(HDF5_C_FLAGS "-fPIC ${C_FLAGS_NO_WARNINGS} ${CMAKE_C_FLAGS_RELEASE}") - ExternalProject_Add( hdf5 URL ${HDF5_URL} PREFIX ${PROJECT_BINARY_DIR}/hdf5 INSTALL_DIR ${HDF5_DIR} - CONFIGURE_COMMAND ../hdf5/configure - CC=${HDF5_C_COMPILER} - CXX=${HDF5_CXX_COMPILER} - --enable-build-mode=production - --prefix= - ${HDF5_ENABLE_PARALLEL} - --enable-shared=yes - CFLAGS=${HDF5_C_FLAGS} BUILD_COMMAND make -j ${NUM_PROC} - INSTALL_COMMAND make install ) + INSTALL_COMMAND make install + CMAKE_ARGS -D CMAKE_C_COMPILER:STRING=${HDF5_C_COMPILER} + -D CMAKE_CXX_COMPILER:STRING=${HDF5_CXX_COMPILER} + -D CMAKE_C_FLAGS:STRING=${C_FLAGS_NO_WARNINGS} + -D CMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE} + -D CMAKE_CXX_FLAGS:STRING=${CXX_FLAGS_NO_WARNINGS} + -D CMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE} + -D CMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -D CMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} + -D HDF5_ENABLE_PARALLEL:BOOL=${ENABLE_MPI} + -D CMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE} + -D CMAKE_INSTALL_PREFIX:PATH= + -D BUILD_SHARED_LIBS:BOOL=ON + -D BUILD_STATIC_LIBS:BOOL=OFF + -D BUILD_TESTING:BOOL=OFF + -D HDF5_BUILD_EXAMPLES:BOOL=OFF + -D HDF5_BUILD_TOOLS:BOOL=OFF + -D HDF5_BUILD_UTILS:BOOL=OFF + ) list(APPEND HDF5_DEPENDENCIES hdf5 ) list(APPEND build_list hdf5 ) @@ -1080,7 +1086,7 @@ if( ENABLE_VTK ) message( STATUS "Building VTK found at ${VTK_URL}" ) - # Depending on the platfor, the install directory could be 'lib' or 'lib64'. + # Depending on the platform, the install directory could be 'lib' or 'lib64'. # This makes the 'rpath' task more complicated to deal with a single script ('CMAKE_INSTALL_RPATH' option). # Defining explicitly 'lib' deals with this issue. # I'm no cmake expert and I do not know if there was a better way to deal with it. @@ -1247,7 +1253,7 @@ if( ENABLE_FESAPI ) -DCMAKE_C_COMPILER=${FESAPI_C_COMPILER} -DCMAKE_CXX_COMPILER=${FESAPI_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${TPL_CXX_STANDARD} - -DHDF5_ROOT:PATH=${HDF5_DIR} + -DCMAKE_PREFIX_PATH:PATH=${HDF5_DIR} -DMINIZIP_INCLUDE_DIR:PATH=${MINIZIP_DIR}/include -DMINIZIP_LIBRARY_RELEASE:PATH=${MINIZIP_DIR}/lib/libminizip.a -DBoost_NO_SYSTEM_PATHS:BOOL=TRUE @@ -1258,7 +1264,19 @@ if( ENABLE_FESAPI ) -DWITH_JAVA_WRAPPING:BOOL=OFF -DWITH_PYTHON_WRAPPING:BOOL=OFF -DWITH_RESQML2_2:BOOL=OFF - -DWITH_TEST:BOOL=OFF) + -DWITH_TEST:BOOL=OFF + # Next lines prevent compilation + # errors due to an issue with the + # detection of the hdf5 version in + # fesapi < 2.4.0.0 (on CentOS, for + # Release build of hdf5, see + # https://github.com/F2I-Consulting/fesapi/issues/326) + # It should be possible to remove it when + # fesapi-2.9.0.0 will be released + -DWITH_LOCAL_HDF5:BOOL=ON + -DHDF5_INCLUDE_DIRS:PATH=${HDF5_DIR}/include + -DHDF5_LIBRARIES:PATH=${HDF5_DIR}/lib/libhdf5${CMAKE_SHARED_MODULE_SUFFIX} + ) list(APPEND build_list fesapi ) From 16c058a97b07792e4d7ad4097301b004d946f312 Mon Sep 17 00:00:00 2001 From: Algiane Froehly Date: Mon, 13 Nov 2023 12:05:53 +0100 Subject: [PATCH 2/7] Fix wrong use of CMAKE_SHARED_MODULE_SUFFIX instead of CMAKE_SHARED_LIBRARY_SUFFIX to find the extension of hdf5 shared library. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca732388..0ba134b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1275,7 +1275,7 @@ if( ENABLE_FESAPI ) # fesapi-2.9.0.0 will be released -DWITH_LOCAL_HDF5:BOOL=ON -DHDF5_INCLUDE_DIRS:PATH=${HDF5_DIR}/include - -DHDF5_LIBRARIES:PATH=${HDF5_DIR}/lib/libhdf5${CMAKE_SHARED_MODULE_SUFFIX} + -DHDF5_LIBRARIES:PATH=${HDF5_DIR}/lib/libhdf5${CMAKE_SHARED_LIBRARY_SUFFIX} ) list(APPEND build_list fesapi ) From 1189776e9526ff36e2d73e7b114921dcf7cb96a1 Mon Sep 17 00:00:00 2001 From: Algiane Froehly Date: Mon, 13 Nov 2023 12:00:59 +0100 Subject: [PATCH 3/7] In Debug mode, build hdf5 in RelWithDebInfo mode to bypass the fact that Silo's autogen script searches for libhdf5 library while CMake's build of hdf5 creates the libhdf5_debug library in Debug mode. --- CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ba134b8..dc52a6f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,6 +191,16 @@ else() set( HDF5_CXX_COMPILER ${CMAKE_CXX_COMPILER} ) endif() +# Build hdf5 in RelWithDebInfo mode to avoid errors when compiling +# Silo: Silo's autogen script fails to find the hdf5 library if it is +# built in Debug mode with CMake due to hdf5 naming convention (see +# https://github.com/LLNL/Silo/issues/369). +if( CMAKE_BUILD_TYPE MATCHES Debug ) + set( HDF5_CMAKE_BUILD_TYPE RelWithDebInfo ) +else() + set( HDF5_CMAKE_BUILD_TYPE CMAKE_BUILD_TYPE ) +endif() + ExternalProject_Add( hdf5 URL ${HDF5_URL} PREFIX ${PROJECT_BINARY_DIR}/hdf5 @@ -203,7 +213,7 @@ ExternalProject_Add( hdf5 -D CMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE} -D CMAKE_CXX_FLAGS:STRING=${CXX_FLAGS_NO_WARNINGS} -D CMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE} - -D CMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -D CMAKE_BUILD_TYPE:STRING=${HDF5_CMAKE_BUILD_TYPE} -D CMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} -D HDF5_ENABLE_PARALLEL:BOOL=${ENABLE_MPI} -D CMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE} From 5c4630a93692b1e6363090db28ce605835ec933d Mon Sep 17 00:00:00 2001 From: Algiane Froehly Date: Mon, 13 Nov 2023 12:02:54 +0100 Subject: [PATCH 4/7] If compiler is Clang, add the -w flag to Silo's compiler flags to avoid a compilation error with release 4.11 of Silo (fixed by release 4.11.1). --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc52a6f2..ac620965 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,6 +294,19 @@ set(SILO_DIR "${CMAKE_INSTALL_PREFIX}/silo") set(SILO_URL "${TPL_MIRROR_DIR}/silo-4.11-bsd.tgz") message(STATUS "Building SILO found at ${SILO_URL}") +# -w compiler flag is needed to build Silo release 4.11 with +# AppleClang or regular Clang due to implicit declaration of +# 'zfp_init_zfp'. This issue is fixed by release 4.11.1 so it will be +# possible to remove the `-w` flag when we will use this latter (see +# https://github.com/LLNL/Silo/issues/224). +# +# This -w flag was exported inside the HDF5_C_FLAGS variable when hdf5 was built +# using autogen. +# +if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) + # HDF5_C_FLAGS is used only here so we can overwritting it + LIST( APPEND HDF5_C_FLAGS -w ) +endif() ExternalProject_Add( silo URL ${SILO_URL} From e2feaa183512459a039e657c8f960955dfd14df3 Mon Sep 17 00:00:00 2001 From: tbeltzun <129868353+tbeltzun@users.noreply.github.com> Date: Wed, 15 Nov 2023 16:22:45 +0100 Subject: [PATCH 5/7] Update CMakeLists.txt Co-authored-by: TotoGaz <49004943+TotoGaz@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac620965..01befd35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -304,7 +304,7 @@ message(STATUS "Building SILO found at ${SILO_URL}") # using autogen. # if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) - # HDF5_C_FLAGS is used only here so we can overwritting it + # HDF5_C_FLAGS is used only here so we can overwrite it LIST( APPEND HDF5_C_FLAGS -w ) endif() From 50973010638d5d9f7caeec46a1c5f1f1dffd0720 Mon Sep 17 00:00:00 2001 From: tbeltzun <129868353+tbeltzun@users.noreply.github.com> Date: Wed, 15 Nov 2023 16:22:55 +0100 Subject: [PATCH 6/7] Update CMakeLists.txt Co-authored-by: TotoGaz <49004943+TotoGaz@users.noreply.github.com> --- CMakeLists.txt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01befd35..2bd558ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1288,14 +1288,10 @@ if( ENABLE_FESAPI ) -DWITH_PYTHON_WRAPPING:BOOL=OFF -DWITH_RESQML2_2:BOOL=OFF -DWITH_TEST:BOOL=OFF - # Next lines prevent compilation - # errors due to an issue with the - # detection of the hdf5 version in - # fesapi < 2.4.0.0 (on CentOS, for - # Release build of hdf5, see - # https://github.com/F2I-Consulting/fesapi/issues/326) - # It should be possible to remove it when - # fesapi-2.9.0.0 will be released + # Next lines prevent compilation errors due to an issue + # with the detection of the hdf5 version in fesapi < 2.4.0.0 + # (on CentOS, for Release build of hdf5, see https://github.com/F2I-Consulting/fesapi/issues/326) + # It should be possible to remove it when fesapi-2.9.0.0 will be released -DWITH_LOCAL_HDF5:BOOL=ON -DHDF5_INCLUDE_DIRS:PATH=${HDF5_DIR}/include -DHDF5_LIBRARIES:PATH=${HDF5_DIR}/lib/libhdf5${CMAKE_SHARED_LIBRARY_SUFFIX} From 907382bf0c6e7215d7c96120f9ee37c38037637d Mon Sep 17 00:00:00 2001 From: Algiane Froehly Date: Thu, 16 Nov 2023 11:02:28 +0100 Subject: [PATCH 7/7] Build Silo with position independent code (-fpic) to solve compilation error of geos with Cuda on ubuntu. --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bd558ac..ddae729c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -316,7 +316,8 @@ ExternalProject_Add( silo DEPENDS ${HDF5_DEPENDENCIES} CONFIGURE_COMMAND ../silo/configure CC=${HDF5_C_COMPILER} - CFLAGS=${HDF5_C_FLAGS} + # Ensure that silo is built with position independent code + "CFLAGS=${HDF5_C_FLAGS} -fpic" CXX=${HDF5_CXX_COMPILER} --prefix= --disable-fortran