diff --git a/.gitmodules b/.gitmodules index 1fa62c425..a0404e0a5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,13 +1,10 @@ [submodule "sc"] path = sc - url = https://github.com/cburstedde/libsc.git - # url = git@github.com:cburstedde/libsc.git + url = https://github.com/cburstedde/libsc.git ignore = dirty - [submodule "p4est"] path = p4est - url = https://github.com/cburstedde/p4est.git - # url = git@github.com:cburstedde/p4est.git + url = https://github.com/cburstedde/p4est.git ignore = dirty [submodule "src/solvers/fc3d_ash3d"] path = src/solvers/fc3d_ash3d @@ -15,3 +12,6 @@ [submodule "cub"] path = cub url = ./cub +[submodule "thunderegg"] + path = thunderegg + url = https://github.com/scivision/thunderegg diff --git a/CMakeLists.txt b/CMakeLists.txt index cf4113efc..2f96193f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) @@ -85,8 +62,6 @@ endif(BUILD_TESTING) # --- ForestClaw add_subdirectory(src) - - # --- Clawpatch if(clawpatch) @@ -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() diff --git a/CMakePresets.json b/CMakePresets.json index 767ab018c..a57f49413 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -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", @@ -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", @@ -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": [ @@ -106,6 +56,7 @@ }, "execution": { "noTestsAction": "error", + "scheduleRandom": true, "stopOnFailure": false} } ] diff --git a/cmake/GitSubmodule.cmake b/cmake/GitSubmodule.cmake index 7791a9a83..a26435c79 100644 --- a/cmake/GitSubmodule.cmake +++ b/cmake/GitSubmodule.cmake @@ -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() diff --git a/cmake/GitVersionGen.cmake b/cmake/GitVersionGen.cmake index 8eed1e8b0..814babd66 100644 --- a/cmake/GitVersionGen.cmake +++ b/cmake/GitVersionGen.cmake @@ -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) diff --git a/cmake/Modules/FindFFTW.cmake b/cmake/Modules/FindFFTW.cmake deleted file mode 100644 index e4094643b..000000000 --- a/cmake/Modules/FindFFTW.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# FindFFTW.cmake -# --------------- -# -# Find fftw library -# -# Result Variables -# ---------------- -# -# This module defines the following variables:: -# -# FFTW_FOUND -# FFTW_INCLUDE_DIRS - include directories for p4est -# FFTW_LIBRARIES - link against this library to use p4est -# -# Imported Targets -# ^^^^^^^^^^^^^^^^ -# FFTW::FFTW - -# Check if we can use PkgConfig -find_package(PkgConfig) - -#Determine from PKG -if(PKG_CONFIG_FOUND) - pkg_check_modules( PKG_FFTW QUIET "fftw3" ) -endif(PKG_CONFIG_FOUND) - -if(NOT FFTW_FOUND) - - find_path (FFTW_INCLUDE_DIR - NAMES fftw3.h - DOC "fftw3 header") - - find_library (FFTW_LIBRARY - NAMES fftw3 - DOC "fftw3 library") - - if(FFTW_LIBRARY AND FFTW_INCLUDE_DIR) - set(FFTW_FFTW_FOUND true) - endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args (FFTW - REQUIRED_VARS FFTW_LIBRARY FFTW_INCLUDE_DIR - HANDLE_COMPONENTS) - -endif(NOT FFTW_FOUND) - -if(FFTW_FOUND) - - set(FFTW_INCLUDE_DIRS ${FFTW_INCLUDE_DIR}) - set(FFTW_LIBRARIES ${FFTW_LIBRARY}) - - if(NOT TARGET FFTW::FFTW) - add_library(FFTW::FFTW INTERFACE IMPORTED) - set_target_properties(FFTW::FFTW PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "${FFTW_LIBRARY}" - ) - endif(NOT TARGET FFTW::FFTW) - -endif(FFTW_FOUND) - -mark_as_advanced(FFTW_INCLUDE_DIR FFTW_LIBRARY) \ No newline at end of file diff --git a/cmake/Modules/FindP4EST.cmake b/cmake/Modules/FindP4EST.cmake deleted file mode 100644 index ee297ecd8..000000000 --- a/cmake/Modules/FindP4EST.cmake +++ /dev/null @@ -1,46 +0,0 @@ -# FindP4EST.cmake -# --------------- -# -# Find p4est library -# -# Result Variables -# ---------------- -# -# This module defines the following variables:: -# -# P4EST_FOUND -# P4EST_INCLUDE_DIRS - include directories for p4est -# P4EST_LIBRARIES - link against this library to use p4est -# -# Imported Targets -# ^^^^^^^^^^^^^^^^ -# P4EST::P4EST - - -find_path (P4EST_INCLUDE_DIR - NAMES p4est.h - DOC "p4est header") - -find_library (P4EST_LIBRARY - NAMES p4est - DOC "p4est library") - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args (P4EST - REQUIRED_VARS P4EST_LIBRARY P4EST_INCLUDE_DIR - ) - -if(P4EST_FOUND) - -set(P4EST_INCLUDE_DIRS ${P4EST_INCLUDE_DIR}) -set(P4EST_LIBRARIES ${P4EST_LIBRARY}) - -if(NOT TARGET P4EST::P4EST) - add_library(P4EST::P4EST INTERFACE IMPORTED) - set_property(TARGET P4EST::P4EST PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${P4EST_INCLUDE_DIR}") - set_property(TARGET P4EST::P4EST PROPERTY INTERFACE_LINK_LIBRARIES "${P4EST_LIBRARY}") -endif() - -endif() - -mark_as_advanced(P4EST_INCLUDE_DIR P4EST_LIBRARY) diff --git a/cmake/Modules/FindSC.cmake b/cmake/Modules/FindSC.cmake deleted file mode 100644 index 0fcaecd21..000000000 --- a/cmake/Modules/FindSC.cmake +++ /dev/null @@ -1,84 +0,0 @@ -# FindSC.cmake -# --------------- -# -# Find libsc library -# -# Result Variables -# ---------------- -# -# This module defines the following variables:: -# -# SC_FOUND -# SC_INCLUDE_DIRS - include directories for libsc -# SC_LIBRARIES - link against this library to use libsc -# -# Imported Targets -# ^^^^^^^^^^^^^^^^ -# SC::SC - - -find_path (SC_INCLUDE_DIR -NAMES sc.h -DOC "libsc header" -) - -find_library (SC_LIBRARY -NAMES sc -DOC "libsc library" -) - -if(SC_LIBRARY AND SC_INCLUDE_DIR) - find_file(SC_CONFIG_H - NAMES sc_config.h - NO_DEFAULT_PATH - HINTS ${SC_INCLUDE_DIR} - ) -endif() - -if(SC_CONFIG_H) - set(SC_mpi_ok true) - - # check if libsc was configured in compatible way - include(CheckSymbolExists) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_LIBRARIES) - - # libsc and current project must both be compiled with/without MPI - check_symbol_exists(SC_ENABLE_MPI ${SC_CONFIG_H} SC_has_mpi) - check_symbol_exists(SC_ENABLE_MPIIO ${SC_CONFIG_H} SC_has_mpi_io) - - if(MPI_C_FOUND) - # a sign the current project is using MPI - if(NOT (SC_has_mpi AND SC_has_mpi_io)) - set(SC_mpi_ok false) - endif() - else() - if(SC_has_mpi OR SC_has_mpi_io) - set(SC_mpi_ok false) - endif() - endif() - -endif() - - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args (SC -REQUIRED_VARS SC_LIBRARY SC_INCLUDE_DIR SC_mpi_ok -) - -if(SC_FOUND) - -set(SC_INCLUDE_DIRS ${SC_INCLUDE_DIR}) -set(SC_LIBRARIES ${SC_LIBRARY}) - -if(NOT TARGET SC::SC) - add_library(SC::SC INTERFACE IMPORTED) - - set_property(TARGET SC::SC PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${SC_INCLUDE_DIR}") - set_property(TARGET SC::SC PROPERTY INTERFACE_LINK_LIBRARIES "${SC_LIBRARY}") -endif() - -endif(SC_FOUND) - -mark_as_advanced(SC_INCLUDE_DIR SC_LIBRARY SC_has_mpi SC_has_mpi_io) diff --git a/cmake/ThunderEgg.cmake b/cmake/ThunderEgg.cmake deleted file mode 100644 index 65fb3f03d..000000000 --- a/cmake/ThunderEgg.cmake +++ /dev/null @@ -1,59 +0,0 @@ -# provides imported targets THUNDEREGG::THUNDEREGG, ... -include(ExternalProject) - -set(thunderegg_external true CACHE BOOL "build thunderegg library" FORCE) - -# --- thunderegg externalProject -# this keeps project scopes totally separate, which avoids -# tricky to diagnose behaviors - -if(NOT DEFINED THUNDEREGG_ROOT) - set(THUNDEREGG_ROOT ${CMAKE_INSTALL_PREFIX}) -endif() - -if(BUILD_SHARED_LIBS) - set(THUNDEREGG_LIBRARIES ${THUNDEREGG_ROOT}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}ThunderEgg${CMAKE_SHARED_LIBRARY_SUFFIX}) -else() - set(THUNDEREGG_LIBRARIES ${THUNDEREGG_ROOT}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}ThunderEgg${CMAKE_STATIC_LIBRARY_SUFFIX}) -endif() - -set(THUNDEREGG_INCLUDE_DIRS ${THUNDEREGG_ROOT}/include) - -if(p4est_external) - set(THUNDEREGG_EXTERNAL_PROJECT_DEPENDS "P4EST-install") -endif() - -ExternalProject_Add(ThunderEgg -GIT_REPOSITORY https://github.com/thunderegg/thunderegg -GIT_TAG v1.0.5 -CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${THUNDEREGG_ROOT} -Dmpi:BOOL=${mpi} -Dopenmp:BOOL=${openmp} -Ddisable_petsc:BOOL=true -DP4EST_ROOT=${P4EST_ROOT} -DBUILD_TESTING:BOOL=off -BUILD_BYPRODUCTS ${THUNDEREGG_LIBRARIES} -DEPENDS ${THUNDEREGG_EXTERNAL_PROJECT_DEPENDS} -) - -# --- required libraries -find_package(FFTW REQUIRED) -find_package(BLAS) -find_package(LAPACK) -find_package(MPI COMPONENTS CXX) - -# --- imported target - -file(MAKE_DIRECTORY ${THUNDEREGG_INCLUDE_DIRS}) -# avoid race condition - -# this GLOBAL is required to be visible via other -# project's FetchContent of this project -add_library(ThunderEgg::ThunderEgg STATIC IMPORTED GLOBAL) -target_include_directories(ThunderEgg::ThunderEgg INTERFACE "${THUNDEREGG_INCLUDE_DIRS}") -target_link_libraries(ThunderEgg::ThunderEgg INTERFACE "${THUNDEREGG_LIBRARIES}" P4EST::P4EST) -set_target_properties(ThunderEgg::ThunderEgg PROPERTIES - IMPORTED_LOCATION ${THUNDEREGG_LIBRARIES} - INTERFACE_INCLUDE_DIRECTORIES ${THUNDEREGG_INCLUDE_DIRS} - INTERFACE_LINK_LIBRARIES "FFTW::FFTW;P4EST::P4EST;SC::SC;MPI::MPI_CXX" -) -if(TARGET BLAS::BLAS AND TARGET LAPACK::LAPACK) - target_link_libraries(ThunderEgg::ThunderEgg INTERFACE BLAS::BLAS LAPACK::LAPACK) -endif() - -add_dependencies(ThunderEgg::ThunderEgg ThunderEgg) diff --git a/cmake/compilers.cmake b/cmake/compilers.cmake index 543d74e80..cb5c56ae9 100644 --- a/cmake/compilers.cmake +++ b/cmake/compilers.cmake @@ -1,28 +1,20 @@ -include(CheckCCompilerFlag) - -# --- compiler options - -check_c_compiler_flag(-Wall _has_wall) -if(_has_wall) +if(MSVC) add_compile_options( - $<$:-Wall> - $<$:-Wall> - $<$:-Wall> - ) + "$<$:/W4>" + ) else() - check_c_compiler_flag(/Wall _has_msvc_wall) - if(_has_msvc_wall) - add_compile_options(/Wall) - endif() + add_compile_options( + "$<$:-Wall>" + ) endif() -if ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel") - # something -elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") +if (CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + add_compile_options( + "$<$:-warn>" + ) +elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") add_compile_options( -# $<$:-std=f2003> - $<$:-Wno-unused-dummy-argument> - $<$:-Wno-unused-variable> - $<$:-Wno-unused-label> + "$<$:-Wall>" + "$<$:-Wno-unused-dummy-argument,-Wno-unused-variable,-Wno-unused-label>" ) -endif() \ No newline at end of file +endif() diff --git a/cmake/config.cmake b/cmake/config.cmake index 392cef667..4181c90e9 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -1,5 +1,4 @@ include(CheckIncludeFile) -include(CheckIncludeFiles) include(CheckSymbolExists) # --- generate fclaw_config.h @@ -7,7 +6,11 @@ include(CheckSymbolExists) set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_LIBRARIES) -if(MPI_FOUND) +set(FCLAW_ENABLE_MPI ${P4EST_ENABLE_MPI} CACHE BOOL "Enable MPI support") +set(FCLAW_ENABLE_MPIIO ${P4EST_ENABLE_MPIIO} CACHE BOOL "Enable MPI-IO support") + +if(FCLAW_ENABLE_MPI) + find_package(MPI COMPONENTS C CXX REQUIRED) set(CMAKE_REQUIRED_LIBRARIES MPI::MPI_C) set(FCLAW_CC \"${MPI_C_COMPILER}\") set(FCLAW_CPP ${MPI_C_COMPILER}) @@ -38,17 +41,6 @@ set(FCLAW_LIBS \"${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${ZLIB_LIBRARIES} m\") set(FCLAW_ENABLE_MEMALIGN 1) -if(MPI_FOUND) - set(FCLAW_ENABLE_MPI ${MPI_FOUND}) - set(FCLAW_ENABLE_MPIIO 1) -endif(MPI_FOUND) - -# check_symbol_exists(sqrt math.h FCLAW_NONEED_M) -# if(NOT FCLAW_NONEED_M) -# set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m) -# check_symbol_exists(sqrt math.h FCLAW_NEED_M) -# endif() - check_include_file(fenv.h FCLAW_HAVE_FENV_H) if(FCLAW_HAVE_FENV_H) set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) @@ -56,12 +48,12 @@ if(FCLAW_HAVE_FENV_H) set(CMAKE_REQUIRED_LIBRARIES m) endif() check_symbol_exists(feenableexcept fenv.h FCLAW_HAVE_FEENABLEEXCEPT) - set(CMAKE_REQUIRED_LIBRARIES) endif() -check_include_file(signal.h FCLAW_HAVE_SIGNAL_H) +set(CMAKE_REQUIRED_LIBRARIES) -check_include_file(unistd.h FCLAW_HAVE_UNISTD_H) +set(FCLAW_HAVE_SIGNAL_H ${P4EST_HAVE_SIGNAL_H} CACHE BOOL "Have signal.h") +set(FCLAW_HAVE_UNISTD_H ${P4EST_HAVE_UNISTD_H} CACHE BOOL "Have unistd.h") set(FCLAW_PACKAGE \"${PROJECT_NAME}\") diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in index baa0c2e13..fcc0d98f0 100644 --- a/cmake/config.cmake.in +++ b/cmake/config.cmake.in @@ -4,10 +4,7 @@ include(CMakeFindDependencyMacro) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) -set(mpi @mpi@) -if(mpi) - set(@PROJECT_NAME@_mpi_FOUND TRUE) -endif() +set(@PROJECT_NAME@_ENABLE_MPI @FCLAW_ENABLE_MPI@) set(openmp @openmp@) if(openmp) @@ -39,12 +36,12 @@ if(thunderegg) set(@PROJECT_NAME@_thunderegg_FOUND TRUE) endif() -if(mpi) +if(@PROJECT_NAME@_ENABLE_MPI) find_dependency(MPI REQUIRED) endif() find_dependency(SC REQUIRED) find_dependency(P4EST REQUIRED) -find_dependency(ZLIB) +find_dependency(ZLIB REQUIRED) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") diff --git a/cmake/install.cmake b/cmake/install.cmake index 4fbeafdee..b88fdec29 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -25,8 +25,8 @@ DESTINATION cmake # --- CPack -set(CPACK_GENERATOR "TGZ") -set(CPACK_SOURCE_GENERATOR "TGZ") +set(CPACK_GENERATOR "TBZ2") +set(CPACK_SOURCE_GENERATOR "TBZ2") set(CPACK_PACKAGE_VENDOR "Carsten Burstedde;Donna Calhoun") set(CPACK_PACKAGE_CONTACT "Carsten Burstedde;Donna Calhoun") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") diff --git a/cmake/options.cmake b/cmake/options.cmake index 5fb2a8254..ebcae9df1 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -1,6 +1,5 @@ -option(mpi "use MPI library") option(openmp "use OpenMP") -option(applications "build applications" ON) +option(fclaw_applications "build applications" off) option(clawpatch "build Clawpatch") option(clawpack "build Clawpack") @@ -8,15 +7,21 @@ option(geoclaw "build Geoclaw") option(cudaclaw "build CudaClaw") option(thunderegg "build ThunderEgg") -option(thunderegg_external "force build of ThunderEgg") -option(p4est_external "force build of p4est") -option(sc_external "force build of libsc") +set(mpi true) +# needed by ThunderEgg, P4EST, Libsc -option(CMAKE_TLS_VERIFY "verify HTTPS certs" on) +option(CMAKE_TLS_VERIFY "verify TLS cert" on) # --- default install directory under build/local # users can specify like "cmake -B build -DCMAKE_INSTALL_PREFIX=~/mydir" -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND PROJECT_IS_TOP_LEVEL) +if(CMAKE_VERSION VERSION_LESS 3.21) + get_property(_not_top DIRECTORY PROPERTY PARENT_DIRECTORY) + if(NOT _not_top) + set(FORESTCLAW_IS_TOP_LEVEL true) + endif() +endif() + +if(FORESTCLAW_IS_TOP_LEVEL AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # will not take effect without FORCE set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/local" CACHE PATH "Install top-level directory" FORCE) endif() diff --git a/cmake/p4est.cmake b/cmake/p4est.cmake deleted file mode 100644 index 0a153cf27..000000000 --- a/cmake/p4est.cmake +++ /dev/null @@ -1,51 +0,0 @@ -# provides imported targets P4EST::P4EST, ... -include(ExternalProject) -include(${CMAKE_CURRENT_LIST_DIR}/GitSubmodule.cmake) - -set(p4est_external true CACHE BOOL "build p4est library" FORCE) - -git_submodule("${PROJECT_SOURCE_DIR}/p4est") - -# --- p4est externalProject -# this keeps project scopes totally separate, which avoids -# tricky to diagnose behaviors - -if(NOT DEFINED P4EST_ROOT) - set(P4EST_ROOT ${CMAKE_INSTALL_PREFIX}) -endif() - -if(BUILD_SHARED_LIBS) - set(P4EST_LIBRARIES ${P4EST_ROOT}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}p4est${CMAKE_SHARED_LIBRARY_SUFFIX}) -else() - set(P4EST_LIBRARIES ${P4EST_ROOT}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}p4est${CMAKE_STATIC_LIBRARY_SUFFIX}) -endif() - -set(P4EST_INCLUDE_DIRS ${P4EST_ROOT}/include) - -ExternalProject_Add(P4EST -SOURCE_DIR ${PROJECT_SOURCE_DIR}/p4est -CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${P4EST_ROOT} - -Dmpi:BOOL=${mpi} - -Dopenmp:BOOL=${openmp} - -DSC_ROOT:PATH=${SC_ROOT} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -BUILD_BYPRODUCTS ${P4EST_LIBRARIES} -DEPENDS SC-install -) -ExternalProject_Add_StepTargets(P4EST install) - -# --- imported target - -file(MAKE_DIRECTORY ${P4EST_INCLUDE_DIRS}) -# avoid race condition - -# this GLOBAL is required to be visible via other -# project's FetchContent of this project -add_library(P4EST::P4EST STATIC IMPORTED GLOBAL) -set_target_properties(P4EST::P4EST PROPERTIES - IMPORTED_LOCATION ${P4EST_LIBRARIES} - INTERFACE_INCLUDE_DIRECTORIES ${P4EST_INCLUDE_DIRS} - INTERFACE_LINK_LIBRARIES $ -) - -add_dependencies(P4EST::P4EST P4EST) diff --git a/cmake/sc.cmake b/cmake/sc.cmake deleted file mode 100644 index 42208049a..000000000 --- a/cmake/sc.cmake +++ /dev/null @@ -1,60 +0,0 @@ -# provides imported target SC::SC -include(ExternalProject) -include(${CMAKE_CURRENT_LIST_DIR}/GitSubmodule.cmake) - -set(sc_external true CACHE BOOL "build sc library" FORCE) - -git_submodule("${PROJECT_SOURCE_DIR}/sc") - -# --- libsc externalProject -# this keeps project scopes totally separate, which avoids -# tricky to diagnose behaviors - -if(NOT DEFINED SC_ROOT) - set(SC_ROOT ${CMAKE_INSTALL_PREFIX}) -endif() - -if(BUILD_SHARED_LIBS) - if(WIN32) - set(SC_LIBRARIES ${SC_ROOT}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}sc${CMAKE_SHARED_LIBRARY_SUFFIX}) - else() - set(SC_LIBRARIES ${SC_ROOT}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}sc${CMAKE_SHARED_LIBRARY_SUFFIX}) - endif() -else() - set(SC_LIBRARIES ${SC_ROOT}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}sc${CMAKE_STATIC_LIBRARY_SUFFIX}) -endif() - -set(SC_INCLUDE_DIRS ${SC_ROOT}/include) - -set(cmake_sc_args --DCMAKE_INSTALL_PREFIX:PATH=${SC_ROOT} --DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} --DCMAKE_BUILD_TYPE=Release --DBUILD_TESTING:BOOL=false --Dmpi:BOOL=${mpi} --Dopenmp:BOOL=${openmp} --DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -) - -ExternalProject_Add(SC -SOURCE_DIR ${PROJECT_SOURCE_DIR}/sc -CMAKE_ARGS ${cmake_sc_args} -BUILD_BYPRODUCTS ${SC_LIBRARIES} -) -ExternalProject_Add_StepTargets(SC install) - -# --- imported target - -file(MAKE_DIRECTORY ${SC_INCLUDE_DIRS}) -# avoid race condition - -# this GLOBAL is required to be visible via other -# project's FetchContent of this project -add_library(SC::SC STATIC IMPORTED GLOBAL) -set_target_properties(SC::SC PROPERTIES - IMPORTED_LOCATION ${SC_LIBRARIES} - INTERFACE_INCLUDE_DIRECTORIES ${SC_INCLUDE_DIRS} - INTERFACE_LINK_LIBRARIES $ -) - -add_dependencies(SC::SC SC) diff --git a/p4est b/p4est index fa0bc331c..feeda802f 160000 --- a/p4est +++ b/p4est @@ -1 +1 @@ -Subproject commit fa0bc331cdf6e02c905cef8745ca1ff9a57d4bde +Subproject commit feeda802fa5aecdc6c8bd1ed3ea4e5be785526e5 diff --git a/scripts/ForestClawExternalProject/ForestClawExternalProject.cmake b/scripts/ForestClawExternalProject/ForestClawExternalProject.cmake index 9c5b8564b..28b6f8028 100644 --- a/scripts/ForestClawExternalProject/ForestClawExternalProject.cmake +++ b/scripts/ForestClawExternalProject/ForestClawExternalProject.cmake @@ -39,22 +39,22 @@ function(ForestClawExternalProject_GetTarget) add_library(SC::SC STATIC IMPORTED GLOBAL) list(APPEND FCLAW_IMPORTED_LIBARIES SC::SC) - set_target_properties(SC::SC PROPERTIES + set_target_properties(SC::SC PROPERTIES IMPORTED_LOCATION ${FCLAW_ROOT}/lib/${FCLAW_LIBRARY_PREFIX}sc${FCLAW_LIBRARY_SUFFIX}) target_include_directories(SC::SC INTERFACE ${FCLAW_ROOT}/include) add_library(P4EST::P4EST STATIC IMPORTED GLOBAL) list(APPEND FCLAW_IMPORTED_LIBARIES P4EST::P4EST) - set_target_properties(P4EST::P4EST PROPERTIES + set_target_properties(P4EST::P4EST PROPERTIES IMPORTED_LOCATION ${FCLAW_ROOT}/lib/${FCLAW_LIBRARY_PREFIX}p4est${FCLAW_LIBRARY_SUFFIX}) target_include_directories(P4EST::P4EST INTERFACE ${FCLAW_ROOT}/include) find_package(ZLIB REQUIRED) target_link_libraries(P4EST::P4EST INTERFACE SC::SC ZLIB::ZLIB) - #FORESTCLAW + #FORESTCLAW add_library(FORESTCLAW::FORESTCLAW STATIC IMPORTED GLOBAL) list(APPEND FCLAW_IMPORTED_LIBARIES FORESTCLAW::FORESTCLAW) - set_target_properties(FORESTCLAW::FORESTCLAW PROPERTIES + set_target_properties(FORESTCLAW::FORESTCLAW PROPERTIES IMPORTED_LOCATION ${FCLAW_ROOT}/lib/${FCLAW_LIBRARY_PREFIX}forestclaw${FCLAW_LIBRARY_SUFFIX} IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX;Fortran") target_include_directories(FORESTCLAW::FORESTCLAW INTERFACE ${FCLAW_ROOT}/include) @@ -66,10 +66,10 @@ function(ForestClawExternalProject_GetTarget) endif() - #CLAWPATCH + #CLAWPATCH add_library(FORESTCLAW::CLAWPATCH STATIC IMPORTED GLOBAL) list(APPEND FCLAW_IMPORTED_LIBARIES FORESTCLAW::CLAWPATCH) - set_target_properties(FORESTCLAW::CLAWPATCH PROPERTIES + set_target_properties(FORESTCLAW::CLAWPATCH PROPERTIES IMPORTED_LOCATION ${FCLAW_ROOT}/lib/${FCLAW_LIBRARY_PREFIX}clawpatch${FCLAW_LIBRARY_SUFFIX} IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX;Fortran") target_include_directories(FORESTCLAW::CLAWPATCH INTERFACE ${FCLAW_ROOT}/include) @@ -81,7 +81,7 @@ function(ForestClawExternalProject_GetTarget) #CLAWPACK4.6 add_library(FORESTCLAW::CLAWPACK4.6 STATIC IMPORTED GLOBAL) list(APPEND FCLAW_IMPORTED_LIBARIES FORESTCLAW::CLAWPACK4.6) - set_target_properties(FORESTCLAW::CLAWPACK4.6 PROPERTIES + set_target_properties(FORESTCLAW::CLAWPACK4.6 PROPERTIES IMPORTED_LOCATION ${FCLAW_ROOT}/lib/${FCLAW_LIBRARY_PREFIX}clawpack4.6${FCLAW_LIBRARY_SUFFIX} IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX;Fortran") target_include_directories(FORESTCLAW::CLAWPACK4.6 INTERFACE ${FCLAW_ROOT}/include) @@ -92,7 +92,7 @@ function(ForestClawExternalProject_GetTarget) #CLAWPACK5 add_library(FORESTCLAW::CLAWPACK5 STATIC IMPORTED GLOBAL) list(APPEND FCLAW_IMPORTED_LIBARIES FORESTCLAW::CLAWPACK5) - set_target_properties(FORESTCLAW::CLAWPACK5 PROPERTIES + set_target_properties(FORESTCLAW::CLAWPACK5 PROPERTIES IMPORTED_LOCATION ${FCLAW_ROOT}/lib/${FCLAW_LIBRARY_PREFIX}clawpack5${FCLAW_LIBRARY_SUFFIX} IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX;Fortran") target_include_directories(FORESTCLAW::CLAWPACK5 INTERFACE ${FCLAW_ROOT}/include) @@ -103,7 +103,7 @@ function(ForestClawExternalProject_GetTarget) #CLAWPACK3_46 add_library(FORESTCLAW::CLAWPACK3_46 STATIC IMPORTED GLOBAL) list(APPEND FCLAW_IMPORTED_LIBARIES FORESTCLAW::CLAWPACK3_46) - set_target_properties(FORESTCLAW::CLAWPACK3_46 PROPERTIES + set_target_properties(FORESTCLAW::CLAWPACK3_46 PROPERTIES IMPORTED_LOCATION ${FCLAW_ROOT}/lib/${FCLAW_LIBRARY_PREFIX}clawpack3_46${FCLAW_LIBRARY_SUFFIX} IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX;Fortran") target_include_directories(FORESTCLAW::CLAWPACK3_46 INTERFACE ${FCLAW_ROOT}/include) @@ -116,7 +116,7 @@ function(ForestClawExternalProject_GetTarget) #FC2D_THUNDEREGG add_library(FORESTCLAW::FC2D_THUNDEREGG STATIC IMPORTED GLOBAL) list(APPEND FCLAW_IMPORTED_LIBARIES FORESTCLAW::FC2D_THUNDEREGG) - set_target_properties(FORESTCLAW::FC2D_THUNDEREGG PROPERTIES + set_target_properties(FORESTCLAW::FC2D_THUNDEREGG PROPERTIES IMPORTED_LOCATION ${FCLAW_ROOT}/lib/${FCLAW_LIBRARY_PREFIX}fc2d_thunderegg${FCLAW_LIBRARY_SUFFIX} IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX;Fortran") target_include_directories(FORESTCLAW::FC2D_THUNDEREGG INTERFACE ${FCLAW_ROOT}/include) @@ -126,7 +126,7 @@ function(ForestClawExternalProject_GetTarget) include(ThunderEggExternalProject) ThunderEggExternalProject_GetTarget(COMPONENTS P4EST OPTIONAL_COMPONENTS FFTW) list(APPEND FCLAW_IMPORTED_LIBARIES ThunderEgg::ThunderEgg) - + endif() target_link_libraries(FORESTCLAW::FC2D_THUNDEREGG INTERFACE FORESTCLAW::FORESTCLAW FORESTCLAW::CLAWPATCH ThunderEgg::ThunderEgg) @@ -137,7 +137,7 @@ function(ForestClawExternalProject_GetTarget) #GEOCLAW add_library(FORESTCLAW::GEOCLAW STATIC IMPORTED GLOBAL) list(APPEND FCLAW_IMPORTED_LIBARIES FORESTCLAW::GEOCLAW) - set_target_properties(FORESTCLAW::GEOCLAW PROPERTIES + set_target_properties(FORESTCLAW::GEOCLAW PROPERTIES IMPORTED_LOCATION ${FCLAW_ROOT}/lib/${FCLAW_LIBRARY_PREFIX}geoclaw${FCLAW_LIBRARY_SUFFIX} IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX;Fortran") target_include_directories(FORESTCLAW::GEOCLAW INTERFACE ${FCLAW_ROOT}/include) @@ -150,7 +150,7 @@ function(ForestClawExternalProject_GetTarget) add_library(FORESTCLAW::CUDACLAW STATIC IMPORTED GLOBAL) list(APPEND FCLAW_IMPORTED_LIBARIES FORESTCLAW::CUDACLAW) - set_target_properties(FORESTCLAW::CUDACLAW PROPERTIES + set_target_properties(FORESTCLAW::CUDACLAW PROPERTIES IMPORTED_LOCATION ${FCLAW_ROOT}/lib/${FCLAW_LIBRARY_PREFIX}cudaclaw${FCLAW_LIBRARY_SUFFIX} IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX;Fortran;CUDA" CUDA_SEPARABLE_COMPILATION ON) @@ -195,7 +195,7 @@ endfunction(ForestClawExternalProject_GetTarget) # function(ForestClawExternalProject) include(ExternalProject) - + set(options "") set(one_value_args REPOSITORY TAG) set(multi_value_args COMPONENTS) @@ -224,7 +224,7 @@ function(ForestClawExternalProject) set(FCLAW_INCLUDE_DIRS ${FCLAW_ROOT}/include) - set(FCLAW_CONFIGURE_ARGS -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=${FCLAW_ROOT} -Dapplications=OFF) + set(FCLAW_CONFIGURE_ARGS -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=${FCLAW_ROOT} -Dfclaw_applications=OFF) # --- optional dependent libraries if("mpi" IN_LIST FCLAW_COMPONENTS OR "thunderegg" IN_LIST FCLAW_COMPONENTS) @@ -295,4 +295,4 @@ function(ForestClawExternalProject) add_dependencies(${LIBRARY} ForestClaw) endforeach() -endfunction(ForestClawExternalProject) \ No newline at end of file +endfunction(ForestClawExternalProject) diff --git a/scripts/ForestClawExternalProject/ThunderEggExternalProject.cmake b/scripts/ForestClawExternalProject/ThunderEggExternalProject.cmake index 7b2643cac..a2ba59a64 100644 --- a/scripts/ForestClawExternalProject/ThunderEggExternalProject.cmake +++ b/scripts/ForestClawExternalProject/ThunderEggExternalProject.cmake @@ -64,8 +64,8 @@ function(ThunderEggExternalProject_GetTarget) endif() if("P4EST" IN_LIST THUNDEREGG_COMPONENTS OR "P4EST" IN_LIST THUNDEREGG_OPTIONAL_COMPONENTS) - find_package(P4EST) - find_package(SC) + find_package(P4EST CONFIG) + find_package(SC CONFIG) endif() if(TARGET P4EST::P4EST) @@ -109,7 +109,7 @@ function(ThunderEggExternalProject_GetTarget) # avoid race condition add_library(ThunderEgg::ThunderEgg STATIC IMPORTED GLOBAL) - set_target_properties(ThunderEgg::ThunderEgg PROPERTIES + set_target_properties(ThunderEgg::ThunderEgg PROPERTIES IMPORTED_LOCATION ${THUNDEREGG_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES ${THUNDEREGG_INCLUDE_DIRS} INTERFACE_LINK_LIBRARIES "${THUNDEREGG_DEP_LIBS}" @@ -148,7 +148,7 @@ endfunction(ThunderEggExternalProject_GetTarget) # function(ThunderEggExternalProject) include(ExternalProject) - + set(one_value_args REPOSITORY TAG) set(multi_value_args COMPONENTS OPTIONAL_COMPONENTS) cmake_parse_arguments(THUNDEREGG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN} ) @@ -247,4 +247,4 @@ function(ThunderEggExternalProject) add_dependencies(ThunderEgg::ThunderEgg ThunderEgg) -endfunction(ThunderEggExternalProject) \ No newline at end of file +endfunction(ThunderEggExternalProject) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea7dd71c4..4d061fac9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,11 @@ # we use auxiliary objects for each code language to avoid compiler option mingling # -- c library -add_library(forestclaw_c OBJECT +add_library(forestclaw_c OBJECT forestclaw.c fclaw_convenience.c - fclaw_base.c - fclaw_options.c + fclaw_base.c + fclaw_options.c fclaw_filesystem.cpp fclaw_gauges.c fclaw_package.c @@ -57,10 +57,9 @@ add_library(forestclaw_c OBJECT mappings/fclaw_map_nomap_brick.c ) target_include_directories(forestclaw_c PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_BINARY_DIR}/include patches/clawpatch) -target_link_libraries(forestclaw_c PRIVATE P4EST::P4EST SC::SC) -if(mpi) - target_link_libraries(forestclaw_c PRIVATE MPI::MPI_C) -endif(mpi) +target_link_libraries(forestclaw_c PRIVATE P4EST::P4EST SC::SC +$<$:MPI::MPI_C> +) # -- fortran library add_library(forestclaw_f OBJECT @@ -89,16 +88,15 @@ add_library(forestclaw_f OBJECT # -- put together in final library -add_library(forestclaw) +add_library(forestclaw $ $) set_target_properties(forestclaw PROPERTIES EXPORT_NAME FORESTCLAW) -target_sources(forestclaw PRIVATE $ $) - -target_link_libraries(forestclaw PRIVATE ZLIB::ZLIB) -target_link_libraries(forestclaw PUBLIC P4EST::P4EST SC::SC) -if(mpi) - target_link_libraries(forestclaw PUBLIC MPI::MPI_C INTERFACE MPI::MPI_CXX) -endif(mpi) +target_link_libraries(forestclaw +PUBLIC +P4EST::P4EST SC::SC "$<$:MPI::MPI_C>" +INTERFACE +"$<$:MPI::MPI_CXX>" +) target_include_directories(forestclaw INTERFACE @@ -106,28 +104,28 @@ target_include_directories(forestclaw $ $) -# imported target, for use from FetchContent +# imported target, for use from parent project add_library(FORESTCLAW::FORESTCLAW INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::FORESTCLAW INTERFACE forestclaw) install(FILES forestclaw.h fclaw_convenience.h - fclaw_base.h - fclaw_timer.h - fclaw_package.h + fclaw_base.h + fclaw_timer.h + fclaw_package.h fclaw_packing.h - fclaw_pointer_map.h - fclaw_filesystem.h - fclaw_options.h - fclaw_gauges.h - fclaw_mpi.h - fclaw_math.h + fclaw_pointer_map.h + fclaw_filesystem.h + fclaw_options.h + fclaw_gauges.h + fclaw_mpi.h + fclaw_math.h fclaw_wrap.h - fclaw_include_all.h - fclaw_advance.h - fclaw_elliptic_solver.h - fclaw_farraybox.hpp + fclaw_include_all.h + fclaw_advance.h + fclaw_elliptic_solver.h + fclaw_farraybox.hpp fclaw_global.h fclaw_forestclaw.h fclaw_domain.h @@ -152,10 +150,10 @@ install(FILES fclaw_map_query.h fclaw_map_query_defs.h fclaw_diagnostics.h - forestclaw2d.h - fp_exception_glibc_extension.h - fclaw2d_convenience.h - fclaw2d_defs.h + forestclaw2d.h + fp_exception_glibc_extension.h + fclaw2d_convenience.h + fclaw2d_defs.h fclaw2d_file.h fclaw2d_wrap.h fclaw2d_to_3d.h @@ -164,11 +162,10 @@ install(FILES fclaw3d_defs.h fclaw3d_file.h fclaw3d_wrap.h - DESTINATION include + TYPE INCLUDE ) -install(TARGETS forestclaw - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS forestclaw EXPORT ${PROJECT_NAME}-targets) if(BUILD_TESTING) add_executable(forestclaw.TEST diff --git a/src/fclaw_base.c b/src/fclaw_base.c index c0df4d475..6eef7a374 100644 --- a/src/fclaw_base.c +++ b/src/fclaw_base.c @@ -172,14 +172,14 @@ fclaw_debugf (const char *fmt, ...) static int logging_rank = 0; static const char* logging_prefix = NULL; -void +void fclaw_set_logging_prefix(const char* new_name) { if(new_name == NULL || strcmp(new_name, "") == 0) { logging_prefix=NULL; - } - else + } + else { logging_prefix=new_name; } @@ -209,8 +209,13 @@ log_handler (const char *name, FILE * log_stream, const char *filename, int line char bn[BUFSIZ], *bp; snprintf (bn, BUFSIZ, "%s", filename); +#ifdef SC_HAVE_LIBGEN_H bp = basename (bn); +#else + bp = bn; +#endif fprintf (log_stream, "%s:%d ", bp, lineno); + } fputs (msg, log_stream); @@ -583,11 +588,11 @@ fclaw_app_options_register_core (fclaw_app_t * a, const char *configfile) void fclaw_app_print_options(fclaw_app_t *app) { sc_options_print_summary (fclaw_get_package_id (), - FCLAW_VERBOSITY_ESSENTIAL, app->opt); + FCLAW_VERBOSITY_ESSENTIAL, app->opt); } int get_keys(const char *key, - const sc_keyvalue_entry_type_t type, + const sc_keyvalue_entry_type_t type, void *entry, const void *u) { @@ -668,7 +673,7 @@ check_sections_in_files(fclaw_app_t* a, sc_array_t* filenames){ // if there are keys in an unexpected file, print a warning if(strcmp(filename, ao->configfile) != 0 && iniparser_find_entry(ini, section)) { - fclaw_global_productionf("Unexpected section [%s] was found in file %s.\n", + fclaw_global_productionf("Unexpected section [%s] was found in file %s.\n", section, filename); } } @@ -773,7 +778,7 @@ fclaw_app_options_parse (fclaw_app_t * a, int *first_arg, for(size_t i = 0; i < filenames->elem_count; i++) { const char* filename = *(const char**) sc_array_index(filenames, i); - int retval = sc_options_load (fclaw_package_id, FCLAW_VERBOSITY_ESSENTIAL, + int retval = sc_options_load (fclaw_package_id, FCLAW_VERBOSITY_ESSENTIAL, a->opt, filename); if (retval > 0) { diff --git a/src/fclaw_mpi.c b/src/fclaw_mpi.c index a4b0e077a..98fcf27cb 100644 --- a/src/fclaw_mpi.c +++ b/src/fclaw_mpi.c @@ -26,6 +26,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#ifdef FCLAW_HAVE_UNISTD_H +#include /* getpid */ +#elif defined(_MSC_VER) +#include /* _getpid */ +#endif + /* Functions with C prototypes to use forestclaw from C code */ void diff --git a/src/fortran_source2d/cellave3.f b/src/fortran_source2d/cellave3.f index a927a2beb..90e34d2f1 100644 --- a/src/fortran_source2d/cellave3.f +++ b/src/fortran_source2d/cellave3.f @@ -449,7 +449,7 @@ double precision function fs(s) y = yl + s*(yh - yl) z = zl + s*(zh - zl) - fs = fdisc(blockno,x,y,z) + fs = fdisc(blockno,x,y) end diff --git a/src/patches/clawpatch/CMakeLists.txt b/src/patches/clawpatch/CMakeLists.txt index 6559e5c9c..a4f07f437 100644 --- a/src/patches/clawpatch/CMakeLists.txt +++ b/src/patches/clawpatch/CMakeLists.txt @@ -139,13 +139,12 @@ install(FILES TYPE INCLUDE ) -install(TARGETS clawpatch - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS clawpatch EXPORT ${PROJECT_NAME}-targets) # -- export name -set_target_properties(clawpatch PROPERTIES EXPORT_NAME CLAWPATCH) +set_property(TARGET clawpatch PROPERTY EXPORT_NAME CLAWPATCH) -# -- imported target, for use from FetchContent +# -- imported target, for use from parent project add_library(FORESTCLAW::CLAWPATCH INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::CLAWPATCH INTERFACE clawpatch) diff --git a/src/solvers/fc2d_clawpack4.6/CMakeLists.txt b/src/solvers/fc2d_clawpack4.6/CMakeLists.txt index 6f50e12f3..d3149e7db 100644 --- a/src/solvers/fc2d_clawpack4.6/CMakeLists.txt +++ b/src/solvers/fc2d_clawpack4.6/CMakeLists.txt @@ -41,11 +41,10 @@ install(FILES TYPE INCLUDE ) -install(TARGETS clawpack4.6 - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS clawpack4.6 EXPORT ${PROJECT_NAME}-targets) -# -- imported target, for use from FetchContent +# -- imported target, for use from parent project add_library(FORESTCLAW::CLAWPACK4.6 INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::CLAWPACK4.6 INTERFACE clawpack4.6) diff --git a/src/solvers/fc2d_clawpack5/CMakeLists.txt b/src/solvers/fc2d_clawpack5/CMakeLists.txt index 272a3d820..948ccc0c1 100644 --- a/src/solvers/fc2d_clawpack5/CMakeLists.txt +++ b/src/solvers/fc2d_clawpack5/CMakeLists.txt @@ -41,10 +41,9 @@ install(FILES TYPE INCLUDE ) -install(TARGETS clawpack5 - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS clawpack5 EXPORT ${PROJECT_NAME}-targets) -# imported target, for use from FetchContent +# imported target, for use from parent project add_library(FORESTCLAW::CLAWPACK5 INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::CLAWPACK5 INTERFACE clawpack5) diff --git a/src/solvers/fc2d_cudaclaw/CMakeLists.txt b/src/solvers/fc2d_cudaclaw/CMakeLists.txt index e6e9abac9..7b0b01fc1 100644 --- a/src/solvers/fc2d_cudaclaw/CMakeLists.txt +++ b/src/solvers/fc2d_cudaclaw/CMakeLists.txt @@ -59,10 +59,9 @@ install(FILES TYPE INCLUDE ) -install(TARGETS cudaclaw - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS cudaclaw EXPORT ${PROJECT_NAME}-targets) -# imported target, for use from FetchContent +# imported target, for use from parent project add_library(FORESTCLAW::CUDACLAW INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::CUDACLAW INTERFACE cudaclaw) diff --git a/src/solvers/fc2d_cudaclaw5/CMakeLists.txt b/src/solvers/fc2d_cudaclaw5/CMakeLists.txt index b04d3c446..cb526bb62 100644 --- a/src/solvers/fc2d_cudaclaw5/CMakeLists.txt +++ b/src/solvers/fc2d_cudaclaw5/CMakeLists.txt @@ -54,9 +54,8 @@ install(FILES TYPE INCLUDE ) -install(TARGETS cudaclaw5 - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS cudaclaw5 EXPORT ${PROJECT_NAME}-targets) -# imported target, for use from FetchContent +# imported target, for use from parent project add_library(FORESTCLAW::CUDACLAW5 INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::CUDACLAW5 INTERFACE cudaclaw5) diff --git a/src/solvers/fc2d_dummy/CMakeLists.txt b/src/solvers/fc2d_dummy/CMakeLists.txt index 2fa035b6a..8a52ef760 100644 --- a/src/solvers/fc2d_dummy/CMakeLists.txt +++ b/src/solvers/fc2d_dummy/CMakeLists.txt @@ -18,9 +18,8 @@ install(FILES TYPE INCLUDE ) -install(TARGETS dummy - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS dummy EXPORT ${PROJECT_NAME}-targets) -# imported target, for use from FetchContent +# imported target, for use from parent project add_library(FORESTCLAW::DUMMY INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::DUMMY INTERFACE dummy) diff --git a/src/solvers/fc2d_geoclaw/CMakeLists.txt b/src/solvers/fc2d_geoclaw/CMakeLists.txt index 418638491..cfe2ca3d3 100644 --- a/src/solvers/fc2d_geoclaw/CMakeLists.txt +++ b/src/solvers/fc2d_geoclaw/CMakeLists.txt @@ -84,9 +84,6 @@ install(FILES fc2d_geoclaw_options.h fc2d_geoclaw_fort.h fc2d_geoclaw_gauges_default.h - TYPE INCLUDE -) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/amr_module.mod ${CMAKE_CURRENT_BINARY_DIR}/include/data_storm_module.mod ${CMAKE_CURRENT_BINARY_DIR}/include/fixedgrids_module.mod @@ -102,11 +99,10 @@ install(FILES TYPE INCLUDE ) -install(TARGETS geoclaw - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS geoclaw EXPORT ${PROJECT_NAME}-targets) -# imported target, for use from FetchContent +# imported target, for use from parent project add_library(FORESTCLAW::GEOCLAW INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::GEOCLAW INTERFACE geoclaw) diff --git a/src/solvers/fc2d_thunderegg/CMakeLists.txt b/src/solvers/fc2d_thunderegg/CMakeLists.txt index 34c12c057..188721141 100644 --- a/src/solvers/fc2d_thunderegg/CMakeLists.txt +++ b/src/solvers/fc2d_thunderegg/CMakeLists.txt @@ -48,11 +48,10 @@ install(FILES TYPE INCLUDE ) -install(TARGETS fc2d_thunderegg - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS fc2d_thunderegg EXPORT ${PROJECT_NAME}-targets) -# imported target, for use from FetchContent +# imported target, for use from parent project add_library(FORESTCLAW::FC2D_THUNDEREGG INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::FC2D_THUNDEREGG INTERFACE fc2d_thunderegg) diff --git a/src/solvers/fc3d_clawpack46/CMakeLists.txt b/src/solvers/fc3d_clawpack46/CMakeLists.txt index 42d4555a6..61def49e8 100644 --- a/src/solvers/fc3d_clawpack46/CMakeLists.txt +++ b/src/solvers/fc3d_clawpack46/CMakeLists.txt @@ -41,11 +41,10 @@ install(FILES TYPE INCLUDE ) -install(TARGETS clawpack3_46 - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS clawpack3_46 EXPORT ${PROJECT_NAME}-targets) -# -- imported target, for use from FetchContent +# -- imported target, for use from parent project add_library(FORESTCLAW::CLAWPACK3_46 INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::CLAWPACK3_46 INTERFACE clawpack3_46) diff --git a/src/solvers/fc3d_clawpack5/CMakeLists.txt b/src/solvers/fc3d_clawpack5/CMakeLists.txt index 5d2ebea1d..6649abdb3 100644 --- a/src/solvers/fc3d_clawpack5/CMakeLists.txt +++ b/src/solvers/fc3d_clawpack5/CMakeLists.txt @@ -34,12 +34,11 @@ install(FILES fc3d_clawpack5.h clawpack5_user_fort.h fc3d_clawpack5_options.h - TYPE INCLUDE + TYPE INCLUDE ) -install(TARGETS clawpack5_3d - EXPORT ${PROJECT_NAME}-targets) +install(TARGETS clawpack5_3d EXPORT ${PROJECT_NAME}-targets) -# imported target, for use from FetchContent +# imported target, for use from parent project add_library(FORESTCLAW::CLAWPACK5_3D INTERFACE IMPORTED GLOBAL) target_link_libraries(FORESTCLAW::CLAWPACK5_3D INTERFACE clawpack5_3d) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e05dd61d1..699d54ae3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,16 +10,14 @@ target_include_directories(testutils PUBLIC ${PROJECT_BINARY_DIR}) target_include_directories(testutils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(testutils PUBLIC forestclaw) +target_link_libraries(testutils PUBLIC forestclaw +"$<$:MPI::MPI_C>" +) if(TARGET ThunderEgg::ThunderEgg) target_link_libraries(testutils PUBLIC ThunderEgg::ThunderEgg) endif(TARGET ThunderEgg::ThunderEgg) -if(mpi) - target_link_libraries(testutils PUBLIC MPI::MPI_C) -endif(mpi) - macro(register_unit_tests test_executable) include(CTest) @@ -28,4 +26,4 @@ macro(register_unit_tests test_executable) string(REPLACE "${CMAKE_SOURCE_DIR}/" "" RELATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") doctest_discover_tests(${test_executable} TEST_PREFIX "${RELATIVE_PATH}/${test_executable} --test-case=\"" TEST_SUFFIX "\"" PROPERTIES LABELS "unit_test") -endmacro() \ No newline at end of file +endmacro() diff --git a/thunderegg b/thunderegg new file mode 160000 index 000000000..0664b057d --- /dev/null +++ b/thunderegg @@ -0,0 +1 @@ +Subproject commit 0664b057d4c01830ba5c714e463a1be15bb13ae1