Skip to content

Commit

Permalink
Merge branch 'develop' into feature-puff
Browse files Browse the repository at this point in the history
  • Loading branch information
cburstedde committed Mar 22, 2024
2 parents 7966db0 + d95bc14 commit 0c6f654
Show file tree
Hide file tree
Showing 28 changed files with 637 additions and 256 deletions.
36 changes: 19 additions & 17 deletions .github/workflows/ci_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
linux:
runs-on: ubuntu-22.04
name: CMake build on Linux
timeout-minutes: 15
timeout-minutes: 60

strategy:
matrix:
Expand Down Expand Up @@ -92,16 +92,16 @@ jobs:

- name: Upload package
if: github.event.action == 'published'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: binary-archive
name: linux-binary-archive-${{ matrix.cc }}-${{ matrix.mpi }}-shared-${{ matrix.shared }}
path: build/package

- name: Upload log files
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: linux_cmake_log
name: linux_cmake_log-${{ matrix.cc }}-${{ matrix.mpi }}-shared-${{ matrix.shared }}
path: |
./build/CMakeFiles/CMakeConfigureLog.yaml
./build/Testing/Temporary/LastTest.log
Expand All @@ -110,7 +110,7 @@ jobs:
needs: linux
runs-on: ubuntu-22.04
name: CMake with Valgrind
timeout-minutes: 15
timeout-minutes: 60

strategy:
matrix:
Expand Down Expand Up @@ -143,17 +143,19 @@ jobs:

- name: Upload log files
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: linux_cmake_valgrind_log
path: |
./build/CMakeFiles/CMakeConfigureLog.yaml
./build/Testing/Temporary/LastTest.log
mac:
runs-on: macos-latest
# macos-14 is to use Apple Silicon hardware as most Apple users nowadays would have
# https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/
runs-on: macos-14
name: CMake build on MacOS
timeout-minutes: 15
timeout-minutes: 60

strategy:
matrix:
Expand Down Expand Up @@ -198,24 +200,24 @@ jobs:

- name: Upload package
if: github.event.action == 'published'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: binary-archive
name: mac-binary-archive-${{ matrix.cc }}-shared-${{ matrix.shared }}
path: build/package

- name: Upload log files
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: mac_cmake_log
name: mac_cmake_log-${{ matrix.cc }}-shared-${{ matrix.shared }}
path: |
./build/CMakeFiles/CMakeConfigureLog.yaml
./build/Testing/Temporary/LastTest.log
windows:
runs-on: windows-latest
name: CMake build on Windows
timeout-minutes: 20
timeout-minutes: 60

strategy:
matrix:
Expand Down Expand Up @@ -253,14 +255,14 @@ jobs:

- name: Upload package
if: github.event.action == 'published'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: binary-archive
name: windows-binary-archive
path: build/package

- name: Upload log files
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: windows_cmake_log
path: |
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ $<$<BOOL:${SC_NEED_M}>:m>
$<$<BOOL:${WIN32}>:${WINSOCK_LIBRARIES}>
)

# imported target, for use from FetchContent
# imported target, for use from parent project
add_library(SC::SC INTERFACE IMPORTED GLOBAL)
target_link_libraries(SC::SC INTERFACE sc)

Expand Down
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"noTestsAction": "error",
"scheduleRandom": true,
"stopOnFailure": false,
"timeout": 30
"timeout": 60
},
"filter": {
"exclude": {
Expand Down
43 changes: 34 additions & 9 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ endif()

find_package(Threads)

find_package(jansson CONFIG)
if(TARGET jansson::jansson)
set(SC_HAVE_JSON 1 CACHE BOOL "JSON features enabled")
if(json)
message(STATUS "Using builtin jansson")
include(${CMAKE_CURRENT_LIST_DIR}/jansson.cmake)
else()
set(SC_HAVE_JSON 0 CACHE BOOL "JSON features disabled")
find_package(jansson CONFIG)
if(TARGET jansson::jansson)
set(SC_HAVE_JSON 1 CACHE BOOL "JSON features enabled")
else()
set(SC_HAVE_JSON 0 CACHE BOOL "JSON features disabled")
endif()
endif()
# --- set global compile environment

Expand All @@ -74,6 +79,7 @@ if(mpi)
set(SC_CC \"${MPI_C_COMPILER}\")
set(SC_CPP ${MPI_C_COMPILER})
else()
set(SC_ENABLE_MPI 0)
set(SC_CC \"${CMAKE_C_COMPILER}\")
set(SC_CPP ${CMAKE_C_COMPILER})
endif()
Expand Down Expand Up @@ -104,7 +110,16 @@ endif()
set(SC_ENABLE_PTHREAD ${CMAKE_USE_PTHREADS_INIT})
set(SC_ENABLE_MEMALIGN 1)

if(mpi)
if(NOT SC_ENABLE_MPI EQUAL CACHE{SC_ENABLE_MPI})
# user has requested a different MPI setting, so we need to clear these cache variables to recheck
unset(SC_ENABLE_MPICOMMSHARED CACHE)
unset(SC_ENABLE_MPITHREAD CACHE)
unset(SC_ENABLE_MPIWINSHARED CACHE)
unset(SC_ENABLE_MPIIO CACHE)
unset(SC_ENABLE_MPI CACHE)
endif()

if(SC_ENABLE_MPI)
check_symbol_exists(MPI_COMM_TYPE_SHARED mpi.h SC_ENABLE_MPICOMMSHARED)
# perform check to set SC_ENABLE_MPIIO
include(cmake/check_mpiio.cmake)
Expand Down Expand Up @@ -201,9 +216,8 @@ endif()
check_type_size(int SC_SIZEOF_INT BUILTIN_TYPES_ONLY)
check_type_size("unsigned int" SC_SIZEOF_UNSIGNED_INT BUILTIN_TYPES_ONLY)
check_type_size(long SC_SIZEOF_LONG BUILTIN_TYPES_ONLY)
check_type_size("long long" SC_SIZEOF_LONG_LONG BUILTIN_TYPES_ONLY)
check_type_size("unsigned long" SC_SIZEOF_UNSIGNED_LONG BUILTIN_TYPES_ONLY)
check_type_size("unsigned long long" SC_SIZEOF_UNSIGNED_LONG_LONG BUILTIN_TYPES_ONLY)
check_type_size("long long" SC_SIZEOF_LONG_LONG BUILTIN_TYPES_ONLY)
set(SC_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})

if(CMAKE_BUILD_TYPE MATCHES "Debug")
Expand All @@ -214,6 +228,9 @@ endif()

configure_file(${CMAKE_CURRENT_LIST_DIR}/sc_config.h.in ${PROJECT_BINARY_DIR}/include/sc_config.h)

file(TIMESTAMP ${PROJECT_BINARY_DIR}/include/sc_config.h _t)
message(VERBOSE "sc_config.h was last generated ${_t}")

# --- sanity check of MPI sc_config.h

unset(SC_ENABLE_MPI)
Expand All @@ -226,9 +243,17 @@ set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_DEFINITIONS)

# libsc and current project must both be compiled with/without MPI
check_symbol_exists(SC_ENABLE_MPI ${PROJECT_BINARY_DIR}/include/sc_config.h SC_ENABLE_MPI)
check_symbol_exists(SC_ENABLE_MPIIO ${PROJECT_BINARY_DIR}/include/sc_config.h SC_ENABLE_MPIIO)
check_symbol_exists("SC_ENABLE_MPI" ${PROJECT_BINARY_DIR}/include/sc_config.h SC_ENABLE_MPI)
check_symbol_exists("SC_ENABLE_MPIIO" ${PROJECT_BINARY_DIR}/include/sc_config.h SC_ENABLE_MPIIO)

# check consistency of MPI configuration
if(mpi AND NOT (SC_ENABLE_MPI AND SC_ENABLE_MPIIO))
message(FATAL_ERROR "libsc MPI support was requested, but not configured in ${PROJECT_BINARY_DIR}/include/sc_config.h")
endif()

# check consistency of MPI I/O configuration
if(mpi AND (SC_ENABLE_MPI AND NOT SC_ENABLE_MPIIO))
message(WARNING "libsc MPI configured but MPI I/O is not configured/found: DEPRECATED")
message(NOTICE "This configuration is DEPRECATED and will be disallowed in the future.")
message(NOTICE "If the MPI File API is not available, please disable MPI altogether.")
endif()
2 changes: 1 addition & 1 deletion cmake/git.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(PROJECT_MINOR 0)
set(PROJECT_PATCH 0)
set(PROJECT_VERSION 0.0.0)
find_program(GIT_VERSION_GEN NAMES git-version-gen
PATHS ${CMAKE_SOURCE_DIR}/build-aux NO_DEFAULT_PATH)
PATHS ${PROJECT_SOURCE_DIR}/build-aux NO_DEFAULT_PATH)
if(GIT_VERSION_GEN)
execute_process(COMMAND ${GIT_VERSION_GEN} .tarball-version
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
Expand Down
52 changes: 52 additions & 0 deletions cmake/jansson.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
include(ExternalProject)
include(GNUInstallDirs)

set(SC_HAVE_JSON 1 CACHE BOOL "using SC-built JANSSON")

set(jansson_url "https://github.com/akheron/jansson/releases/download/v2.14/jansson-2.14.tar.bz2")

set(JANSSON_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)

if(BUILD_SHARED_LIBS)
if(WIN32)
set(JANSSON_LIBRARIES ${CMAKE_INSTALL_FULL_BINDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}jansson${CMAKE_SHARED_LIBRARY_SUFFIX})
else()
set(JANSSON_LIBRARIES ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}jansson${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
else()
set(JANSSON_LIBRARIES ${CMAKE_INSTALL_FULL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}jansson${CMAKE_STATIC_LIBRARY_SUFFIX})
endif()

set(jansson_cmake_args
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
-DJANSSON_BUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DCMAKE_BUILD_TYPE=Release
-DJANSSON_EXAMPLES:BOOL=off
-DJANSSON_WITHOUT_TESTS:BOOL=on
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)

ExternalProject_Add(JANSSON
URL ${jansson_url}
CMAKE_ARGS ${jansson_cmake_args}
BUILD_BYPRODUCTS ${JANSSON_LIBRARIES}
CONFIGURE_HANDLED_BY_BUILD ON
USES_TERMINAL_DOWNLOAD true
USES_TERMINAL_UPDATE true
USES_TERMINAL_CONFIGURE true
USES_TERMINAL_BUILD true
USES_TERMINAL_INSTALL true
USES_TERMINAL_TEST true
)


# --- imported target

file(MAKE_DIRECTORY ${JANSSON_INCLUDE_DIRS})
# avoid race condition

add_library(jansson::jansson INTERFACE IMPORTED GLOBAL)
add_dependencies(jansson::jansson JANSSON) # to avoid include directory race condition
target_link_libraries(jansson::jansson INTERFACE ${JANSSON_LIBRARIES})
target_include_directories(jansson::jansson INTERFACE ${JANSSON_INCLUDE_DIRS})
2 changes: 2 additions & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
option(mpi "use MPI library" off)
option(openmp "use OpenMP" off)
option(zlib "build ZLIB" off)
option(json "build Jansson" off)

option(SC_BUILD_TESTING "build libsc self-tests" on)
option(TEST_WITH_VALGRIND "run self-tests with valgrind" OFF)
option(BUILD_SHARED_LIBS "build shared libsc")
Expand Down
7 changes: 2 additions & 5 deletions cmake/sc_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,11 @@
#ifndef SC_SIZEOF_LONG
#define SC_SIZEOF_LONG @SC_SIZEOF_LONG@
#endif
#ifndef SC_SIZEOF_LONG_LONG
#define SC_SIZEOF_LONG_LONG @SC_SIZEOF_LONG_LONG@
#endif
#ifndef SC_SIZEOF_UNSIGNED_LONG
#define SC_SIZEOF_UNSIGNED_LONG @SC_SIZEOF_UNSIGNED_LONG@
#endif
#ifndef SC_SIZEOF_UNSIGNED_LONG_LONG
#define SC_SIZEOF_UNSIGNED_LONG_LONG @SC_SIZEOF_UNSIGNED_LONG_LONG@
#ifndef SC_SIZEOF_LONG_LONG
#define SC_SIZEOF_LONG_LONG @SC_SIZEOF_LONG_LONG@
#endif

/* The size of `void *', as computed by sizeof. */
Expand Down
3 changes: 1 addition & 2 deletions cmake/zlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(SC_HAVE_ZLIB 1 CACHE BOOL "using SC-built Zlib")
# default zlib source archive
if (NOT DEFINED SC_BUILD_ZLIB_ARCHIVE_FILE)
if (NOT DEFINED SC_BUILD_ZLIB_VERSION)
set(SC_BUILD_ZLIB_VERSION 2.1.5)
set(SC_BUILD_ZLIB_VERSION 2.1.6)
endif()
set(SC_BUILD_ZLIB_ARCHIVE_FILE https://github.com/zlib-ng/zlib-ng/archive/refs/tags/${SC_BUILD_ZLIB_VERSION}.tar.gz CACHE STRING "zlib source archive (URL or local filepath).")
endif()
Expand Down Expand Up @@ -43,7 +43,6 @@ URL ${SC_BUILD_ZLIB_ARCHIVE_FILE}
CMAKE_ARGS ${zlib_cmake_args}
BUILD_BYPRODUCTS ${ZLIB_LIBRARIES}
CONFIGURE_HANDLED_BY_BUILD ON
INACTIVITY_TIMEOUT 60
USES_TERMINAL_DOWNLOAD true
USES_TERMINAL_UPDATE true
USES_TERMINAL_CONFIGURE true
Expand Down
29 changes: 24 additions & 5 deletions config/sc_include.m4
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

dnl
dnl sc_include.m4 - general custom macros
dnl
dnl This file is part of the SC Library.
Expand All @@ -8,6 +8,18 @@ dnl Copyright (C) 2008,2009 Carsten Burstedde, Lucas Wilcox.

dnl Documentation for macro names: brackets indicate optional arguments

dnl SC_SINGLE_LINE
dnl Print 72 characters '-' without any trailing newline.
AC_DEFUN([SC_SINGLE_LINE],[dnl
------------------------------------------------------------------------dnl
])

dnl SC_DOUBLE_LINE
dnl Print 72 characters '=' without any trailing newline.
AC_DEFUN([SC_DOUBLE_LINE],[dnl
========================================================================dnl
])

dnl SC_VERSION(PREFIX)
dnl Expose major, minor, and point version numbers as CPP defines.
dnl Also creates a makefile variable PACKAGE_PREFIX with value PREFIX.
Expand Down Expand Up @@ -406,9 +418,15 @@ dnl This macro prints messages at the end of the configure run.
dnl
AC_DEFUN([SC_FINAL_MESSAGES],
[
if test "x$HAVE_PKG_MPI" = xyes && test "x$HAVE_PKG_MPIIO" != xyes ; then
AC_MSG_NOTICE([SC_SINGLE_LINE
$1 has been configured --enable-mpi and --disable-mpiio.
This configuration is DEPRECATED and will be disallowed in the future.
If the MPI File API is not available, please configure to --disable-mpi.])
fi
if test "x$$1_HAVE_ZLIB" = x ; then
AC_MSG_NOTICE([- $1 ----------------------------------------------------
We did not find a recent zlib containing the function adler32_combine.
AC_MSG_NOTICE([SC_SINGLE_LINE
$1 did not find a recent zlib containing the function adler32_combine.
This is OK if the following does not matter to you:
- Calling some functions that rely on zlib will abort your program.
These include sc_array_checksum and sc_vtk_write_compressed.
Expand All @@ -417,9 +435,10 @@ This is OK if the following does not matter to you:
You can fix this by compiling a recent zlib and pointing LIBS to it.])
fi
if test "x$$1_HAVE_JSON" = x ; then
AC_MSG_NOTICE([- $1 ----------------------------------------------------
We did not find a JSON library containing json_integer and json_real.
AC_MSG_NOTICE([SC_SINGLE_LINE
$1 did not find a JSON library containing json_integer and json_real.
This means that loading JSON files for option values will fail.
You can fix this by installing the jansson development library.])
fi
AC_MSG_NOTICE([SC_SINGLE_LINE])
])
Loading

0 comments on commit 0c6f654

Please sign in to comment.