Skip to content

Commit

Permalink
Fix FindTPL<tplName>.cmake files and TPL dependencies (TriBITSPub/Tri…
Browse files Browse the repository at this point in the history
…BITS/trilinos#299)

With new TriBITS, *all* FindTPL<tplName>.cmake files must produce
<tplName>::all_libs targets and a <tplName>Config.cmake file.

Also, with the new TriBITS implementation, we took out the sorting of TPLs by
the TPL order.  Therefore, to restore the correct TPL ordering, we need to
tell CMake the ordering between the TPLs.

For now, I am just hacking this by setting the var
<tplName>_LIB_ENABLED_DEPENDENCIES in until we can come up with offical
support in TriBITS for FindTPL<tplName>Dependencies.cmake files.  NOTE: You
get link errors if you don't set these dependencies.

This calls tribits_tpl_find_include_dirs_and_libraries(...) at the end to
create the <tplName>::all_libs target and triggers the generation and install
of the <tplName>Config.cmake file.

For the CUDA-related TPLs, for some reason, calling raw find_library() finds
these libs okay but using the find_library() call inside of
tribits_tpl_find_include_dirs_and_libraries() does not.  I will have to debug
that because these FindTPL<tplName>.cmake files should be about two lines
long.

I tested this on several different Trilinos builds, including a CUDA build on
'vortex'.
  • Loading branch information
bartlettroscoe committed Jun 28, 2022
1 parent f9d943a commit 52b8825
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 22 deletions.
12 changes: 12 additions & 0 deletions TPLsList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,15 @@ TRIBITS_REPOSITORY_DEFINE_TPLS(
# ParMETIS include directories must come before the
# Scotch include directories.
#


# Temp hack for setting up TPL dependencies (until we support
# FindTPL<tplName>Dependencies.cmake files in #63).
advanced_set(LAPACK_LIB_ENABLED_DEPENDENCIES BLAS
CACHE STRING "LAPACK TPL deps")
advanced_set(ParMETIS_LIB_ENABLED_DEPENDENCIES METIS
CACHE STRING "ParMETIS TPL deps")
advanced_set(SuperLUDist_LIB_ENABLED_DEPENDENCIES ParMETIS BLAS
CACHE STRING "SuperLUDist TPL deps")
advanced_set(CUSPARSE_LIB_ENABLED_DEPENDENCIES CUBLAS
CACHE STRING "CUSPARSE TPL deps")
7 changes: 4 additions & 3 deletions cmake/TPLs/FindTPLCUBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ ELSE()
IF(CUDA_cublas_LIBRARY STREQUAL "CUDA_cublas_LIBRARY-NOTFOUND")
MESSAGE(FATAL_ERROR "\nCUBLAS: could not find cublas library.")
ENDIF()
GLOBAL_SET(TPL_CUBLAS_LIBRARY_DIRS)
GLOBAL_SET(TPL_CUBLAS_INCLUDE_DIRS ${TPL_CUDA_INCLUDE_DIRS})
GLOBAL_SET(TPL_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY})
SET(TPL_CUBLAS_LIBRARIES ${CUDA_cublas_LIBRARY})
ENDIF()

tribits_tpl_find_include_dirs_and_libraries(CUBLAS REQUIRED_LIBS_NAMES cublas)

unset(TPL_CUBLAS_LIBRARIES)
7 changes: 4 additions & 3 deletions cmake/TPLs/FindTPLCUSOLVER.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ ELSE()
IF(CUDA_cusolver_LIBRARY STREQUAL "CUDA_cusolver_LIBRARY-NOTFOUND")
MESSAGE(FATAL_ERROR "\nCUSOLVER: could not find cusolver library.")
ENDIF()
GLOBAL_SET(TPL_CUSOLVER_LIBRARY_DIRS)
GLOBAL_SET(TPL_CUSOLVER_INCLUDE_DIRS ${TPL_CUDA_INCLUDE_DIRS})
GLOBAL_SET(TPL_CUSOLVER_LIBRARIES ${CUDA_cusolver_LIBRARY})
SET(TPL_CUSOLVER_LIBRARIES ${CUDA_cusolver_LIBRARY})
ENDIF()

tribits_tpl_find_include_dirs_and_libraries(CUSOLVER REQUIRED_LIBS_NAMES cusparse)

unset(TPL_CUSOLVER_LIBRARIES)
7 changes: 4 additions & 3 deletions cmake/TPLs/FindTPLCUSPARSE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ ELSE()
MESSAGE(FATAL_ERROR "\nCUSPARSE: could not find cuspasre library.")
ENDIF()
ENDIF(CMAKE_VERSION VERSION_LESS "2.8.8")
GLOBAL_SET(TPL_CUSPARSE_LIBRARY_DIRS)
GLOBAL_SET(TPL_CUSPARSE_INCLUDE_DIRS ${TPL_CUDA_INCLUDE_DIRS})
GLOBAL_SET(TPL_CUSPARSE_LIBRARIES ${CUDA_cusparse_LIBRARY})
SET(TPL_CUSPARSE_LIBRARIES ${CUDA_cusparse_LIBRARY})
ENDIF()

tribits_tpl_find_include_dirs_and_libraries(CUSPARSE REQUIRED_LIBS_NAMES cusparse)

unset(TPL_CUSPARSE_LIBRARIES)
4 changes: 1 addition & 3 deletions cmake/TPLs/FindTPLParMETIS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ FUNCTION(CHECK_PARMETIS_HAS_VERSION_4_0_3 VARNAME)
"
)
SET(CMAKE_REQUIRED_INCLUDES ${TPL_ParMETIS_INCLUDE_DIRS})
SET(CMAKE_REQUIRED_LIBRARIES ${TPL_ParMETIS_LIBRARIES})
SET(CMAKE_REQUIRED_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
SET(CMAKE_REQUIRED_LIBRARIES ParMETIS::all_libs)
CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VARNAME})
ENDFUNCTION()

Expand Down
4 changes: 1 addition & 3 deletions cmake/TPLs/FindTPLScotch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ FUNCTION(CHECK_SCOTCH_VERSION_6_0_3 VARNAME)
}
"
)
SET(CMAKE_REQUIRED_INCLUDES ${TPL_Scotch_INCLUDE_DIRS})
SET(CMAKE_REQUIRED_LIBRARIES ${TPL_Scotch_LIBRARIES})
SET(CMAKE_REQUIRED_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
SET(CMAKE_REQUIRED_LIBRARIES Scotch::all_libs)
CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VARNAME})
ENDFUNCTION()

Expand Down
4 changes: 1 addition & 3 deletions cmake/TPLs/FindTPLSuperLU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ int main()
"
)

SET(CMAKE_REQUIRED_INCLUDES ${TPL_SuperLU_INCLUDE_DIRS})
SET(CMAKE_REQUIRED_LIBRARIES ${TPL_SuperLU_LIBRARIES} ${TPL_METIS_LIBRARIES} ${TPL_BLAS_LIBRARIES})
SET(CMAKE_REQUIRED_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
SET(CMAKE_REQUIRED_LIBRARIES SuperLU::all_libs ParMETIS::all_libs BLAS::all_libs)
CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VARNAME})
ENDFUNCTION()

Expand Down
6 changes: 2 additions & 4 deletions cmake/TPLs/FindTPLSuperLUDist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ int main()
"
)

SET(CMAKE_REQUIRED_INCLUDES ${TPL_SuperLUDist_INCLUDE_DIRS})
SET(CMAKE_REQUIRED_LIBRARIES ${TPL_SuperLUDist_LIBRARIES} ${TPL_ParMETIS_LIBRARIES} ${TPL_METIS_LIBRARIES} ${TPL_BLAS_LIBRARIES})
SET(CMAKE_REQUIRED_LIBRARIES SuperLUDist::all_libs ParMETIS::all_libs METIS::all_libs BLAS::all_libs)
SET(CMAKE_REQUIRED_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VARNAME})
ENDFUNCTION()
Expand All @@ -101,8 +100,7 @@ int main()
"
)

SET(CMAKE_REQUIRED_INCLUDES ${TPL_SuperLUDist_INCLUDE_DIRS})
SET(CMAKE_REQUIRED_LIBRARIES ${TPL_SuperLUDist_LIBRARIES} ${TPL_ParMETIS_LIBRARIES} ${TPL_METIS_LIBRARIES} ${TPL_BLAS_LIBRARIES})
SET(CMAKE_REQUIRED_LIBRARIES SuperLUDist::all_libs ParMETIS::all_libs METIS::all_libs BLAS::all_libs)
SET(CMAKE_REQUIRED_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VARNAME})
ENDFUNCTION()
Expand Down

0 comments on commit 52b8825

Please sign in to comment.