Skip to content

Commit

Permalink
Merge branch 'master' of github.com:hopr-framework/hopr into feature.…
Browse files Browse the repository at this point in the history
…AppImage
  • Loading branch information
scopplestone committed Mar 14, 2023
2 parents b411316 + 9da2d3e commit 40e3570
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CMake
name: cmake-make

on:
push:
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/cmake-ninja.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: cmake-ninja

on:
push:
#pull_request:

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

# Use centos7
container:
image: centos:7

steps:
- uses: actions/checkout@v3

- name: Dependencies
run: |
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-Linux-x86_64.sh
chmod +x cmake-3.16.4-Linux-x86_64.sh
./cmake-3.16.4-Linux-x86_64.sh --skip-license --prefix=/usr/local
curl -L -O https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-16.02-20.el7.x86_64.rpm
curl -L -O https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-plugins-16.02-20.el7.x86_64.rpm
rpm -U --quiet p7zip-16.02-20.el7.x86_64.rpm
rpm -U --quiet p7zip-plugins-16.02-20.el7.x86_64.rpm
yum install -y epel-release
yum install -y make libasan gcc-gfortran gcc-c++ unzip git openblas-devel lapack-devel zlib-devel
curl -L -O https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip
unzip ninja-linux.zip
mv ./ninja /usr/bin
- name: Configure CMake
shell: bash
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
#run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
# hdf5-openmpi-devel on centos7 probably broken
#run: cmake -G Ninja -B ${{github.workspace}}/build -DLIBS_BUILD_HDF5=OFF -DCMAKE_BUILD_TYPE=Release -DLIBS_USE_MPI=OFF
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DLIBS_USE_MPI=OFF

- name: Build
shell: bash
# Build your program with the given configuration
#run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
run: cmake --build ${{github.workspace}}/build

- name: Create archive
run: |
mkdir artifact
7z a artifact/hopr.zip ${{github.workspace}}/build/bin/hopr
# Upload hopr binary archive as an artifact
- name: Upload artifact
uses: actions/upload-artifact@v1
with:
name: hopr-binary-archives
path: artifact
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ ENDIF()
# Location of binary and filenames
# =========================================================================
# append relative filename-macro for __FILENAME__ in Stamp of abort function (see flexi.h)
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
# subst replacement is GNU make specific
IF("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
ENDIF()

# add basedir for location of corresponding userblock-file
ADD_DEFINITIONS("-DBASEDIR='\"${CMAKE_CURRENT_BINARY_DIR}/\"'")
Expand Down
93 changes: 67 additions & 26 deletions CMakeListsLib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ ENDIF()
OPTION(LIBS_USE_MPI "Compile SINGLE or MPI version" OFF)
MARK_AS_ADVANCED(FORCE LIBS_USE_MPI)
IF(LIBS_USE_MPI)
SET(MPI_DETERMINE_LIBRARY_VERSION TRUE)
FIND_PACKAGE(MPI REQUIRED)

IF (NOT MPI_Fortran_NO_INTERROGATE)
FOREACH(DIR ${MPI_INCLUDE_PATH})
INCLUDE_DIRECTORIES(${DIR})
Expand All @@ -61,13 +63,31 @@ IF(LIBS_USE_MPI)
ENDFOREACH()
LIST(APPEND linkedlibs ${MPI_Fortran_LIBRARIES})
ENDIF()

MARK_AS_ADVANCED(FORCE MPI_LIBRARY MPI_EXTRA_LIBRARY)
MESSAGE(STATUS "Building HOPR with MPI")
MESSAGE(STATUS "MPI Compiler: " ${MPI_Fortran_COMPILER})
# Detect HPE MPT implementation since if changes some MPI definitions
IF("${MPI_Fortran_COMPILER}" MATCHES "mpt")

# Detect MPI implementation and version since it changes some MPI definitions
IF(MPI_C_LIBRARY_VERSION_STRING MATCHES ".*CRAY MPICH.*" AND MPI_C_VERSION_MAJOR MATCHES "3")
SET(LIBS_MPI_NAME "Cray MPICH")
STRING(REGEX MATCH "([0-9]+)\\.([0-9]+)" MPI_C_LIBRARY_VERSION ${MPI_C_LIBRARY_VERSION_STRING})
ELSEIF(MPI_C_LIBRARY_VERSION_STRING MATCHES ".*MPICH.*" AND MPI_C_VERSION_MAJOR MATCHES "3")
SET(LIBS_MPI_NAME "MPICH")
STRING(REGEX MATCH "([0-9]+)\\.([0-9]+)" MPI_C_LIBRARY_VERSION ${MPI_C_LIBRARY_VERSION_STRING})
ELSEIF(MPI_C_LIBRARY_VERSION_STRING MATCHES ".*Open MPI.*" AND MPI_C_VERSION_MAJOR MATCHES "3")
SET(LIBS_MPI_NAME "OpenMPI")
STRING(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" MPI_C_LIBRARY_VERSION ${MPI_C_LIBRARY_VERSION_STRING})
ELSEIF(MPI_C_LIBRARY_VERSION_STRING MATCHES ".*HPE MPT.*" AND MPI_C_VERSION_MAJOR MATCHES "3")
SET(LIBS_MPI_NAME "HPE MPT")
STRING(REGEX MATCH "([0-9]+)\\.([0-9]+)" MPI_C_LIBRARY_VERSION ${MPI_C_LIBRARY_VERSION_STRING})
ADD_DEFINITIONS(-DLIBS_MPT=1)
ELSEIF(MPI_C_LIBRARY_VERSION_STRING MATCHES ".*Intel.*" AND MPI_C_VERSION_MAJOR MATCHES "3")
SET(LIBS_MPI_NAME "Intel MPI")
STRING(REGEX MATCH "([0-9]+)\\.([0-9]+)" MPI_C_LIBRARY_VERSION ${MPI_C_LIBRARY_VERSION_STRING})
ELSE()
MESSAGE(FATAL_ERROR "Cannot detect supported MPI type or version. Valid options are Cray MPICH, IntelMPI, MPICH, HPE MPT, and OpenMPI supporting MPI version 3.x")
ENDIF()

MESSAGE(STATUS "Compiling with [${LIBS_MPI_NAME}] (v${MPI_C_LIBRARY_VERSION})")
ADD_DEFINITIONS(-DUSE_MPI=1)
ELSE()
ADD_DEFINITIONS(-DUSE_MPI=0)
Expand All @@ -92,6 +112,12 @@ SET(HDF5_ROOT "$ENV{HDF5_ROOT}" CACHE STRING "Expose HDF5_ROOT environment varia

# Use system HDF5
IF(NOT LIBS_BUILD_HDF5)
# Unset leftover paths from old CMake runs
UNSET(HDF5_LIBRARIES)
UNSET(HDF5_INCLUDE_DIR_FORTRAN)
UNSET(HDF5_INCLUDE_DIR)
UNSET(HDF5_DIFF_EXECUTABLE)

# Try to find the CMake version
SET(LIBS_HDF5_CMAKE TRUE)
FIND_PACKAGE(HDF5 NAMES hdf5 COMPONENTS C Fortran ${SEARCH_TYPE} QUIET PATH_SUFFIXES share/cmake)
Expand Down Expand Up @@ -137,20 +163,16 @@ ELSE()
#SET HDF5_TAG depending on MPI Version
IF(LIBS_USE_MPI)
# HDF5 1.12.0 and greater is compatible with OpenMPI 4.0.0 and greater
EXECUTE_PROCESS(COMMAND mpiexec --version COMMAND grep ^mpiexec COMMAND sed "s/^.* //g" OUTPUT_VARIABLE OPENMPI_VERSION)
IF (DEFINED OPENMPI_VERSION AND NOT "${OPENMPI_VERSION}" STREQUAL "")
IF (${OPENMPI_VERSION} VERSION_GREATER_EQUAL "4.0.0")
SET (HDF5_TAG "hdf5-1_12_0" CACHE STRING "HDF5 version tag")
ELSE()
SET (HDF5_TAG "hdf5-1_10_6" CACHE STRING "HDF5 version tag")
ENDIF()
IF("${LIBS_MPI_NAME}" MATCHES "OpenMPI" AND ${MPI_C_LIBRARY_VERSION} VERSION_GREATER_EQUAL "4.0.0")
SET (HDF5_TAG "hdf5-1_12_0" CACHE STRING "HDF5 version tag")
ELSE()
SET (HDF5_TAG "hdf5-1_10_6" CACHE STRING "HDF5 version tag")
ENDIF()
MESSAGE (STATUS "Setting HDF5 to tag ${HDF5_TAG} to be compatible with detected [${LIBS_MPI_NAME}] (v${MPI_C_LIBRARY_VERSION})")
ELSE()
SET (HDF5_TAG "hdf5-1_12_0" CACHE STRING "HDF5 version tag")
MESSAGE (STATUS "Setting HDF5 to tag ${HDF5_TAG} as no MPI support was requested")
ENDIF()
MESSAGE (STATUS "Setting HDF5 to tag ${HDF5_TAG} to be compatible with detected MPI version")
MARK_AS_ADVANCED(FORCE HDF5_TAG)

# Set HDF5 build dir
Expand All @@ -169,6 +191,10 @@ ELSE()
SET(LIBS_HDF5CC ${CMAKE_C_COMPILER} )
ENDIF()

# Set parallel build with maximum number of threads
INCLUDE(ProcessorCount)
PROCESSORCOUNT(N)

# Optional Features:
# --enable-silent-rules less verbose build output (undo: "make V=1")
# --enable-build-mode=(debug|production|clean)
Expand All @@ -192,12 +218,14 @@ ELSE()
PREFIX ${LIBS_HDF5_DIR}
UPDATE_COMMAND ""
CONFIGURE_COMMAND FC=${LIBS_HDF5FC} CC=${LIBS_HDF5CC} ${LIBS_HDF5_DIR}/src/HDF5/configure --prefix=${LIBS_HDF5_DIR} --with-pic --enable-fortran ${LIBS_HDF5PARALLEL} --libdir=${LIBS_HDF5_DIR}/lib --enable-build-mode=production --enable-silent-rules --disable-dependency-tracking
BUILD_COMMAND ${MAKE}
BUILD_BYPRODUCTS ${LIBS_HDF5_DIR}/lib/libhdf5_fortran.a ${LIBS_HDF5_DIR}/lib/libhdf5.a ${LIBS_HDF5_DIR}/bin/h5diff
# Configure explicitly requires GNU make
BUILD_COMMAND make -j${N}
)
SET(LIBS_HDF5_CMAKE FALSE)

# CMake HDF5 is fast but not yet reliable. The following section can be enabled once HDF5 promotes the CMake option to stable
#ExternalProject_Add(HDF5
#EXTERNALPROJECT_ADD(HDF5
# GIT_REPOSITORY ${HDF5DOWNLOAD}
# GIT_TAG ${HDF5_TAG}
# GIT_PROGRESS TRUE
Expand Down Expand Up @@ -227,7 +255,7 @@ ELSE()
LIST(APPEND HDF5_INCLUDE_DIR ${HDF5_C_INCLUDE_DIR})
MARK_AS_ADVANCED(FORCE HDF5_z_LIBRARY_RELEASE)
# Add ZLIB to include paths for HDF5 data compression
FIND_LIBRARY(HDF5_z_LIBRARY_RELEASE z)
FIND_LIBRARY(HDF5_z_LIBRARY_RELEASE z REQUIRED)
LIST(APPEND HDF5_LIBRARIES ${HDF5_hdf5_fortran_LIBRARY_RELEASE} ${HDF5_hdf5_LIBRARY_RELEASE} ${HDF5_z_LIBRARY_RELEASE} -ldl)
ENDIF()

Expand All @@ -239,7 +267,11 @@ IF(LIBS_HDF5_CMAKE)
# HDF5 build with configure
ELSE()
INCLUDE_DIRECTORIES (${HDF5_INCLUDE_DIR_FORTRAN} ${HDF5_INCLUDE_DIR})
MESSAGE(STATUS "Found HDF5 Libs: " ${HDF5_LIBRARIES})
IF(${HDF5_IS_PARALLEL})
MESSAGE(STATUS "Compiling with [HDF5] (v${HDF5_VERSION}) with parallel support")
ELSE()
MESSAGE(STATUS "Compiling with [HDF5] (v${HDF5_VERSION}) without parallel support")
ENDIF()
LIST(APPEND linkedlibs ${HDF5_LIBRARIES} )
ENDIF()

Expand All @@ -263,15 +295,17 @@ IF(NOT LIBS_BUILD_MATH_LIB)
FIND_PACKAGE(LAPACK QUIET)
IF (LAPACK_FOUND)
LIST(APPEND linkedlibs ${LAPACK_LIBRARIES})
MESSAGE(STATUS "Using system BLAS/Lapack library")
MESSAGE(STATUS "Compiling with system [BLAS/Lapack]")
ENDIF()

# Build LAPACK/OpenBLAS in HOPR
ELSE()
# Offer LAPACK and OpenBLAS
SET (LIBS_BUILD_MATH_LIB_VENDOR LAPACK CACHE STRING "Choose the type of math lib vendor, options are: LAPACK, OpenBLAS.")
SET_PROPERTY(CACHE LIBS_BUILD_MATH_LIB_VENDOR PROPERTY STRINGS LAPACK OpenBLAS)

# Set parallel build with maximum number of threads
INCLUDE(ProcessorCount)
PROCESSORCOUNT(N)

# Build LAPACK
IF (LIBS_BUILD_MATH_LIB_VENDOR MATCHES "LAPACK")
# Origin pointing to Github
Expand Down Expand Up @@ -315,6 +349,7 @@ ELSE()
PREFIX ${LIBS_MATH_DIR}
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX=${LIBS_MATH_DIR} -DBLAS++=OFF -DLAPACK++=OFF -DBUILD_SHARED_LIBS=ON -DCBLAS=OFF -DLAPACKE=OFF -DBUILD_TESTING=OFF
BUILD_BYPRODUCTS ${LIBS_MATH_DIR}/lib/liblapack.so ${LIBS_MATH_DIR}/lib/libblas.so
)

LIST(APPEND SELFBUILTEXTERNALS ${LIBS_BUILD_MATH_LIB_VENDOR})
Expand All @@ -331,8 +366,11 @@ ELSE()
PREFIX ${LIBS_MATH_DIR}
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_BYPRODUCTS ${LIBS_MATH_DIR}/src/${LIBS_BUILD_MATH_LIB_VENDOR}/libopenblas.so
BUILD_IN_SOURCE TRUE
INSTALL_COMMAND ""
# Configure explicitly requires GNU make
BUILD_COMMAND make -j${N}
)

LIST(APPEND SELFBUILTEXTERNALS ${LIBS_BUILD_MATH_LIB_VENDOR})
Expand All @@ -355,7 +393,7 @@ ELSE()
# Actually add the math lib paths to the linking paths
INCLUDE_DIRECTORIES (${MATH_LIB_LIBRARIES})
LIST(APPEND linkedlibs ${LAPACK_LIBRARY} ${BLAS_LIBRARY})
MESSAGE(STATUS "Using self-built LAPACK library")
MESSAGE(STATUS "Compiling with self-built [LAPACK]")
ELSEIF (LIBS_BUILD_MATH_LIB_VENDOR MATCHES "OpenBLAS")
# Set math lib paths
SET(MATH_LIB_LIBRARIES ${LIBS_MATH_DIR}/src/${LIBS_BUILD_MATH_LIB_VENDOR})
Expand All @@ -369,7 +407,7 @@ ELSE()
# Actually add the math lib paths to the linking paths
INCLUDE_DIRECTORIES (${MATH_LIB_LIBRARIES})
LIST(APPEND linkedlibs ${LAPACK_LIBRARY} ${BLAS_LIBRARY})
MESSAGE(STATUS "Using self-built OpenBLAS library")
MESSAGE(STATUS "Compiling with self-built [OpenBLAS]")
ENDIF()
ENDIF()

Expand Down Expand Up @@ -424,7 +462,7 @@ ELSE()
SET(LIBS_CGNS_DLDIR ${LIBS_EXTERNAL_LIB_DIR}/CGNS${LIBS_BUILD_CGNS_TAG})
SET(LIBS_CGNS_DIR ${LIBS_CGNS_DLDIR})

IF (NOT EXISTS "${LIBS_CGNS_DIR}/build/lib/libcgns.a")
IF (NOT EXISTS "${LIBS_CGNS_DIR}/lib/libcgns.a")
STRING(COMPARE EQUAL ${LIBS_BUILD_CGNS_INT} "64" LIBS_CGNS_64BIT)

# Origin pointing to Github
Expand All @@ -445,10 +483,11 @@ ELSE()
GIT_PROGRESS TRUE
${${GITSHALLOW}}
PREFIX ${LIBS_CGNS_DIR}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBS_CGNS_DIR}/build -DCMAKE_PREFIX_PATH=${LIBS_HDF5_DIR} /
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBS_CGNS_DIR} -DCMAKE_PREFIX_PATH=${LIBS_HDF5_DIR} /
-DCGNS_ENABLE_FORTRAN=ON -DCGNS_ENABLE_64BIT=${LIBS_CGNS_64BIT} -DCGNS_BUILD_SHARED=OFF -DCGNS_USE_SHARED=OFF /
-DCMAKE_BUILD_TYPE=Release -DCGNS_BUILD_CGNSTOOLS=OFF -DCGNS_ENABLE_HDF5=${LIBS_BUILD_CGNS_ENABLE_HDF5} /
-DCGNS_ENABLE_PARALLEL=OFF -DCGNS_ENABLE_TESTS=OFF -DCMAKE_SKIP_RPATH=ON /
-DCGNS_ENABLE_PARALLEL=OFF -DCGNS_ENABLE_TESTS=OFF -DCMAKE_SKIP_RPATH=ON
BUILD_BYPRODUCTS ${LIBS_CGNS_DIR}/lib/libcgns.a
)
# If HDF5 is built in HOPR, it must occur before the CGNS compilation (for the support of HDF5-based CGNS files)
IF(LIBS_BUILD_HDF5)
Expand All @@ -459,8 +498,10 @@ ELSE()
LIST(APPEND SELFBUILTEXTERNALS cgns)
ENDIF()

LIST(INSERT linkedlibs 0 ${LIBS_CGNS_DIR}/build/lib/libcgns.a)
INCLUDE_DIRECTORIES( ${LIBS_CGNS_DIR}/build/include)
LIST(INSERT linkedlibs 0 ${LIBS_CGNS_DIR}/lib/libcgns.a)
INCLUDE_DIRECTORIES( ${LIBS_CGNS_DIR}/include)

MESSAGE(STATUS "Compiling with [CGNS] (${LIBS_BUILD_CGNS_TAG})")
ENDIF()

# set pre-processor flag for CGNS version
Expand Down
Loading

0 comments on commit 40e3570

Please sign in to comment.