@@ -3,30 +3,6 @@ option(ALIEN_TRILINOS_UNIT_TESTS "Enable Trilinos wrapper tests" ${ALIEN_UNIT_TE
33
44find_package (MPI REQUIRED)
55
6-
7- # ----------------------------------------------------------------------------
8- find_package (Trilinos 13 REQUIRED COMPONENTS Teuchos Kokkos KokkosKernels Belos Tpetra Ifpack2)
9-
10- # Echo trilinos build info just for fun
11- MESSAGE ("\n Found Trilinos! Here are the details: " )
12- MESSAGE (" Trilinos_DIR = ${Trilinos_DIR} " )
13- MESSAGE (" Trilinos_VERSION = ${Trilinos_VERSION} " )
14- MESSAGE (" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST} " )
15- MESSAGE (" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES} " )
16- MESSAGE (" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS} " )
17- MESSAGE (" Trilinos_LIBRARY_DIRS = ${Trilinos_LIBRARY_DIRS} " )
18- MESSAGE (" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST} " )
19- MESSAGE (" Trilinos_TPL_INCLUDE_DIRS = ${Trilinos_TPL_INCLUDE_DIRS} " )
20- MESSAGE (" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES} " )
21- MESSAGE (" Trilinos_TPL_LIBRARY_DIRS = ${Trilinos_TPL_LIBRARY_DIRS} " )
22- MESSAGE (" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS} " )
23- MESSAGE ("End of Trilinos details\n " )
24-
25- # Make sure to use same compilers and flags as Trilinos
26- #MESSAGE(" Trilinos_CXX_COMPILER_FLAGS = ${Trilinos_CXX_COMPILER_FLAGS}")
27- string (REPLACE " " ";" Trilinos_CXX_COMPILER_FLAGS ${Trilinos_CXX_COMPILER_FLAGS} )
28-
29- # ----------------------------------------------------------------------------
306# ----------------------------------------------------------------------------
317
328add_library (trilinos_wrapper
@@ -46,26 +22,69 @@ add_library(trilinos_wrapper
4622 src/trilinos_config.cpp
4723 )
4824
49- set_property (TARGET trilinos_wrapper
50- APPEND_STRING
51- PROPERTY
52- COMPILE_OPTIONS ${Trilinos_CXX_COMPILER_FLAGS}
53- )
54-
5525target_link_libraries (trilinos_wrapper PUBLIC
5626 Alien::alien_core
5727 )
5828
29+ # ----------------------------------------------------------------------------
30+ find_package (Trilinos 13 REQUIRED COMPONENTS Teuchos Kokkos KokkosKernels Belos Tpetra Ifpack2 MueLu)
31+
32+ if (NOT TARGET Trilinos::all_selected_libs)
33+ # Newer versions of Trilinos should define this target.
34+
35+ # Echo trilinos build info just for fun
36+ MESSAGE ("\n Found Trilinos! Here are the details: " )
37+ MESSAGE (" Trilinos_DIR = ${Trilinos_DIR} " )
38+ MESSAGE (" Trilinos_VERSION = ${Trilinos_VERSION} " )
39+ MESSAGE (" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST} " )
40+ MESSAGE (" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES} " )
41+ MESSAGE (" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS} " )
42+ MESSAGE (" Trilinos_LIBRARY_DIRS = ${Trilinos_LIBRARY_DIRS} " )
43+ MESSAGE (" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST} " )
44+ MESSAGE (" Trilinos_TPL_INCLUDE_DIRS = ${Trilinos_TPL_INCLUDE_DIRS} " )
45+ MESSAGE (" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES} " )
46+ MESSAGE (" Trilinos_TPL_LIBRARY_DIRS = ${Trilinos_TPL_LIBRARY_DIRS} " )
47+ MESSAGE (" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS} " )
48+ MESSAGE ("End of Trilinos details\n " )
49+
50+ # Make sure to use same compilers and flags as Trilinos
51+ #MESSAGE(" Trilinos_CXX_COMPILER_FLAGS = ${Trilinos_CXX_COMPILER_FLAGS}")
52+ string (REPLACE " " ";" Trilinos_CXX_COMPILER_FLAGS ${Trilinos_CXX_COMPILER_FLAGS} )
53+ add_library (Trilinos::all_selected_libs INTERFACE IMPORTED )
54+ target_compile_options (Trilinos::all_selected_libs INTERFACE ${Trilinos_CXX_COMPILER_FLAGS} )
55+ target_include_directories (Trilinos::all_selected_libs INTERFACE ${Trilinos_INCLUDE_DIRS} ${TRILINOS_TPL_INCLUDE_DIRS} )
56+ target_link_libraries (Trilinos::all_selected_libs INTERFACE ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES} )
57+
58+ if (NOT TARGET Kokkos::kokkos)
59+ add_library (Kokkos::kokkos INTERFACE IMPORTED )
60+ else ()
61+ # Debian and Ubuntu packaging is bugged, INTERFACE_INCLUDE_DIRECTORIES referencing a /usr/lib/include directory
62+ get_target_property (KOKKOS_INC_DIRS Kokkos::kokkos INTERFACE_INCLUDE_DIRECTORIES )
63+ set (NEW_KOKKOS_INC_DIRS)
64+ foreach (INC_DIR ${KOKKOS_INC_DIRS} )
65+ MESSAGE (STATUS "INC_DIR = ${INC_DIR} " )
66+ if (EXISTS ${INC_DIR} )
67+ LIST (APPEND NEW_KOKKOS_INC_DIRS ${INC_DIR} )
68+ endif ()
69+ endforeach ()
70+ set_target_properties (Kokkos::kokkos PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${NEW_KOKKOS_INC_DIRS} " )
71+ endif ()
72+ else ()
73+ kokkos_compilation(TARGET trilinos_wrapper)
74+ endif ()
75+
76+ # ----------------------------------------------------------------------------
77+
5978target_link_libraries (trilinos_wrapper PRIVATE
6079 MPI::MPI_CXX
6180 Arccore::arccore_trace
6281 Arccore::arccore_collections
6382 Arccore::arccore_base
6483 Arccore::arccore_message_passing_mpi
65- ${Trilinos_LIBRARIES}
66- ${Trilinos_TPL_LIBRARIES}
84+ Trilinos::all_selected_libs Kokkos::kokkos
6785 )
6886
87+
6988if (ALIEN_PLUGIN_TRILINOS_OMP)
7089 message ("------ COMPILING TRILINOS WRAPPER WITH *OPENMP* BACKEND ------- " )
7190elseif (ALIEN_PLUGIN_TRILINOS_CUDA)
@@ -91,8 +110,6 @@ target_include_directories(trilinos_wrapper PUBLIC
91110 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >
92111 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR} /include >
93112 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR} >
94- ${Trilinos_INCLUDE_DIRS}
95- ${Trilinos_TPL_INCLUDE_DIRS}
96113 )
97114
98115add_library (Alien::trilinos_wrapper ALIAS trilinos_wrapper)
0 commit comments