Skip to content

Commit

Permalink
Fix compile for trilinos
Browse files Browse the repository at this point in the history
  • Loading branch information
xDarkLemon committed Mar 19, 2024
1 parent 31539bb commit 03fc84f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ jobs:
- name: Dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt -o Acquire::Retries=3 install \
sudo apt-get update
sudo apt-get -o Acquire::Retries=3 install \
libblas-dev \
libglu1-mesa-dev \
xorg-dev \
mpi \
trilinos-dev \
ccache
echo 'CACHE_PATH=~/.ccache' >> "$GITHUB_ENV"
Expand Down
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ option(POLYSOLVE_WITH_SUPERLU "Enable SuperLU library"
option(POLYSOLVE_WITH_MKL "Enable MKL library" ${POLYSOLVE_NOT_ON_APPLE_SILICON})
option(POLYSOLVE_WITH_CUSOLVER "Enable cuSOLVER library" OFF)
option(POLYSOLVE_WITH_PARDISO "Enable Pardiso library" OFF)
option(POLYSOLVE_WITH_HYPRE "Enable hypre" ON)
option(POLYSOLVE_WITH_HYPRE "Enable hypre" OFF)
option(POLYSOLVE_WITH_AMGCL "Use AMGCL" ON)
option(POLYSOLVE_WITH_SPECTRA "Enable Spectra library" ON)
option(POLYSOLVE_WITH_TRILINOS "Enable Trilinos" ON)
Expand Down Expand Up @@ -288,8 +288,12 @@ endif()
# Trilinos
if (POLYSOLVE_WITH_TRILINOS)
include(trilinos)
target_link_libraries(polysolve_linear PUBLIC Trilinos::Trilinos)
target_compile_definitions(polysolve_linear PRIVATE -DPOLYSOLVE_WITH_TRILINOS)
if(TARGET Trilinos::Trilinos)
target_link_libraries(polysolve_linear PUBLIC Trilinos::Trilinos)
target_compile_definitions(polysolve_linear PRIVATE -DPOLYSOLVE_WITH_TRILINOS)
else()
message(WARNING "Trilinos not found, solver will not be available.")
endif()
endif()

# cuSolver solvers
Expand Down
42 changes: 24 additions & 18 deletions cmake/recipes/trilinos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,37 @@ message(STATUS "Third-party: creating target 'Trilinos::Trilinos'")
find_package(Trilinos COMPONENTS ML Epetra)

if(NOT Trilinos_FOUND)
set(POLYSOLVE_WITH_TRILINOS OFF)
message("Trilinos not found.")
endif()

find_package(MPI)

if(NOT MPI_FOUND)
set(POLYSOLVE_WITH_TRILINOS OFF)
message("MPI not found.")
endif()

MESSAGE("\nFound Trilinos! Here are the details: ")
MESSAGE(" Trilinos_DIR = ${Trilinos_DIR}")
MESSAGE(" Trilinos_VERSION = ${Trilinos_VERSION}")
MESSAGE(" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST}")
MESSAGE(" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES} ")
MESSAGE(" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS} ")
MESSAGE(" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}")
MESSAGE(" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}")
MESSAGE(" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}")
MESSAGE("End of Trilinos details\n")
# include(trilinos)
if(TARGET Trilinos::Trilinos)
else()
add_library(trilinos INTERFACE)
add_library(Trilinos::Trilinos ALIAS trilinos)
target_include_directories(trilinos INTERFACE ${Trilinos_INCLUDE_DIRS} )
target_link_libraries(trilinos INTERFACE ${Trilinos_LIBRARIES} )
target_link_libraries(trilinos INTERFACE MPI::MPI_C MPI::MPI_CXX )
if(Trilinos_FOUND)
if(MPI_FOUND)
MESSAGE("\nFound Trilinos! Here are the details: ")
MESSAGE(" Trilinos_DIR = ${Trilinos_DIR}")
MESSAGE(" Trilinos_VERSION = ${Trilinos_VERSION}")
MESSAGE(" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST}")
MESSAGE(" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES} ")
MESSAGE(" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS} ")
MESSAGE(" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}")
MESSAGE(" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}")
MESSAGE(" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}")
MESSAGE("End of Trilinos details\n")
# include(trilinos)
if(TARGET Trilinos::Trilinos)
else()
add_library(trilinos INTERFACE)
add_library(Trilinos::Trilinos ALIAS trilinos)
target_include_directories(trilinos INTERFACE ${Trilinos_INCLUDE_DIRS} )
target_link_libraries(trilinos INTERFACE ${Trilinos_LIBRARIES} )
target_link_libraries(trilinos INTERFACE MPI::MPI_C MPI::MPI_CXX )
endif()
endif()
endif()

0 comments on commit 03fc84f

Please sign in to comment.