Skip to content

Commit

Permalink
Include Scotch when scotchmetis is used
Browse files Browse the repository at this point in the history
  • Loading branch information
lisajulia committed Jul 19, 2024
1 parent e50da9d commit f0183f7
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmake/Modules/FindMETIS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ if (METIS_INCLUDE_DIRS OR METIS_LIBRARY)
# Silently assume version 5, it is >=2024 after all...
set(METIS_API_VERSION "5")
find_package(PTScotch)
# If we use scotchmetis, we need Scotch, which is automatically installed then
find_package(Scotch REQUIRED)
endif()
if (NOT TARGET METIS::METIS)
add_library(METIS::METIS UNKNOWN IMPORTED)
Expand All @@ -86,6 +88,14 @@ if (METIS_INCLUDE_DIRS OR METIS_LIBRARY)
INTERFACE_COMPILE_DEFINITIONS
SCOTCH_METIS_VERSION=${METIS_API_VERSION})
endif()
if(Scotch_FOUND)
set_property(TARGET METIS::METIS APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${SCOTCH_INCLUDE_DIRS})
set_property(TARGET METIS::METIS APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${SCOTCH_LIBRARIES})
else()
message(FATAL_ERROR "Scotch library not found")
endif()
# Force our build system to use the target
set(METIS_LIBRARIES METIS::METIS)
endif()
Expand Down
43 changes: 43 additions & 0 deletions cmake/Modules/FindScotch.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Module that checks whether Scotch is available.
#
# Accepts the following variables:
#
# Sets the following variables:
# SCOTCH_INCLUDE_DIRS: All include directories needed to compile Scotch programs.
# SCOTCH_LIBRARIES: Alle libraries needed to link Scotch programs.
# SCOTCH_FOUND: True if Scotch was found.
#
# Provides the following macros:
#
# find_package(Scotch)

# Search for Scotch includes
find_path(SCOTCH_INCLUDE_DIR scotch.h
PATHS /usr/include /usr/local/include
PATH_SUFFIXES scotch
)

if (SCOTCH_INCLUDE_DIR)
set(SCOTCH_INCLUDE_DIRS ${SCOTCH_INCLUDE_DIR})
endif()

# Search for Scotch libraries
find_library(SCOTCH_LIBRARY NAMES scotch scotch-int32 scotch-int64 scotch-long
PATHS
/usr/lib
/usr/local/lib
)

if (SCOTCH_LIBRARY)
set(SCOTCH_LIBRARIES ${SCOTCH_LIBRARY})
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"Scotch"
DEFAULT_MSG
SCOTCH_INCLUDE_DIRS
SCOTCH_LIBRARIES
)

mark_as_advanced(SCOTCH_INCLUDE_DIRS SCOTCH_LIBRARIES)

0 comments on commit f0183f7

Please sign in to comment.