Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libsc (with updated CMake logic) #256

Merged
merged 26 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
90e8707
Update libsc
cburstedde Oct 27, 2023
5cfc45d
Update libsc to latest develop
cburstedde Nov 16, 2023
e37a2e0
ci:cmake: use presets more
scivision Oct 29, 2023
b30b46f
cmake: don't override runpath.
scivision Oct 29, 2023
a396486
example: restore standalone ability
scivision Nov 1, 2023
33cdc09
remove unused FindP4EST.cmake
scivision Nov 1, 2023
2901b76
install cmake as package for testing
scivision Nov 1, 2023
ec38c3f
switch to new packaging
scivision Nov 1, 2023
a6a0a34
cmake: allow tests to fail rather than fail to build
scivision Nov 1, 2023
f64b882
Cmake: SC describes its own linking needs
scivision Nov 1, 2023
b944ad5
cmake syntax
scivision Nov 1, 2023
3765a51
cmake: simplify compiler flags
scivision Nov 1, 2023
d10b7f3
cmake: set p4est library version
scivision Nov 1, 2023
fb301d0
ci:cmake: reduce fanout
scivision Nov 1, 2023
a43cd90
simplify logic
scivision Nov 1, 2023
594ada9
Test balance: surviving without ZLIB
cburstedde Dec 15, 2023
4be4085
Test valid: surviving without ZLIB
cburstedde Dec 15, 2023
1dcc3ed
Test loadsave: surviving without ZLIB
cburstedde Dec 15, 2023
9f30abf
Test partition: add call to p4est_init
cburstedde Dec 15, 2023
7ea5b69
Test partition: surviving without ZLIB
cburstedde Dec 15, 2023
11d090c
Test balance type: surviving without ZLIB
cburstedde Dec 15, 2023
cafeb66
Test for zlib: conjunct test in p4est and sc
cburstedde Dec 15, 2023
51396a6
Test hash: use size_t in pointer cast
cburstedde Dec 15, 2023
33d24d7
Update libsc to latest develop
cburstedde Dec 15, 2023
364a566
CMake CI: lowercase p4est
cburstedde Dec 15, 2023
9fb982a
Update release notes
cburstedde Dec 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
cd sc
git fetch --tags
# git checkout v2.8.5
git checkout -b test-branch 64a7508885cc6a55895758023e00227a6786111f
git checkout -b test-branch a8a9995240eb51c11dfbadead4473d30eed79883

- name: Run bootstrap script
run: ./bootstrap
Expand Down
95 changes: 75 additions & 20 deletions .github/workflows/ci_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,53 @@ jobs:
strategy:
matrix:
cc: [gcc-9, gcc-10, gcc-11, gcc-12]
shared: [true, false]
shared: [false]
mpi: [mpich]
include:
- cc: gcc
shared: true
mpi: mpich
- cc: gcc
shared: false
mpi: openmpi


env:
CC: ${{ matrix.cc }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: Checkout source code

- name: Install system dependencies
run: |
sudo apt-get update -yq
sudo apt-get install -yq --no-install-recommends \
zlib1g-dev libmpich-dev mpich
sudo apt-get install -yq --no-install-recommends zlib1g-dev lib${{ matrix.mpi }}-dev

- name: CMake configure
run: |
cmake -B build --preset default --install-prefix=${{ runner.temp }} \
-DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }}
run: >-
cmake --preset default
--install-prefix=${{ runner.temp }}
-DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }}

- name: CMake build
run: cmake --build build --parallel
run: cmake --build --preset default

- name: CMake self-tests
run: ctest --test-dir build --preset default
run: ctest --preset default

- name: install p4est CMake package
run: cmake --install build

# standalone examples tests that CMake packaging is correct
- name: CMake configure examples
run: >-
cmake -B example/build -S example
-DCMAKE_PREFIX_PATH:PATH=${{ runner.temp }}
-DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }}

- name: CMake build examples
run: cmake --build example/build --parallel

- name: Create package
if: github.event.action == 'published'
Expand Down Expand Up @@ -83,29 +105,45 @@ jobs:
strategy:
matrix:
cc: [clang, gcc-12]
shared: [true, false]
shared: [false]
include:
- cc: clang
shared: true

env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
CC: ${{ matrix.cc }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: Checkout source code

- name: Install system dependencies
run: brew install open-mpi

- name: CMake configure
run: |
cmake -B build -Dmpi=yes --install-prefix=${{ runner.temp }} \
-DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }}
run: >-
cmake --preset default
--install-prefix=${{ runner.temp }}
-DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }}

- name: CMake build
run: cmake --build build --parallel
run: cmake --build --preset default

- name: CMake self-tests
run: ctest --test-dir build --preset default
run: ctest --preset default

- name: install p4est CMake package
run: cmake --install build

- name: CMake configure examples
run: >-
cmake -B example/build -S example
-DCMAKE_PREFIX_PATH:PATH=${{ runner.temp }}
-DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }}

- name: CMake build examples
run: cmake --build example/build --parallel

- name: Create package
if: github.event.action == 'published'
Expand Down Expand Up @@ -140,17 +178,34 @@ jobs:
CMAKE_GENERATOR: "MinGW Makefiles"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
name: Checkout source code

# Windows MPI is shaky in general on GitHub Actions, so we don't use it
- name: CMake configure without MPI
run: cmake -B build -Dmpi:BOOL=no --install-prefix=${{ runner.temp }} -DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }}
run: >-
cmake --preset default
-Dmpi:BOOL=no
--install-prefix=${{ runner.temp }}
-DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }}

- name: CMake build
run: cmake --build build --parallel
run: cmake --build --preset default

- name: CMake self-tests
run: ctest --test-dir build --preset default
run: ctest --preset default

- name: install p4est CMake package
run: cmake --install build

- name: CMake configure examples
run: >-
cmake -B example/build -S example
-DCMAKE_PREFIX_PATH:PATH=${{ runner.temp }}
-DBUILD_SHARED_LIBS:BOOL=${{ matrix.shared }}

- name: CMake build examples
run: cmake --build example/build --parallel

- name: Create package
if: github.event.action == 'published'
Expand Down
58 changes: 10 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.13...3.24)
cmake_minimum_required(VERSION 3.15...3.28)

include(cmake/git.cmake)

Expand All @@ -10,8 +10,6 @@ VERSION ${PROJECT_VERSION})

include(CTest)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)

# --- user options

include(cmake/options.cmake)
Expand All @@ -22,70 +20,36 @@ message(STATUS "p4est ${PROJECT_VERSION} "

if(mpi)
find_package(MPI COMPONENTS C REQUIRED)
if(NOT MPIEXEC_EXECUTABLE)
message(FATAL_ERROR "MPIEXEC is missing, MPI will not work properly")
endif()
endif()

find_package(ZLIB)

# --- libsc

# when user did not require to build libsc, try to detect it from environment
if(NOT sc_external)
include(cmake/find_sc.cmake)
endif()

# when libsc was really not found in the environment, then build it
if(NOT TARGET SC::SC)
message(STATUS "libsc was not found in environment, so let's built it !")
include(cmake/sc.cmake)

# here we make sure SC_HAVE_JSON is defined:
# - when sc_external is true, we use the same logic as in libsc to find library jansson
# - when libsc is found via find_package (CONFIG mode), this variable is already defined
# in SCConfig.cmake
include(cmake/jansson.cmake)
endif()

include(cmake/sc.cmake)

# --- configure p4est

include(cmake/config.cmake)
include(cmake/compilers.cmake)

target_link_libraries(SC::SC INTERFACE
$<$<BOOL:${MPI_C_FOUND}>:MPI::MPI_C>
$<$<BOOL:${ZLIB_FOUND}>:ZLIB::ZLIB>
$<$<BOOL:${SC_HAVE_JSON}>:jansson::jansson>
$<$<BOOL:${P4EST_NEED_M}>:m>
)

# --- p4est
# p4est is always needed.

add_library(p4est)
set_property(TARGET p4est PROPERTY EXPORT_NAME P4EST)
set_property(TARGET p4est PROPERTY VERSION ${PROJECT_VERSION})
target_include_directories(p4est PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(p4est PUBLIC SC::SC)
target_link_libraries(p4est PUBLIC SC::SC $<$<BOOL:${P4EST_HAVE_WINSOCK2_H}>:${WINSOCK_LIBRARIES}>)

# imported target, for use from FetchContent
add_library(P4EST::P4EST INTERFACE IMPORTED GLOBAL)
target_link_libraries(P4EST::P4EST INTERFACE p4est)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/ ${PROJECT_BINARY_DIR}/include/
DESTINATION include
TYPE INCLUDE
FILES_MATCHING PATTERN "*.h")

install(TARGETS p4est
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
install(TARGETS p4est EXPORT ${PROJECT_NAME}-targets)

#--- p8est

Expand Down Expand Up @@ -115,20 +79,18 @@ endif(BUILD_TESTING)

# --- packaging

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindSC.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindP4EST.cmake
DESTINATION cmake)

include(cmake/pkgconf.cmake)
include(cmake/install.cmake)

# --- build examples
add_subdirectory(example)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
add_subdirectory(example)
endif()

include(FeatureSummary)
add_feature_info(MPI mpi "MPI features of ${PROJECT_NAME}")
add_feature_info(OpenMP openmp "OpenMP features of ${PROJECT_NAME}")
add_feature_info(P6EST enable_p6est "2D-3D p6est")
add_feature_info(P8EST enable_p8est "3D p8est")
add_feature_info(shared BUILD_SHARED_LIBS "Build shared libraries")
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
33 changes: 30 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
{
"version": 3,
"version": 6,

"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"mpi": true,
"openmp": false
"openmp": false,
"CMAKE_COMPILE_WARNING_AS_ERROR": true
}
}
],
"buildPresets": [
{
"name": "default",
"configurePreset": "default"
}
],
"testPresets": [
{
"name": "default",
"configurePreset": "default",
"output": {
"outputOnFailure": true,
"verbosity": "default"
"verbosity": "verbose"
},
"execution": {
"noTestsAction": "error",
Expand All @@ -25,5 +33,24 @@
"timeout": 10
}
}
],
"workflowPresets": [
{
"name": "default",
"steps": [
{
"type": "configure",
"name": "default"
},
{
"type": "build",
"name": "default"
},
{
"type": "test",
"name": "default"
}
]
}
]
}
46 changes: 0 additions & 46 deletions cmake/FindP4EST.cmake

This file was deleted.

Loading