Skip to content

Commit 03fc84f

Browse files
committed
Fix compile for trilinos
1 parent 31539bb commit 03fc84f

File tree

3 files changed

+34
-23
lines changed

3 files changed

+34
-23
lines changed

.github/workflows/continuous.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ jobs:
3636
- name: Dependencies (Linux)
3737
if: runner.os == 'Linux'
3838
run: |
39-
sudo apt update
40-
sudo apt -o Acquire::Retries=3 install \
39+
sudo apt-get update
40+
sudo apt-get -o Acquire::Retries=3 install \
4141
libblas-dev \
4242
libglu1-mesa-dev \
4343
xorg-dev \
4444
mpi \
45+
trilinos-dev \
4546
ccache
4647
echo 'CACHE_PATH=~/.ccache' >> "$GITHUB_ENV"
4748

CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ option(POLYSOLVE_WITH_SUPERLU "Enable SuperLU library"
7777
option(POLYSOLVE_WITH_MKL "Enable MKL library" ${POLYSOLVE_NOT_ON_APPLE_SILICON})
7878
option(POLYSOLVE_WITH_CUSOLVER "Enable cuSOLVER library" OFF)
7979
option(POLYSOLVE_WITH_PARDISO "Enable Pardiso library" OFF)
80-
option(POLYSOLVE_WITH_HYPRE "Enable hypre" ON)
80+
option(POLYSOLVE_WITH_HYPRE "Enable hypre" OFF)
8181
option(POLYSOLVE_WITH_AMGCL "Use AMGCL" ON)
8282
option(POLYSOLVE_WITH_SPECTRA "Enable Spectra library" ON)
8383
option(POLYSOLVE_WITH_TRILINOS "Enable Trilinos" ON)
@@ -288,8 +288,12 @@ endif()
288288
# Trilinos
289289
if (POLYSOLVE_WITH_TRILINOS)
290290
include(trilinos)
291-
target_link_libraries(polysolve_linear PUBLIC Trilinos::Trilinos)
292-
target_compile_definitions(polysolve_linear PRIVATE -DPOLYSOLVE_WITH_TRILINOS)
291+
if(TARGET Trilinos::Trilinos)
292+
target_link_libraries(polysolve_linear PUBLIC Trilinos::Trilinos)
293+
target_compile_definitions(polysolve_linear PRIVATE -DPOLYSOLVE_WITH_TRILINOS)
294+
else()
295+
message(WARNING "Trilinos not found, solver will not be available.")
296+
endif()
293297
endif()
294298

295299
# cuSolver solvers

cmake/recipes/trilinos.cmake

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,37 @@ message(STATUS "Third-party: creating target 'Trilinos::Trilinos'")
77
find_package(Trilinos COMPONENTS ML Epetra)
88

99
if(NOT Trilinos_FOUND)
10+
set(POLYSOLVE_WITH_TRILINOS OFF)
1011
message("Trilinos not found.")
1112
endif()
1213

1314
find_package(MPI)
1415

1516
if(NOT MPI_FOUND)
17+
set(POLYSOLVE_WITH_TRILINOS OFF)
1618
message("MPI not found.")
1719
endif()
1820

19-
MESSAGE("\nFound Trilinos! Here are the details: ")
20-
MESSAGE(" Trilinos_DIR = ${Trilinos_DIR}")
21-
MESSAGE(" Trilinos_VERSION = ${Trilinos_VERSION}")
22-
MESSAGE(" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST}")
23-
MESSAGE(" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES} ")
24-
MESSAGE(" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS} ")
25-
MESSAGE(" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}")
26-
MESSAGE(" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}")
27-
MESSAGE(" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}")
28-
MESSAGE("End of Trilinos details\n")
29-
# include(trilinos)
30-
if(TARGET Trilinos::Trilinos)
31-
else()
32-
add_library(trilinos INTERFACE)
33-
add_library(Trilinos::Trilinos ALIAS trilinos)
34-
target_include_directories(trilinos INTERFACE ${Trilinos_INCLUDE_DIRS} )
35-
target_link_libraries(trilinos INTERFACE ${Trilinos_LIBRARIES} )
36-
target_link_libraries(trilinos INTERFACE MPI::MPI_C MPI::MPI_CXX )
21+
if(Trilinos_FOUND)
22+
if(MPI_FOUND)
23+
MESSAGE("\nFound Trilinos! Here are the details: ")
24+
MESSAGE(" Trilinos_DIR = ${Trilinos_DIR}")
25+
MESSAGE(" Trilinos_VERSION = ${Trilinos_VERSION}")
26+
MESSAGE(" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST}")
27+
MESSAGE(" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES} ")
28+
MESSAGE(" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS} ")
29+
MESSAGE(" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}")
30+
MESSAGE(" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}")
31+
MESSAGE(" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}")
32+
MESSAGE("End of Trilinos details\n")
33+
# include(trilinos)
34+
if(TARGET Trilinos::Trilinos)
35+
else()
36+
add_library(trilinos INTERFACE)
37+
add_library(Trilinos::Trilinos ALIAS trilinos)
38+
target_include_directories(trilinos INTERFACE ${Trilinos_INCLUDE_DIRS} )
39+
target_link_libraries(trilinos INTERFACE ${Trilinos_LIBRARIES} )
40+
target_link_libraries(trilinos INTERFACE MPI::MPI_C MPI::MPI_CXX )
41+
endif()
42+
endif()
3743
endif()

0 commit comments

Comments
 (0)