Skip to content
Snippets Groups Projects
Commit b51a8293 authored by Lars Bilke's avatar Lars Bilke Committed by Dmitry Yu. Naumov
Browse files

[cmake] Moved PETSc dependency to ExternalProject_Add() instead of Conan.

Moved tfel dep to DependenciesExternalProject.cmake
parent 37b3d436
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,7 @@ include(JobPools)
include(Find)
include(CLCacheSetup)
include(packaging/PackagingDependencies)
include(DependenciesExternalProject)
include(Dependencies)
include(DocumentationSetup)
include(test/Test)
......
# 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)
......@@ -164,7 +152,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
......
# 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()
find_package(PETSc ${ogs.minimum_version.petsc})
if(NOT PETSC_FOUND)
set(_configure_opts "")
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 --with-fc=0 --download-f2cblaslapack=1
--prefix=<INSTALL_DIR> --with-debugging=$<CONFIG:Debug>
${_configure_opts}
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()
......@@ -118,27 +118,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)
......
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