Commit 1b060987 authored by uvilla's avatar uvilla Committed by Antonio Cervone
Browse files

Try to use TrilinosConfig.cmake to configure LifeV.

I still need to lifeconfig.h, but it is easy ;)
parent 23dcf273
......@@ -29,6 +29,7 @@ set (SuperLU_ROOT "SuperLU_ROOT-NOTFOUND" CACHE PATH "Location of SuperLU")
set (SuperLUMT_ROOT "SuperLUMT_ROOT-NOTFOUND" CACHE PATH "Location of SuperLUMT")
set (SuperLUDist_ROOT "SuperLUDist_ROOT-NOTFOUND" CACHE PATH "Location of SuperLUDist")
set (BOOST_ROOT "BOOST_ROOT-NOTFOUND" CACHE PATH "Location of Boost")
set (Trilinos_ROOT "Trilinos_ROOT-NOTFOUND" CACHE PATH "Location of Trilinos")
set (BLAS_LIBRARIES "BLAS_LIBRARIES-NOTFOUND" CACHE STRING "BLAS libraries")
set (LAPACK_LIBRARIES "LAPACK_LIBRARIES-NOTFOUND" CACHE STRING "LAPACK libraries")
......@@ -88,50 +89,24 @@ if (NOT LIFE_USE_MPI_WRAPPER)
endif()
# Trilinos
find_package (Trilinos COMPONENTS anasazi belos ml ifpack aztecoo amesos zoltan epetraext teuchos epetra REQUIRED)
find_package (Trilinos REQUIRED)
if (Trilinos_FOUND)
if (Trilinos_amesos_FOUND)
set (HAVE_TRILINOS_AMESOS TRUE)
endif()
if (Trilinos_anasazi_FOUND)
set (HAVE_TRILINOS_ANASAZI TRUE)
endif()
if (Trilinos_aztecoo_FOUND)
set (HAVE_TRILINOS_AZTECOO TRUE)
endif()
if (Trilinos_belos_FOUND)
set (HAVE_TRILINOS_BELOS TRUE)
endif()
if (Trilinos_epetra_FOUND)
set (HAVE_TRILINOS_EPETRA TRUE)
endif()
if (Trilinos_epetraext_FOUND)
set (HAVE_TRILINOS_EPETRAEXT TRUE)
endif()
if (Trilinos_ifpack_FOUND)
set (HAVE_TRILINOS_IFPACK TRUE)
endif()
if (Trilinos_ml_FOUND)
set (HAVE_TRILINOS_ML TRUE)
endif()
if (Trilinos_teuchos_FOUND)
set (HAVE_TRILINOS_TEUCHOS TRUE)
endif()
if (Trilinos_zoltan_FOUND)
set (HAVE_TRILINOS_ZOLTAN TRUE)
endif()
include_directories (${Trilinos_INCLUDE_DIR})
set (LIBS ${LIBS} ${Trilinos_LIBRARIES})
endif()
# ParMETIS
if( NOT PARMETIS_IS_IN_TRILINOS)
find_package (PARMETIS REQUIRED)
if (PARMETIS_FOUND)
include_directories (${PARMETIS_INCLUDE_DIR})
set (LIBS ${LIBS} ${PARMETIS_LIBRARIES})
endif()
endif()
#FIXME I need to put the set(HAVE_XXX TRUE) outside the NOT XXXX_IS_IN_TRILINOS if
# UMFPACK (optional)
if( NOT UMFPACK_IS_IN_TRILINOS)
if (LIFE_USE_UMFPACK)
find_package (UMFPACK)
if (UMFPACK_FOUND)
......@@ -142,8 +117,10 @@ if (LIFE_USE_UMFPACK)
set (LIBS ${LIBS} ${UMFPACK_LIBRARIES})
endif()
endif(LIFE_USE_UMFPACK)
endif()
# SuperLU (optional)
if( NOT SUPERLU_IS_IN_TRILINOS)
if (LIFE_USE_SuperLU)
find_package (SuperLU)
if (SuperLU_FOUND)
......@@ -152,8 +129,10 @@ if (LIFE_USE_SuperLU)
set (LIBS ${LIBS} ${SuperLU_LIBRARIES})
endif()
endif(LIFE_USE_SuperLU)
endif()
# SuperLUMT (optional)
if (NOT SUPERLUMT_IS_IN_TRILINOS)
if (LIFE_USE_SuperLUMT)
find_package (SuperLUMT)
if (SuperLUMT_FOUND)
......@@ -162,8 +141,10 @@ if (LIFE_USE_SuperLUMT)
set (LIBS ${LIBS} ${SuperLUMT_LIBRARIES})
endif()
endif(LIFE_USE_SuperLUMT)
endif()
# SuperLUDist (optional)
if (NOT SUPERLUDIST_IS_IN_TRILINOS)
if (LIFE_USE_SuperLUDist)
find_package (SuperLUDist)
if (SuperLUDist_FOUND)
......@@ -172,22 +153,28 @@ if (LIFE_USE_SuperLUDist)
set (LIBS ${LIBS} ${SuperLUDist_LIBRARIES})
endif()
endif(LIFE_USE_SuperLUDist)
endif()
# LAPACK
if (NOT LAPACK_IS_IN_TRILINOS)
find_package (LAPACK REQUIRED)
if (LAPACK_FOUND)
include_directories (${LAPACK_INCLUDE_DIR})
set (LIBS ${LIBS} ${LAPACK_LIBRARIES})
endif()
endif()
# BLAS
if (NOT BLAS_IS_IN_TRILINOS)
find_package (BLAS REQUIRED)
if (BLAS_FOUND)
include_directories (${BLAS_INCLUDE_DIR})
set (LIBS ${LIBS} ${BLAS_LIBRARIES})
endif()
endif()
# HDF5 (optional)
if (NOT HDF5_IS_IN_TRILINOS)
if (LIFE_USE_HDF5)
if (HDF5_ROOT)
set (HDF5_INCLUDE_DIRS ${HDF5_ROOT}/include)
......@@ -202,6 +189,7 @@ if (LIFE_USE_HDF5)
set (LIBS ${LIBS} ${HDF5_LIBRARIES})
endif()
endif(LIFE_USE_HDF5)
endif()
# Boost
find_package (Boost REQUIRED)
......
# Find Trilinos library
#
# Example:
# find_package( Trilinos COMPONENTS epetra aztecoo )
# if(Trilinos_FOUND)
# include_directories(${Trilinos_INCLUDE_DIR})
# add_executable(foo foo.cc)
# target_link_libraries(foo ${Trilinos_LIBRARIES})
# endif()
# if(Trilinos_epetra_FOUND)
# include_directories(${Trilinos_INCLUDE_DIR})
# add_executable(bar bar.cc)
# target_link_libraries(bar ${Trilinos_epetra_LIBRARY})
# endif()
#
#### Optional input variables:
# Trilinos_ROOT Hint the directory with lib and include
#
#### RESULTS:
#
# Trilinos_INCLUDE_DIR Where to find the Trilinos header files
# Trilinos_LIBRARIES Libraries to link against to use Trilinos.
# Trilinos_FOUND Found all of the requested Trilinos packages
#
# Trilinos_${COMPONENT}_FOUND Found a specific package library
# Trilinos_${COMPONENT}_LIBRARY Library path for a specific package
# Trilinos_vecLib_FRAMEWORK Command to link against the vecLib framework
# (needed for mac)
macro(__TRILINOS_PRINT_STATUS)
message(STATUS "=========== TRILINOS STATUS ===============
Trilinos_FOUND ${Trilinos_FOUND}
Trilinos_ALREADY_CACHED ${Trilinos_ALREADY_CACHED}
Trilinos_LIBRARIES ${Trilinos_LIBRARIES}
Trilinos_INCLUDE_DIR ${Trilinos_INCLUDE_DIR}
Trilinos_epetra_FOUND ${Trilinos_epetra_FOUND}
Trilinos_epetra_LIBRARY ${Trilinos_epetra_LIBRARY}
Trilinos_vecLib_FRAMEWORK ${Trilinos_vecLib_FRAMEWORK}
============================================
"
)
endmacro(__TRILINOS_PRINT_STATUS)
# This three lines are left to be similar to Radu, but I do not understand what they do.
set(Trilinos_FOUND TRUE)
set(Trilinos_ERROR_REASONS)
set(Trilinos_ALREADY_CACHED FALSE)
find_path(Trilinos_INCLUDE_DIR "Epetra_config.h"
HINTS "${Trilinos_ROOT}/include"
)
if(Trilinos_INCLUDE_DIR)
set(Trilinos_ALREADY_CACHED TRUE)
mark_as_advanced(Trilinos_INCLUDE_DIR)
else(Trilinos_INCLUDE_DIR)
# we don't even know the include directory, so we have to find the library
# for sure
set(Trilinos_FOUND FALSE)
list(APPEND Trilinos_ERROR_REASONS
"Include directory not found." )
endif(Trilinos_INCLUDE_DIR)
#__TRILINOS_PRINT_STATUS()
# verify that in addition to the include directory, we have all the desired
# library components cached
if(Trilinos_ALREADY_CACHED)
foreach(COMPONENT ${Trilinos_FIND_COMPONENTS})
if(Trilinos_${COMPONENT}_LIBRARY)
set(Trilinos_${COMPONENT}_FOUND TRUE)
else(Trilinos_${COMPONENT}_LIBRARY)
set(Trilinos_ALREADY_CACHED FALSE)
set(Trilinos_${COMPONENT}_FOUND FALSE)
endif(Trilinos_${COMPONENT}_LIBRARY)
endforeach(COMPONENT)
endif(Trilinos_ALREADY_CACHED)
if(Trilinos_ALREADY_CACHED)
#message(STATUS "All Trilinos headers and required components "
# "(${Trilinos_FIND_COMPONENTS}) were found in the cache.")
else(Trilinos_ALREADY_CACHED)
##### Trilinos was not in the cache. We have to search for it ourselves. #####
##### Detailed lookup of each component
foreach(COMPONENT ${Trilinos_FIND_COMPONENTS})
set(LIBVAR "Trilinos_${COMPONENT}_LIBRARY")
message(STATUS "Looking for Trilinos component ${COMPONENT}")
find_library(${LIBVAR}
NAMES ${COMPONENT}
HINTS "${Trilinos_INCLUDE_DIR}/../lib"
"${Trilinos_ROOT}/lib"
)
set(Trilinos_${COMPONENT}_FOUND TRUE)
if(${LIBVAR} )
mark_as_advanced(${LIBVAR})
else(${LIBVAR} )
set(Trilinos_${COMPONENT}_FOUND FALSE)
set(Trilinos_FOUND FALSE)
list(APPEND Trilinos_ERROR_REASONS
"Library component ${COMPONENT} not found." )
endif(${LIBVAR} )
endforeach(COMPONENT)
# On mac systems, we likely have to link against the vecLib framework
if(APPLE AND NOT Trilinos_vecLib_FRAMEWORK)
include(CMakeFindFrameworks)
CMAKE_FIND_FRAMEWORKS(vecLib)
if(vecLib_FRAMEWORKS)
set(
Trilinos_vecLib_FRAMEWORK ${vecLib_FRAMEWORKS}
CACHE PATH "Path to vecLib framework"
)
mark_as_advanced(Trilinos_vecLib_FRAMEWORK)
else(vecLib_FRAMEWORKS)
set(Trilinos_FOUND FALSE)
list(APPEND Trilinos_ERROR_REASONS
"vecLib framework not found." )
endif(vecLib_FRAMEWORKS)
endif(APPLE AND NOT Trilinos_vecLib_FRAMEWORK)
endif(Trilinos_ALREADY_CACHED)
# build Trilinos_LIBRARIES
foreach(COMPONENT ${Trilinos_FIND_COMPONENTS})
set(LIBVAR "Trilinos_${COMPONENT}_LIBRARY")
list(APPEND Trilinos_LIBRARIES ${${LIBVAR}})
endforeach(COMPONENT)
if(APPLE)
list(APPEND Trilinos_LIBRARIES "-framework vecLib")
endif(APPLE)
##__TRILINOS_PRINT_STATUS()
## Final result: see if we found it, error if appropriate
# (this is mostly duplicated by FIND_PACKAGE_HANDLE_STANDARD_ARGS )
if(Trilinos_FOUND)
if(NOT Trilinos_FIND_QUIETLY AND NOT Trilinos_ALREADY_CACHED)
message(STATUS "Found the following Trilinos libraries:")
foreach ( COMPONENT ${Trilinos_FIND_COMPONENTS} )
message (STATUS " ${COMPONENT}")
endforeach(COMPONENT)
endif(NOT Trilinos_FIND_QUIETLY AND NOT Trilinos_ALREADY_CACHED)
if(Trilinos_ROOT STREQUAL "Trilinos-NOTFOUND")
message(STATUS "clearing Trilinos_ROOT")
# clear trilinos_ROOT if the user didn't end up using it
unset( Trilinos_ROOT CACHE)
endif(Trilinos_ROOT STREQUAL "Trilinos-NOTFOUND")
else (Trilinos_FOUND)
if(Trilinos_FIND_REQUIRED)
set(THE_ERROR_MESSAGE "Unable to find the requested Trilinos libraries:")
foreach( REASON ${Trilinos_ERROR_REASONS})
set(THE_ERROR_MESSAGE "${THE_ERROR_MESSAGE}\n + ${REASON}")
endforeach(REASON)
message(SEND_ERROR "${THE_ERROR_MESSAGE}\n"
"** Try setting the Trilinos_ROOT variable and re-configuring. **")
set(
Trilinos_ROOT "Trilinos-NOTFOUND"
CACHE PATH "Path to Trilinos base"
)
endif(Trilinos_FIND_REQUIRED)
endif(Trilinos_FOUND)
# 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
SET (Trilinos_INCLUDE_DIR ${Trilinos_DIR} ${Trilinos_TPL_INCLUDE_DIRS})
# 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
SET( tmp "-L${Trilinos_ROOT}/lib")
# Then I concatenate all the Trilinos libraries -lXXXX
FOREACH(LIB_FILE ${Trilinos_LIBRARIES})
SET (tmp "${tmp} -l${LIB_FILE}")
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})
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()
ENDFOREACH(PACKAGE ${REQUIRED_PACKAGES})
#If XXX is already linked through Trilinos. If so I set the variable XXX_IS_IN_TRILINOS to true
FOREACH(tpl ${Trilinos_TPL_LIST})
STRING(TOUPPER ${tpl} TPL)
SET(${TPL}_IS_IN_TRILINOS TRUE)
MESSAGE( "Library ${TPL} already included through Trilinos" )
ENDFOREACH(tpl ${Trilinos_TPL_LIST})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment