FindTrilinos.cmake 3.32 KB
Newer Older
1
# This three lines are left to be similar to Radu, but I do not understand what they do.
Radu Popescu's avatar
Radu Popescu committed
2
3
4
5
set(Trilinos_FOUND TRUE)
set(Trilinos_ERROR_REASONS)
set(Trilinos_ALREADY_CACHED FALSE)

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Here I am looking for TrilinosConfig.cmake and I will import it. 
FIND_PACKAGE(Trilinos PATHS ${Trilinos_ROOT}/include)

# Stop cmake if Trilinos is not found.
IF(NOT Trilinos_FOUND)
  MESSAGE(FATAL_ERROR "Could not find Trilinos!")
ENDIF()

# Here it will be better just to raise a warning or have if(USE_TRILINOS_COMPILERS)
# Make sure to use same compilers and flags as Trilinos
SET(CMAKE_CXX_COMPILER ${Trilinos_CXX_COMPILER} )
SET(CMAKE_C_COMPILER ${Trilinos_C_COMPILER} )
SET(CMAKE_Fortran_COMPILER ${Trilinos_Fortran_COMPILER} )

# Set all the include directories to compile against Trilinos and its dependencies
21
SET (Trilinos_INCLUDE_DIR  ${Trilinos_INCLUDE_DIRS} ${Trilinos_TPL_INCLUDE_DIRS})
22
23
24

# Now we created the list of all the Trilinos libraries and TPL we need to link agaist to
#First I define the directory where Trilinos libs are
25
SET( tmp  "-L${Trilinos_ROOT}/lib") 
26
27
# Then I concatenate all the Trilinos libraries -lXXXX
FOREACH(LIB_FILE ${Trilinos_LIBRARIES})
28
    SET (tmp "${tmp} -l${LIB_FILE}")
29
30
31
32
33
34
35
36
37
ENDFOREACH(LIB_FILE ${Trilinos_LIBRARIES})    
#Finally I set Trilinos_LIBRARIES to be the set of Trilinos libraries plus the other TPL of Trilinos
SET (Trilinos_LIBRARIES ${tmp} ${Trilinos_TPL_LIBRARIES})

#Finally I check that all the Trilinos package we need are present.
#I define all the needed packages
SET( REQUIRED_PACKAGES "amesos;anasazi;aztecoo;belos;epetra;epetraext;ifpack;ml;teuchos;zoltan")
#Now I check if all the required packages are in the list of Trilinos Packages. (This might be done better with a find...)
FOREACH( PACKAGE ${REQUIRED_PACKAGES})
38
39
40
41
42
43
44
45
46
47
48
49
    STRING(TOUPPER ${PACKAGE} UPACK)
    FOREACH(Tpack ${Trilinos_PACKAGE_LIST})
        STRING(TOUPPER ${Tpack} TPACK)
        IF(${UPACK} STREQUAL ${TPACK})
            SET(${UPACK}_FOUND TRUE)
        ENDIF()
    ENDFOREACH(Tpack ${Trilinos_PACKAGE_LIST})
    IF(${UPACK}_FOUND)
        set( HAVE_TRILINOS_${UPACK} TRUE)
    ELSE()
        MESSAGE( FATAL_ERROR "Could not find ${PACKAGE}")
    ENDIF()
50
51
ENDFOREACH(PACKAGE ${REQUIRED_PACKAGES})

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#optional packages
SET( OPTIONAL_PACKAGES "rythmos")
#Now I check if all the required packages are in the list of Trilinos Packages. (This might be done better with a find...)
FOREACH( PACKAGE ${OPTIONAL_PACKAGES})
    STRING(TOUPPER ${PACKAGE} UPACK)
    FOREACH(Tpack ${Trilinos_PACKAGE_LIST})
        STRING(TOUPPER ${Tpack} TPACK)
        IF(${UPACK} STREQUAL ${TPACK})
            SET(${UPACK}_FOUND TRUE)
        ENDIF()
    ENDFOREACH(Tpack ${Trilinos_PACKAGE_LIST})
    IF(${UPACK}_FOUND)
        set( HAVE_TRILINOS_${UPACK} TRUE)
    ELSE()
        MESSAGE( STATUS "Could not find ${PACKAGE}")
    ENDIF()
ENDFOREACH(PACKAGE ${REQUIRED_PACKAGES})

70
#temporary hack to properly set HAVE_NOX_THYRA
71
72
FOREACH(Tpack ${NOX_LIBRARIES})
    IF(${Tpack} STREQUAL "noxthyra")
73
74
        SET(HAVE_NOX_THYRA TRUE)
    ENDIF()
75
ENDFOREACH(Tpack ${NOX_LIBRARIES})
76

77
78
#If XXX is already linked through Trilinos. If so I set the variable XXX_IS_IN_TRILINOS to true
FOREACH(tpl ${Trilinos_TPL_LIST})
79
80
81
82
    STRING(TOUPPER ${tpl} TPL)
    SET(${TPL}_IS_IN_TRILINOS TRUE)
    set (HAVE_${TPL} TRUE)
    MESSAGE( STATUS "Library ${TPL} already included through Trilinos" )
83
ENDFOREACH(tpl ${Trilinos_TPL_LIST})