Skip to content
Snippets Groups Projects
Commit e3d1c23d authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

Merge branch 'external-petsc' into 'master'

PETSc as ExternalProject instead of Conan

See merge request ogs/ogs!3686
parents a2a002c2 52e44bcc
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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'
......
......@@ -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)
......
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
......@@ -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
# 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()
......
......@@ -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()
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
)
......
# 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()
......@@ -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)
......
......@@ -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})
......
......@@ -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.
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment