-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake: Improve handling of Albany and related packages #5950
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,65 +205,6 @@ if (USE_PETSC) | |
set(PETSC_LIB ${PETSC_LIBRARIES}) | ||
endif() | ||
|
||
if (USE_TRILINOS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So much better than what we had... |
||
if (TRILINOS_PATH) | ||
if (NOT INC_TRILINOS) | ||
set(INC_TRILINOS ${TRILINOS_PATH}/include) | ||
endif() | ||
if (NOT LIB_TRILINOS) | ||
set(LIB_TRILINOS ${TRILINOS_PATH}/lib) | ||
endif() | ||
else() | ||
message(FATAL_ERROR "TRILINOS_PATH must be defined when USE_TRILINOS is TRUE") | ||
endif() | ||
|
||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${TRILINOS_PATH} PARENT_SCOPE) | ||
find_package(Trilinos) | ||
endif() | ||
|
||
if (USE_ALBANY) | ||
if (ALBANY_PATH) | ||
if (NOT INC_ALBANY) | ||
set(INC_ALBANY ${ALBANY_PATH}/include) | ||
endif() | ||
if (NOT LIB_ALBANY) | ||
set(LIB_ALBANY ${ALBANY_PATH}/lib) | ||
endif() | ||
else() | ||
message(FATAL_ERROR "ALBANY_PATH must be defined when USE_ALBANY is TRUE") | ||
endif() | ||
|
||
# get the "ALBANY_LINK_LIBS" list as an env var | ||
file(READ ${ALBANY_PATH}/export_albany.in ALBANY_OUTPUT) | ||
string(REPLACE "ALBANY_LINK_LIBS=" "" ALBANY_LINK_LIBS "${ALBANY_OUTPUT}") | ||
endif() | ||
|
||
if (USE_KOKKOS) | ||
# LB 01/23 | ||
# CMake's find_package, when used with multiple PATHS and PATH_SUFFIXES, | ||
# follows the following rule when looking in paths: | ||
# 1. look in all the path suffixes of the first PATHS entry, in the order provided | ||
# 2. look in the first PATH provided | ||
# 3. repeat 1-2 with the following entry of PATHS | ||
# 4. look in cmake/system default paths (unless told not to). | ||
# So the following cmd will fist look in the KOKKOS_PATH folder and subfolders, | ||
# if KOKKOS_PATH is non-empty. Then will proceed to look in the lib, lib/cmake, | ||
# and lib64/cmake subfolders of the INSTALL_SHAREDPATH. If all of these fail, | ||
# it will look in INSTALL_SHAREDPATH. | ||
|
||
if (KOKKOS_PATH) | ||
set (PATHS ${KOKKOS_PATH} ${INSTALL_SHAREDPATH}) | ||
elseif(DEFINED ENV{KOKKOS_PATH}) | ||
set (PATHS $ENV{KOKKOS_PATH} ${INSTALL_SHAREDPATH}) | ||
else() | ||
set (PATHS ${INSTALL_SHAREDPATH}) | ||
endif() | ||
find_package(Kokkos REQUIRED | ||
PATHS ${PATHS} | ||
PATH_SUFFIXES lib lib/cmake lib64/cmake | ||
NO_DEFAULT_PATH) | ||
endif() | ||
|
||
# JGF: No one seems to be using this | ||
# if (USE_MOAB) | ||
# if (MOAB_PATH) | ||
|
@@ -369,7 +310,7 @@ else() | |
list(APPEND INCLDIR "${INC_NETCDF_C}" "${INC_NETCDF_FORTRAN}") | ||
endif() | ||
|
||
foreach(ITEM MOD_NETCDF INC_MPI INC_PNETCDF INC_PETSC INC_TRILINOS INC_ALBANY) # INC_MOAB) | ||
foreach(ITEM MOD_NETCDF INC_MPI INC_PNETCDF INC_PETSC) # INC_MOAB) | ||
if (${ITEM}) | ||
list(APPEND INCLDIR "${${ITEM}}") | ||
endif() | ||
|
@@ -417,7 +358,7 @@ if (NOT HAS_COSP EQUAL -1) | |
set(USE_COSP TRUE) | ||
endif() | ||
|
||
# System libraries (netcdf, mpi, pnetcdf, esmf, trilinos, etc.) | ||
# System libraries (netcdf, mpi, pnetcdf, esmf, etc.) | ||
if (NOT SLIBS) | ||
if (NOT NETCDF_SEPARATE) | ||
set(SLIBS "-L${LIB_NETCDF} -lnetcdff -lnetcdf") | ||
|
@@ -443,17 +384,6 @@ if (USE_PETSC) | |
set(SLIBS "${SLIBS} ${PETSC_LIB}") | ||
endif() | ||
|
||
# Add trilinos libraries; too be safe, we include all libraries included in the trilinos build, | ||
# as well as all necessary third-party libraries | ||
if (USE_TRILINOS) | ||
set(SLIBS "${SLIBS} -L${LIB_TRILINOS} ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARY_DIRS} ${Trilinos_TPL_LIBRARIES}") | ||
endif() | ||
|
||
# Add Albany libraries. These are defined in the ALBANY_LINK_LIBS env var that was included above | ||
if (USE_ALBANY) | ||
set(SLIBS "${SLIBS} ${ALBANY_LINK_LIBS}") | ||
endif() | ||
|
||
# Add MOAB libraries. These are defined in the MOAB_LINK_LIBS env var that was included above | ||
# if (USE_MOAB) | ||
# set(SLIBS "${SLIBS} ${IMESH_LIBS}") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This file is for finding pacakges needed by E3SM. It should be included | ||
# from the main CMakeLists.txt file. | ||
# | ||
# Finding the correct packages will likely depend on the ${Package}_ROOT | ||
# environment variable being set by config_machines.xml for your machine. Note | ||
# that is environment var is case sensitive. | ||
|
||
# Machine env vars should follow the following pattern: | ||
# <env name="Package_ROOT">$SHELL{if [ -z "$Package_ROOT" ]; then echo /default/install/location; else echo "$Package_ROOT"; fi}</env> | ||
# | ||
# This will allow users to easily specify a different location for all their cases by | ||
# simply setting ${Package}_ROOT in their shell. | ||
|
||
# Kokkos' find_package needs to come before other find_packages | ||
# that may define Kokkos targets so we can avoid duplicate target | ||
# errors. | ||
if (USE_KOKKOS) | ||
|
||
# Kokkos will be built in the sharedlibs if Kokkos_ROOT is | ||
# unset. | ||
if (NOT DEFINED ENV{Kokkos_ROOT}) | ||
set(ENV{Kokkos_ROOT} ${INSTALL_SHAREDPATH}) | ||
endif() | ||
|
||
find_package(Kokkos REQUIRED) | ||
endif() | ||
|
||
# Albany depends on Trilinos | ||
if (USE_ALBANY OR USE_TRILINOS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fine, but for the record, I think that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this is a deficiency with the Albany cmake system. I tried without
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, we are probably not packaging albany that well.. :/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am going through our cmake stuff, and indeed we lack a lot of stuff to consider us "good cmake citizens"... I will fix it at some point. |
||
find_package(Trilinos REQUIRED) | ||
endif() | ||
|
||
if (USE_ALBANY) | ||
find_package(Albany REQUIRED) | ||
endif() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pattern for setting up ${Package}_ROOT is established here. It's a bit messy so I'm wondering if it would be better to move this login into the cmake macro file for the machine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a better bash syntax:
The
${VAR:=default}
syntax expands to${VAR}
ifVAR
is defined, otherwise it expands todefault
. E.g.:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bartgol , I tried that at first. The problem is that the CIME regex will incorrectly match the first
}
as terminating the SHELL command, so you can use that character in your syntax.