diff --git a/.cmake-format.yaml b/.cmake-format.yaml index 57aa032e4b22cecd65068e0f6da24a50185beb89..acc977940b1681e6c5b578a35a416720c50030d2 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.yaml @@ -6,24 +6,24 @@ format: line_width: 80 lint: disabled_codes: - - "C0301" - - "C0301" # Line to long. - - "C0113" # Missing COMMAND for optional dependencies. + - "C0301" + - "C0301" # Line to long. + - "C0113" # Missing COMMAND for optional dependencies. parse: vartags: - - !!python/tuple - - set_property - - - cmdline + - !!python/tuple + - set_property + - - cmdline additional_commands: ogs_add_library: pargs: nargs: 2+ addtest: pargs: - nargs: '*' + nargs: "*" flags: - - DISABLED + - DISABLED spelling: AddTest kwargs: EXECUTABLE: 1 @@ -41,7 +41,7 @@ parse: DIFF_DATA: pargs: tags: - - cmdline + - cmdline WRAPPER_ARGS: + REQUIREMENTS: + PYTHON_PACKAGES: + @@ -49,9 +49,9 @@ parse: ogstest: pargs: - nargs: '*' + nargs: "*" flags: - - DISABLED + - DISABLED spelling: OgsTest kwargs: PROJECTFILE: 1 @@ -60,9 +60,9 @@ parse: meshtest: pargs: - nargs: '*' + nargs: "*" flags: - - NONE + - NONE spelling: MeshTest kwargs: EXECUTABLE: 1 @@ -76,13 +76,13 @@ parse: DIFF_DATA: pargs: tags: - - cmdline + - cmdline WRAPPER_ARGS: + REQUIREMENTS: + cpmaddpackage: pargs: - nargs: '*' + nargs: "*" flags: [] spelling: CPMAddPackage kwargs: &cpmaddpackagekwargs @@ -112,19 +112,19 @@ parse: OPTIONS: + cpmfindpackage: pargs: - nargs: '*' + nargs: "*" flags: [] spelling: CPMFindPackage kwargs: *cpmaddpackagekwargs cpmdeclarepackage: pargs: - nargs: '*' + nargs: "*" flags: [] spelling: CPMDeclarePackage kwargs: *cpmaddpackagekwargs packageproject: pargs: - nargs: '*' + nargs: "*" flags: [] spelling: packageProject kwargs: @@ -145,3 +145,16 @@ parse: cpmgetpackageversion: pargs: 2 spelling: CPMGetPackageVersion + + buildexternalproject: + pargs: + nargs: "*" + spelling: BuildExternalProject + kwargs: + GIT_REPOSITORY: 1 + GIT_TAG: 1 + CONFIGURE_COMMAND: + + BUILD_COMMAND: + + INSTALL_COMMAND: + + BUILD_IN_SOURCE: 1 + LOG_OUTPUT_ON_FAILURE: 1 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 247ac2619716be2160dcd9195d1bbbb45d34b0e3..d94fa3f4e88fc6a53442e679bf53bfd9621506f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,7 +33,6 @@ include: - local: '/scripts/ci/jobs/build-linux.yml' - local: '/scripts/ci/jobs/build-linux-petsc.yml' - local: '/scripts/ci/jobs/build-linux-frontend.yml' - - local: '/scripts/ci/jobs/build-linux-conan.yml' - local: '/scripts/ci/jobs/build-docs.yml' - local: '/scripts/ci/jobs/build-win.yml' - local: '/scripts/ci/jobs/build-mac.yml' diff --git a/CMakeLists.txt b/CMakeLists.txt index ab1d55500e353444cf2d8549d40236fee240a6b1..f254ad85d301c82e07283cf869da4e6cd7ac7b6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,17 +50,12 @@ if(NOT WIN32 AND OGS_BUILD_SWMM) message(FATAL_ERROR "OGS_BUILD_SWMM requires Windows!") endif() -# Third-party libraries, names come from Conan package names -foreach(lib vtk qt petsc tfel) - set(OGS_LIB_${lib} "Default" CACHE STRING - "Which ${LIB} library should be used?" - ) - set_property(CACHE OGS_LIB_${lib} PROPERTY STRINGS "Default" "System") -endforeach() - if(OGS_USE_PETSC) set(OGS_USE_MPI ON CACHE BOOL "Use MPI" FORCE) endif() +set(OGS_PETSC_CONFIG_OPTIONS "" CACHE STRING + "Additional PETSc configuration options." +) option(OGS_USE_CVODE "Use the Sundials CVODE module?" OFF) option(OGS_BUILD_UTILS "Should the utilities programs be built?" ON) option(OGS_BUILD_TESTING "Should the tests be built?" ON) @@ -78,6 +73,7 @@ include(JobPools) include(Find) include(CLCacheSetup) include(packaging/PackagingDependencies) +include(DependenciesExternalProject) include(Dependencies) include(DocumentationSetup) include(test/Test) @@ -96,10 +92,15 @@ if((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) AND GPROF_PATH) endif() # GCC AND GPROF_PATH option(OGS_BUILD_GUI "Should the Data Explorer be built?" OFF) -option(OGS_NO_EXTERNAL_LIBS "Builds OGS without any external dependencies." OFF) option(OGS_INSITU "Builds OGS with insitu visualization capabilities." OFF) option(OGS_USE_LIS "Use Lis" OFF) option(OGS_USE_PETSC "Use PETSc routines" OFF) +if(OGS_USE_PETSC AND MSVC) + message( + FATAL_ERROR + "OGS_USE_PETSC=ON is not supported on Windows Visual Studio! Use Linux or macOS." + ) +endif() option(OGS_USE_NETCDF "Add NetCDF support." OFF) option(OGS_USE_XDMF "Add Xdmf file IO support" OFF) diff --git a/scripts/ci/jobs/build-linux-conan.yml b/scripts/ci/jobs/build-linux-conan.yml deleted file mode 100644 index 0f76c8928196e226f1a6bd228f425852d55cec42..0000000000000000000000000000000000000000 --- a/scripts/ci/jobs/build-linux-conan.yml +++ /dev/null @@ -1,29 +0,0 @@ -build linux conan: - extends: - - .template-build-linux - - .test-artifacts - - .rules-master-manual - tags: [shell, envinf1-shell] - needs: [meta] - variables: - CMAKE_PRESET: release - CMAKE_ARGS: >- - -DBUILD_SHARED_LIBS=ON - -DOGS_USE_CONAN=AUTO - -DOGS_USE_MFRONT=ON - -DOGS_USE_XDMF=ON - -build linux native: - extends: - - .template-build-linux - - .test-artifacts - tags: [shell, envinf] - needs: [meta] - variables: - CMAKE_PRESET: release - CMAKE_ARGS: >- - -DBUILD_SHARED_LIBS=ON - -DOGS_USE_CONAN=OFF - -DOGS_USE_POETRY=OFF - -DOGS_USE_MFRONT=ON - -DOGS_USE_XDMF=ON diff --git a/scripts/ci/jobs/build-linux.yml b/scripts/ci/jobs/build-linux.yml index 13fb32e26f2cd285340963518db19ad481dd3edc..ff416ff37d16f4964e03000b4642f1270c1c4246 100644 --- a/scripts/ci/jobs/build-linux.yml +++ b/scripts/ci/jobs/build-linux.yml @@ -3,7 +3,7 @@ build linux: extends: - .template-build-linux - .test-artifacts - tags: [ docker ] + tags: [docker] needs: [meta, ci_images] timeout: 2h variables: @@ -23,7 +23,7 @@ linux ctest large: image: $CONTAINER_GCC_IMAGE extends: - .template-build-linux - tags: [ docker, envinf2 ] + tags: [docker, envinf2] needs: [meta, ci_images] rules: - when: manual @@ -43,7 +43,7 @@ build linux (no unity): extends: - .template-build-linux - .test-artifacts - tags: [ docker ] + tags: [docker] needs: [meta, ci_images] timeout: 1h variables: @@ -62,11 +62,26 @@ build linux (no unity): build linux (no deps, no procs): image: $CONTAINER_GCC_IMAGE extends: .template-build-linux - tags: [ docker ] - needs: [ meta, ci_images ] + tags: [docker] + needs: [meta, ci_images] timeout: 1h variables: BUILD_TESTS: "false" BUILD_CTEST: "false" BUILD_PROCESSES: "SteadyStateDiffusion" CMAKE_PRESET: ci-simplest + +build linux native: + extends: + - .template-build-linux + - .test-artifacts + tags: [shell, envinf] + needs: [meta] + variables: + CMAKE_PRESET: release + CMAKE_ARGS: >- + -DBUILD_SHARED_LIBS=ON + -DOGS_USE_CONAN=OFF + -DOGS_USE_POETRY=OFF + -DOGS_USE_MFRONT=ON + -DOGS_USE_XDMF=ON diff --git a/scripts/cmake/BuildExternalProject.cmake b/scripts/cmake/BuildExternalProject.cmake index 45e80d6d85d849dcc453103d929bebf301bf8380..dfae85566f8e2158faf016375bea210375a498e8 100644 --- a/scripts/cmake/BuildExternalProject.cmake +++ b/scripts/cmake/BuildExternalProject.cmake @@ -1,7 +1,7 @@ # Modified from # https://github.com/Sbte/BuildExternalProject/commit/ce1a70996aa538aac17a6faf07db487c3a238838 macro(BuildExternalProject_find_package target) - set(build_dir ${CMAKE_BINARY_DIR}/external/build_${target}) + set(build_dir ${PROJECT_BINARY_DIR}/_ext/${target}) # Set CMake prefix path so we can look there for the module set(_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}) @@ -22,7 +22,7 @@ macro(BuildExternalProject_find_package target) endmacro() function(BuildExternalProject target) - set(build_dir ${CMAKE_BINARY_DIR}/external/build_${target}) + set(build_dir ${PROJECT_BINARY_DIR}/_ext/${target}) message(STATUS "Building ${target}") @@ -64,8 +64,6 @@ function(BuildExternalProject target) BuildExternalProject_configure(${build_dir}) endif() - BuildExternalProject_build(${build_dir}) - message( STATUS "Finished building ${target}. Logs in ${build_dir}/src/${target}-stamp" @@ -80,6 +78,8 @@ function(BuildExternalProject_configure build_dir) if(result) message(FATAL_ERROR "CMake step for external project failed: ${result}") + else() + BuildExternalProject_build(${build_dir}) endif() endfunction() diff --git a/scripts/cmake/ConanSetup.cmake b/scripts/cmake/ConanSetup.cmake index 0e6e7ed38b35abb8a111f8f963028810e01ea047..744bb21a546e7c80a80267a773ff24df33824471 100644 --- a/scripts/cmake/ConanSetup.cmake +++ b/scripts/cmake/ConanSetup.cmake @@ -11,12 +11,7 @@ if(OGS_USE_CONAN_lower STREQUAL "auto" AND POETRY) else() find_program(CONAN_CMD conan) endif() -if(NOT CONAN_CMD - AND (OGS_USE_PETSC - OR OGS_USE_LIS - OR OGS_BUILD_GUI - ) -) +if(NOT CONAN_CMD AND (OGS_USE_LIS OR OGS_BUILD_GUI)) message(WARNING "conan executable not found. Specify CMake option " "OGS_USE_CONAN=auto for automatic installation in the build directory " "OR install it system-wide (https://www.opengeosys.org/docs/devguide/" @@ -37,13 +32,6 @@ set(CONAN_SYSTEM_INCLUDES ON) include(${PROJECT_SOURCE_DIR}/scripts/cmake/conan/conan.cmake) -if(OGS_USE_PETSC) - set(CONAN_REQUIRES ${CONAN_REQUIRES} petsc/${ogs.minimum_version.petsc}@bilke/testing) - if(OGS_CONAN_USE_SYSTEM_OPENMPI) - set(CONAN_OPTIONS ${CONAN_OPTIONS} petsc:skip_install_openmpi=True) - endif() -endif() - if(OGS_USE_LIS) list(APPEND CONAN_OPTIONS lis:with_omp=True) set(CONAN_REQUIRES ${CONAN_REQUIRES} lis/1.7.37@bilke/stable) @@ -93,14 +81,6 @@ endif() conan_check(VERSION ${ogs.minimum_version.conan}) conan_config_install(ITEM ${PROJECT_SOURCE_DIR}/scripts/cmake/conan/config) -message(STATUS "Third-party libraries:") -foreach(LIB ${OGS_LIBS}) - message(STATUS " - OGS_LIB_${LIB} = ${OGS_LIB_${LIB}}") - if("${OGS_LIB_${LIB}}" STREQUAL System) - list(FILTER CONAN_REQUIRES EXCLUDE REGEX ${LIB}) - endif() -endforeach() - set(CONAN_IMPORTS "") if(APPLE) set(CONAN_IMPORTS ${CONAN_IMPORTS} "lib, *.dylib* -> ./lib") @@ -164,7 +144,3 @@ if(NOT ${OGS_CONAN_BUILD} MATCHES "never|always|missing|outdated") message(STATUS "Warning: Resetting CMake variable OGS_CONAN_BUILD to its default value of 'missing'") set(OGS_CONAN_BUILD "missing" CACHE INTERNAL "") endif() - -if(OGS_USE_PETSC) - set(PETSC_DIR ${CONAN_PETSC_ROOT} CACHE INTERNAL "") -endif() diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake index 3fcaecd4cf4e70192be1499d74475eccc20f5567..1109abb8529279fa233fccbbffa82fe6e9b0bca1 100644 --- a/scripts/cmake/Dependencies.cmake +++ b/scripts/cmake/Dependencies.cmake @@ -1,17 +1,3 @@ -include(BuildExternalProject) - -if(OGS_USE_MFRONT) - find_program(MFRONT mfront) - if(NOT MFRONT) - BuildExternalProject( - TFEL GIT_REPOSITORY https://github.com/thelfer/tfel.git GIT_TAG - rliv-${ogs.minimum_version.tfel-rliv} - ) - set(ENV{TFELHOME} ${PROJECT_BINARY_DIR}/external/build_TFEL) - endif() - list(APPEND CMAKE_INSTALL_RPATH $ENV{TFELHOME}/${CMAKE_INSTALL_LIBDIR}) -endif() - set(CMAKE_FOLDER ThirdParty) # ccache @@ -34,6 +20,7 @@ if(OGS_BUILD_TESTING) GITHUB_REPOSITORY google/googletest GIT_TAG 389cb68b87193358358ae87cc56d257fd0d80189 OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt ON" + "BUILD_SHARED_LIBS OFF" EXCLUDE_FROM_ALL YES ) diff --git a/scripts/cmake/DependenciesExternalProject.cmake b/scripts/cmake/DependenciesExternalProject.cmake new file mode 100644 index 0000000000000000000000000000000000000000..a9edd533a348fecb97860964b9bf19a74e058161 --- /dev/null +++ b/scripts/cmake/DependenciesExternalProject.cmake @@ -0,0 +1,62 @@ +# Build dependencies via ExternalProject_Add() at configure time in +# ${PROJECT_BINARY_DIR}/_ext +include(BuildExternalProject) + +if(OGS_USE_MFRONT) + find_program(MFRONT mfront) + if(NOT MFRONT) + BuildExternalProject( + TFEL GIT_REPOSITORY https://github.com/thelfer/tfel.git + GIT_TAG rliv-${ogs.minimum_version.tfel-rliv} + ) + set(ENV{TFELHOME} ${PROJECT_BINARY_DIR}/_ext/TFEL) + endif() + list(APPEND CMAKE_INSTALL_RPATH $ENV{TFELHOME}/${CMAKE_INSTALL_LIBDIR}) +endif() + +if(OGS_USE_PETSC) + # Force CMake to accept a given PETSc configuration in case the failure of + # MPI tests. This may cause the compilation broken. + option(FORCE_PETSC_EXECUTABLE_RUNS + "Force CMake to accept a given PETSc configuration" ON + ) + if(FORCE_PETSC_EXECUTABLE_RUNS) + set(PETSC_EXECUTABLE_RUNS YES) + endif() + + if(NOT OGS_PETSC_CONFIG_OPTIONS) + find_package(PETSc ${ogs.minimum_version.petsc}) + endif() + if(NOT PETSC_FOUND) + set(_configure_opts "") + if(NOT "--download-fc=1" IN_LIST OGS_PETSC_CONFIG_OPTIONS) + list(APPEND _configure_opts --with-fc=0) + endif() + if(ENV{CC}) + list(APPEND _configure_opts --with-cc=$ENV{CC}) + endif() + if(ENV{CXX}) + list(APPEND _configure_opts --with-cxx=$ENV{CXX}) + endif() + BuildExternalProject( + PETSc + LOG_OUTPUT_ON_FAILURE ON + GIT_REPOSITORY https://gitlab.com/petsc/petsc.git + GIT_TAG v${ogs.minimum_version.petsc} + CONFIGURE_COMMAND + ./configure --download-f2cblaslapack=1 --prefix=<INSTALL_DIR> + --with-debugging=$<CONFIG:Debug> ${_configure_opts} + ${OGS_PETSC_CONFIG_OPTIONS} + BUILD_IN_SOURCE ON + BUILD_COMMAND make -j all + INSTALL_COMMAND make -j install + ) + set(PETSC_DIR ${PROJECT_BINARY_DIR}/_ext/PETSc) + find_package(PETSc ${ogs.minimum_version.petsc} REQUIRED) + endif() + + add_library(petsc SHARED IMPORTED) + target_include_directories(petsc INTERFACE ${PETSC_INCLUDES}) + set_target_properties(petsc PROPERTIES IMPORTED_LOCATION ${PETSC_LIBRARIES}) + target_compile_definitions(petsc INTERFACE USE_PETSC) +endif() diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake index faac5224537537f452df9509c46b017b6ea35110..25387f83a50de19fe7a442442e99cb717aecadc8 100644 --- a/scripts/cmake/Find.cmake +++ b/scripts/cmake/Find.cmake @@ -72,11 +72,6 @@ if(OGS_USE_MFRONT) endif() endif() -# Do not search for libs if this option is set -if(OGS_NO_EXTERNAL_LIBS) - return() -endif() # OGS_NO_EXTERNAL_LIBS - find_package(OpenMP) if(OPENMP_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") @@ -118,27 +113,6 @@ if(OGS_USE_MKL) find_package(MKL REQUIRED) endif() -if(OGS_USE_PETSC) - message(STATUS "Configuring for PETSc") - - option(FORCE_PETSC_EXECUTABLE_RUNS - "Force CMake to accept a given PETSc configuration" ON - ) - - # Force CMake to accept a given PETSc configuration in case the failure of - # MPI tests. This may cause the compilation broken. - if(FORCE_PETSC_EXECUTABLE_RUNS) - set(PETSC_EXECUTABLE_RUNS YES) - endif() - - find_package(PETSc ${ogs.minimum_version.petsc} REQUIRED) - - add_library(petsc SHARED IMPORTED) - target_include_directories(petsc INTERFACE ${PETSC_INCLUDES}) - set_target_properties(petsc PROPERTIES IMPORTED_LOCATION ${PETSC_LIBRARIES}) - target_compile_definitions(petsc INTERFACE USE_PETSC) -endif() - # Check MPI package if(OGS_USE_MPI) find_package(MPI REQUIRED) diff --git a/scripts/cmake/jedbrown/FindPETSc.cmake b/scripts/cmake/jedbrown/FindPETSc.cmake index 7fb969e138eb3475ae81a107514ccd4afc959ae0..3e2a99045844218a944a7acdaeb875ec4625e8a6 100644 --- a/scripts/cmake/jedbrown/FindPETSc.cmake +++ b/scripts/cmake/jedbrown/FindPETSc.cmake @@ -101,6 +101,7 @@ if (PETSC_DIR AND NOT PETSC_ARCH) set (_petsc_arches $ENV{PETSC_ARCH} # If set, use environment variable first linux-gnu-c-debug linux-gnu-c-opt # Debian defaults + arch-darwin-c-debug arch-darwin-c-opt x86_64-unknown-linux-gnu i386-unknown-linux-gnu) set (petscconf "NOTFOUND" CACHE FILEPATH "Cleared" FORCE) foreach (arch ${_petsc_arches}) diff --git a/web/content/docs/devguide/advanced/configuration-options.md b/web/content/docs/devguide/advanced/configuration-options.md index 317a5fb1cdfb46b368cb11cc7899df88b3f9065f..72aeb6dc3e11ab5c4ea1aa21cccf91843cc48122 100644 --- a/web/content/docs/devguide/advanced/configuration-options.md +++ b/web/content/docs/devguide/advanced/configuration-options.md @@ -21,7 +21,6 @@ CMake switches to enable / disable parts of OGS. - `OGS_BUILD_GUI` - Builds the Data Explorer. *Defaults* to *OFF*. - `OGS_BUILD_TESTING` - Builds the test executables. *Defaults* to *ON*. - `OGS_BUILD_UTILS` - Builds several utilities. -- `OGS_NO_EXTERNAL_LIBS` - Disables all external optional dependencies. - `OGS_BUILD_PROCESS_X` - For enabling/disabling compilation of process `X`. Run the CMake-Gui to see a list of processes. - `OGS_BUILD_PROCESSES` - A `;`-separated list specifying processes to build. *Defaults* to an *empty string*. This will alter the `OGS_BUILD_PROCESS_X`-options. For e.g. building just the two processes `HT` and `LIE`: `-DOGS_BUILD_PROCESSES="HT;LIE"`. Setting this variable back to an empty string **does not reset** the `OGS_BUILD_PROCESS_X`-options. You can also set it to *OFF* to disable all processes. diff --git a/web/content/docs/devguide/getting-started/prerequisites.md b/web/content/docs/devguide/getting-started/prerequisites.md index df23c5c9ca940c107ddcfb0ee62b60ef9621be91..c1e1e0eed26966f0981256c859c8d69f8697cf00 100644 --- a/web/content/docs/devguide/getting-started/prerequisites.md +++ b/web/content/docs/devguide/getting-started/prerequisites.md @@ -273,8 +273,6 @@ Make sure that `ninja` is in the path afterwards. See Conan install instructions You only need Conan if you intend to build with one of the following settings **and** do not want to install their dependencies manually: -- `OGS_USE_PETSC` – For parallel processing, requires PETSc -- `OGS_USE_MFRONT` – MFront material models, requires tfel - `OGS_BUILD_GUI` – Builds the Data Explorer, requires Qt - `OGS_USE_NETCDF` – NetCDF IO, requires netcdf-cxx