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

CMake improvement for consumption of libsc, p4est and Zlib #295

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
378a3ba
FIXME: define SC_ENABLE_MPI until we use FetchContent
scivision Oct 27, 2023
f933ba9
presets: mpi + clawpack on
scivision Oct 27, 2023
95e6059
always build SC and P4EST
scivision Oct 27, 2023
c8944ab
ForestClaw: use CMAKE_CURRENT_LIST_DIR instead of CMAKE_SOURCE_DIR
scivision Nov 10, 2023
619aa66
cmake: install_prefix check if top level (for git submod use)
scivision Nov 13, 2023
f8aa746
cmake: cleanup compiler options
scivision Dec 22, 2023
3060d5e
cmake: ignore build dir
scivision Dec 22, 2023
24c34a9
FetchContent Git Submodules for P4EST and SC
scivision Dec 22, 2023
15f19e3
sc,p4est: eclairwave submod for Zlib fix
scivision Dec 24, 2023
b792043
workaround for platform w/o libgen.h
scivision Dec 24, 2023
fb96d93
windows getpid include
scivision Dec 24, 2023
4bf9dcf
bugfix: call function with appropriate arguments
scivision Dec 24, 2023
2780d9c
use cburstedde/{p4est,libsc} develop again
scivision Jan 3, 2024
64d1bcd
package: fclaw requires zlib
scivision Jan 3, 2024
92f729e
cmake:config: use check_* from sc,p4est
scivision Jan 3, 2024
69760d1
cmake: refer to sc_enable_mpi
scivision Jan 3, 2024
3cb2b43
cmake:propagate variables from child projects
scivision Jan 3, 2024
968ec74
submodules: p4est, libsc temp use scivision fork
scivision Jan 3, 2024
9c22696
use latest upstream libsc
scivision Jan 5, 2024
f6fd45b
use p4est PR #270
scivision Jan 5, 2024
5783ed2
cmake: remove unused code
scivision Jan 5, 2024
eecc482
cmake: applications => fclaw_applications
scivision Jan 5, 2024
cb06541
p4est: use cbursteede upstream again
scivision Jan 5, 2024
36595c3
thunderegg as Git submodule
scivision Jan 17, 2024
c0f3c0d
p4est/libsc: latest upstream
scivision Jan 30, 2024
60bb0ce
GitSubmodule.cmake correct logic
scivision Jan 30, 2024
ef37645
upstream: p4est, libsc
scivision Feb 9, 2024
80bd9a2
fixup merge
scivision Feb 9, 2024
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
10 changes: 5 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[submodule "sc"]
path = sc
url = https://github.com/cburstedde/libsc.git
# url = [email protected]:cburstedde/libsc.git
url = https://github.com/cburstedde/libsc.git
ignore = dirty

[submodule "p4est"]
path = p4est
url = https://github.com/cburstedde/p4est.git
# url = [email protected]:cburstedde/p4est.git
url = https://github.com/cburstedde/p4est.git
ignore = dirty
[submodule "src/solvers/fc3d_ash3d"]
path = src/solvers/fc3d_ash3d
url = [email protected]:MelodyShih/fc3d_ash3d.git
[submodule "cub"]
path = cub
url = ./cub
[submodule "thunderegg"]
path = thunderegg
url = https://github.com/scivision/thunderegg
66 changes: 18 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
cmake_minimum_required(VERSION 3.14...3.28)
cmake_minimum_required(VERSION 3.15...3.28)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "please use out-of-source build
cmake -Bbuild
")
endif()

include(cmake/GitVersionGen.cmake)

Expand All @@ -13,66 +19,37 @@ include(CTest)

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

file(GENERATE OUTPUT .gitignore CONTENT "*")

set(CMAKE_CXX_STANDARD 17)

# --- user options

include(cmake/options.cmake)
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} install prefix: ${CMAKE_INSTALL_PREFIX} CMake ${CMAKE_VERSION} Toolchain ${CMAKE_TOOLCHAIN_FILE}")

# --- external libs

if(mpi)
find_package(MPI COMPONENTS C CXX REQUIRED)
endif()

if(cudaclaw)
enable_language(CUDA)
set(CMAKE_CUDA_STANDARD 14)
find_package(CUDAToolkit REQUIRED)
endif()

#find_package(LAPACK)
#find_package(BLAS)
find_package(ZLIB)

# --- p4est, sc
include(cmake/GitSubmodule.cmake)

set(CMAKE_FIND_PACKAGE_PREFER_CONFIG true)

if(NOT sc_external)
find_package(SC HINTS ${THUNDEREGG_ROOT} ${P4EST_ROOT})
endif()
if(NOT TARGET SC::SC)
include(cmake/sc.cmake)
endif()


if(NOT p4est_external)
find_package(P4EST HINTS ${THUNDEREGG_ROOT})
endif()
if(NOT TARGET P4EST::P4EST)
include(cmake/p4est.cmake)
endif()


git_submodule(${CMAKE_CURRENT_SOURCE_DIR}/p4est)
add_subdirectory(p4est)

# --- ThunderEgg
if(thunderegg)
if(NOT thunderegg_external)
find_package(ThunderEgg HINTS ${THUNDEREGG_ROOT})
endif()
if(NOT TARGET ThunderEgg::ThunderEgg)
include(cmake/ThunderEgg.cmake)
endif()
endif(thunderegg)

git_submodule(${CMAKE_CURRENT_SOURCE_DIR}/thunderegg)
add_subdirectory(thunderegg)
endif()

if(cudaclaw)
endif(cudaclaw)
# --- configure


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

Expand All @@ -85,8 +62,6 @@ endif(BUILD_TESTING)
# --- ForestClaw
add_subdirectory(src)



# --- Clawpatch
if(clawpatch)

Expand Down Expand Up @@ -154,13 +129,8 @@ include(cmake/install.cmake)


# --- examples
if(applications)
if(fclaw_applications)
add_subdirectory(applications)
endif(applications)
endif()

include(cmake/documentation.cmake)

# --- auto-ignore build directory
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
file(GENERATE OUTPUT .gitignore CONTENT "*")
endif()
59 changes: 5 additions & 54 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
{
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"version": 3,

"configurePresets": [
{
"name": "ci",
"binaryDir": "${sourceDir}/build",
"generator": "Ninja",
"environment": {
"CUDAARCHS": "72",
"CFLAGS": "-DFCLAW_ENABLE_DEBUG",
Expand All @@ -23,17 +17,15 @@
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"mpi": true,
"openmp": true}
"clawpack": true,
"fclaw_applications": false}
},
{
"name": "mac", "inherits": "default",
"displayName": "MacOS",
"description": "MacOS: OpenMP not used",
"cacheVariables": {"openmp": false},
"displayName": "macOS",
"environment": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CC": "gcc-11",
Expand All @@ -42,48 +34,6 @@
"CXXFLAGS": "-DFCLAW_ENABLE_DEBUG",
"FC": "gfortran-11"
}
},
{
"name": "makemac", "inherits": ["make", "mac"],
"displayName": "MacOS with Make",
"description": "MacOS: OpenMP not used, using Make"
},
{
"name": "make", "inherits": "default",
"displayName": "build with GNU Make",
"generator": "Unix Makefiles"
},
{
"name": "makewin", "inherits": "default",
"displayName": "build with GNU Make: Windows",
"generator": "MinGW Makefiles"
},
{
"name": "intel", "inherits": "default",
"displayName": "Intel Classic compiler: Linux/MacOS",
"environment": {
"CC": "icc",
"CXX": "icpc",
"FC": "ifort",
"MPI_ROOT": "$env{I_MPI_ROOT}"
}
},
{
"name": "intelwin", "inherits": "intel",
"displayName": "Intel Classic compiler: Windows",
"environment": {
"CC": "icl",
"CXX": "icl"
}
},
{
"name": "intelnext", "inherits": "intel",
"displayName": "Intel oneAPI LLVM",
"environment": {
"CC": "icx",
"CXX": "icx",
"FC": "ifx"
}
}
],
"buildPresets": [
Expand All @@ -106,6 +56,7 @@
},
"execution": {
"noTestsAction": "error",
"scheduleRandom": true,
"stopOnFailure": false}
}
]
Expand Down
32 changes: 21 additions & 11 deletions cmake/GitSubmodule.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
find_package(Git REQUIRED)

# else it's an offline archive
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/.git)
find_package(Git REQUIRED)
endif()

function(git_submodule dir)
function(git_submodule submod_dir)
# get/update Git submodule directory to CMake, assuming the
# Git submodule directory is a CMake project.

if(NOT EXISTS ${dir}/CMakeLists.txt)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE _err)
# EXISTS, do not use IS_DIRECTORY as in submodule .git is a file not a directory
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/.git)
message(DEBUG "${PROJECT_SOURCE_DIR} is not a Git repository, skipping submodule ${submod_dir}")
return()
endif()

if(EXISTS ${submod_dir}/CMakeLists.txt)
return()
endif()

execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${submod_dir}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE err)

if(NOT _err EQUAL 0)
message(FATAL_ERROR "Could not retrieve Git submodule ${dir}.")
endif()
if(NOT err EQUAL 0)
message(FATAL_ERROR "${submod_dir} Git submodule failed to retrieve.")
endif()

endfunction(git_submodule)
endfunction()
2 changes: 1 addition & 1 deletion cmake/GitVersionGen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ string(REGEX REPLACE "^v" "" FORESTCLAW_FULL_VERSION "${FORESTCLAW_FULL_VERSION}
# Parse the version string into major, minor, and patch variables
string(REGEX MATCHALL "[0-9]+" FORESTCLAW_VERSION_PARTS "${FORESTCLAW_FULL_VERSION}")

# if list size is less than 3, set all verison numbers to 0
# if list size is less than 3, set all version numbers to 0
list(LENGTH FORESTCLAW_VERSION_PARTS FORESTCLAW_VERSION_PARTS_LENGTH)
if(FORESTCLAW_VERSION_PARTS_LENGTH LESS 3)
set(FORESTCLAW_VERSION_PARTS 0 0 0)
Expand Down
63 changes: 0 additions & 63 deletions cmake/Modules/FindFFTW.cmake

This file was deleted.

46 changes: 0 additions & 46 deletions cmake/Modules/FindP4EST.cmake

This file was deleted.

Loading
Loading