Skip to content

Commit

Permalink
Ifpack2: Remove tribtits_add_option_and_define() calls for vars TriBI…
Browse files Browse the repository at this point in the history
…TS automatically sets (trilinos#10355, trilinos#11583)

The updated funtion tribits_add_option_and_define(<optionName> <defineName>
...) will error out if a local non-cache var of the same name <defineName>
already exists.  As explained in the TriBITS Users Guide, for all dependencies
listed in the package's Dependencies.cmake file, TriBITS automatically defines
and sets the vars:

* <Package>_ENABLE_<UpstreamDepPkg>: Cache var and/or non-cache local project-level var

* HAVE_<PACKAGE>_<UPSTREAMDEPPKG>: Non-cache local project-level var

The function tribits_add_option_and_define(<optionName> <defineName> ...)
creates an INTERNAL cache var with the name <defineName>.  (This was done
because some Trilinos packages communicated info through these <defineName>
vars for some reason.)

With new behavior in CMake 3.21+ with policy CMP0126, setting the INTERNAL
cache var <defineName> no longer resets the local var of the same name.
Therefore, the function tribits_add_option_and_define(<optionName>
<defineName> ...) has no impact and does not change anything that impacts
behavior.  Also, since TriBITS automatically defines documented cache vars
with the name <Package>_ENABLE_<UpstreamDepPkg>, the statement
set(<optionName> <value> CACHE BOOL ...) does not have any effect because the
cache var is already set.  Therefore, these calls to:

tribits_add_option_and_define(<Package>_ENABLE_<UpstreamDepPkg>
  HAVE_<PACKAGE>_<UPSTREAMDEPPKG> ...)

have no impact and just confused behavior.  (But were actually masking a nasty
defect described in trilinos#11583 after updating the CMake minimum version to 3.23.)

This commit also adds a formal optional dependency on MPI to replace the
option Ifpack2_ENABLE_MPI and the macro define var HAVE_IFPACK2_MPI that are
defined automatically by TriBITS.
  • Loading branch information
bartlettroscoe committed Feb 23, 2023
1 parent a896f07 commit c57865a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
19 changes: 0 additions & 19 deletions packages/ifpack2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,6 @@ TRIBITS_ADD_ETI_SUPPORT()
#This replaces an option that was reusing an existing name.
SET(HAVE_${PACKAGE_NAME_UC}_QD "${PACKAGE_NAME}_ENABLE_QD")

#Adding a define for TPL METIS
IF (TPL_ENABLE_METIS)
SET (IFPACK2_ENABLE_METIS_DEFAULT ON)
ELSE ()
SET (IFPACK2_ENABLE_METIS_DEFAULT OFF)
ENDIF ()
TRIBITS_ADD_OPTION_AND_DEFINE(
${PACKAGE_NAME}_ENABLE_METIS
HAVE_IFPACK2_METIS
"Enable METIS for Ifpack2."
${IFPACK2_ENABLE_METIS_DEFAULT} )

#Adding an option and define when MPI is enabled.
TRIBITS_ADD_OPTION_AND_DEFINE(
${PACKAGE_NAME}_ENABLE_MPI
HAVE_IFPACK2_MPI
"Enable MPI build of Ifpack2."
${TPL_ENABLE_MPI} )

ASSERT_DEFINED(${PACKAGE_NAME}_ENABLE_Lemon)
ASSERT_DEFINED(${PACKAGE_NAME}_ENABLE_Amesos2)
ASSERT_DEFINED(${PACKAGE_NAME}_ENABLE_Cholmod)
Expand Down
2 changes: 1 addition & 1 deletion packages/ifpack2/cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ SET(LIB_OPTIONAL_DEP_PACKAGES Xpetra Zoltan2Core ThyraTpetraAdapters Amesos2 Shy
SET(TEST_REQUIRED_DEP_PACKAGES Belos Galeri)
SET(TEST_OPTIONAL_DEP_PACKAGES Amesos2 ShyLU_NodeHTS ML AztecOO Epetra)
SET(LIB_REQUIRED_DEP_TPLS)
SET(LIB_OPTIONAL_DEP_TPLS HYPRE Cholmod Lemon METIS)
SET(LIB_OPTIONAL_DEP_TPLS HYPRE Cholmod Lemon METIS MPI)
SET(TEST_REQUIRED_DEP_TPLS)
SET(TEST_OPTIONAL_DEP_TPLS QD HYPRE METIS)

0 comments on commit c57865a

Please sign in to comment.