Skip to content

Commit

Permalink
Move check for ParMETS version for Zoltan2 to Zoltan2 (#63)
Browse files Browse the repository at this point in the history
When ParMEITS is found by an upstream cmake project (e.g. KokkosKerenls), the
value of HAVE_PARMETIS_VERSION_4_0_3l does not get written into the
ParMETISConfig.cmake file so Zoltan2 was configuring with an error.  But this
is a check for Zoltan2, not other Trilinos packages anyway so this check
should be in Zoltan2, not in the FindTPLParMETIS.cmake

NOTE: If we want to support exporting various variables into the generated
<tplName>Config.cmake files for TriBITS TPLs generated using
tribits_tpl_find_include_dirs_and_libraries(), then we will need to do some
refactoring in TriBITS to make that possible. But that should not be too hard.
This was just not needed in this case.
  • Loading branch information
bartlettroscoe committed Feb 9, 2023
1 parent b7c3118 commit fd8b701
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 35 deletions.
32 changes: 0 additions & 32 deletions cmake/TPLs/FindTPLParMETIS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,3 @@ TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES( ParMETIS
REQUIRED_HEADERS "parmetis.h;metis.h"
REQUIRED_LIBS_NAMES "parmetis;metis"
)

# Zoltan2 has a dependency on ParMETIS 4.0.3

include(CheckCSourceCompiles)
FUNCTION(CHECK_PARMETIS_HAS_VERSION_4_0_3 VARNAME)
SET(SOURCE
"
#include <stdio.h>
#include <parmetis.h>
int main()
{
#if PARMETIS_MAJOR_VERSION > 4
return 0;
#elif PARMETIS_MAJOR_VERSION == 4 && PARMETIS_MINOR_VERSION > 0
return 0;
#elif PARMETIS_MAJOR_VERSION == 4 && PARMETIS_MINOR_VERSION == 0 && PARMETIS_SUBMINOR_VERSION >= 3
return 0;
#else
parmetis_version_failure
#endif
}
"
)
SET(CMAKE_REQUIRED_LIBRARIES ParMETIS::all_libs)
CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VARNAME})
ENDFUNCTION()

# We can't compile ParMETIS without MPI
IF(TPL_ENABLE_MPI AND TPL_ENABLE_ParMETIS)
CHECK_PARMETIS_HAS_VERSION_4_0_3(HAVE_PARMETIS_VERSION_4_0_3)
ENDIF()
10 changes: 7 additions & 3 deletions packages/zoltan2/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ IF(Zoltan2_ENABLE_ParMETIS AND NOT TPL_ENABLE_MPI)
"Zoltan2_ENABLE_ParMETIS OFF.")
ENDIF()

IF(Zoltan2_ENABLE_ParMETIS AND NOT HAVE_PARMETIS_VERSION_4_0_3)
MESSAGE(FATAL_ERROR "Zoltan2 requires ParMETIS_version 4.0.3 or later. Upgrade"
" or set TPL_ENABLE_ParMETIS OFF or set Zoltan2_ENABLE_ParMETIS OFF.")
IF(Zoltan2_ENABLE_ParMETIS)
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/cmake/Zoltan2CheckParMETISVersion.cmake")
ZOLTAN2_CHECK_PARMETIS_HAS_VERSION_4_0_3(HAVE_PARMETIS_VERSION_4_0_3l)
IF (NOT "${HAVE_PARMETIS_VERSION_4_0_3l}" STREQUAL "1")
MESSAGE(FATAL_ERROR "Zoltan2 requires ParMETIS_version 4.0.3 or later. Upgrade"
" or set TPL_ENABLE_ParMETIS OFF or set Zoltan2_ENABLE_ParMETIS OFF.")
ENDIF()
ENDIF()

IF(Zoltan2_ENABLE_Scotch AND NOT HAVE_SCOTCH_VERSION_6_0_3)
Expand Down
25 changes: 25 additions & 0 deletions packages/zoltan2/core/cmake/Zoltan2CheckParMETISVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
include(CheckCSourceCompiles)

FUNCTION(ZOLTAN2_CHECK_PARMETIS_HAS_VERSION_4_0_3 VARNAME)
SET(SOURCE
"
#include <stdio.h>
#include <parmetis.h>
int main()
{
#if PARMETIS_MAJOR_VERSION > 4
return 0;
#elif PARMETIS_MAJOR_VERSION == 4 && PARMETIS_MINOR_VERSION > 0
return 0;
#elif PARMETIS_MAJOR_VERSION == 4 && PARMETIS_MINOR_VERSION == 0 && PARMETIS_SUBMINOR_VERSION >= 3
return 0;
#else
parmetis_version_failure
#endif
}
"
)
SET(CMAKE_REQUIRED_LIBRARIES ParMETIS::all_libs)
CHECK_C_SOURCE_COMPILES("${SOURCE}" ${VARNAME})
ENDFUNCTION()

0 comments on commit fd8b701

Please sign in to comment.