Skip to content

Commit

Permalink
Merge pull request #97 from zhangwei217245/hotfix/FindMercury1
Browse files Browse the repository at this point in the history
Fix NERSC CI issue for FindMercury
  • Loading branch information
jeanbez authored Jul 14, 2023
2 parents 1578f00 + 398c0b9 commit 8259f51
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 10 deletions.
46 changes: 46 additions & 0 deletions CMake/FindMERCURY.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# FindMERCURY.cmake

# Find the system's MERCURY library
# This will define:
#
# MERCURY_FOUND - System has MERCURY
# MERCURY_INCLUDE_DIRS - The MERCURY include directory
# MERCURY_LIBRARIES - The libraries needed to use MERCURY

find_package(MERCURY QUIET HINTS $ENV{MERCURY_HOME} $ENV{MERCURY_DIR} $ENV{MERCURY_ROOT} $ENV{MERCURYPATH} $ENV{MERCURY_PATH})
if(MERCURY_FOUND)
message(STATUS "mercury dir = ${MERCURY_DIR}")
# NOTE: enable the following if you need ${MERCURY_INCLUDE_DIR} in the future
# NOTE: remember to add MERCURY_HOME to PATH or CMAKE_PREFIX_PATH if you enable the following.
find_path(MERCURY_INCLUDE_DIR mercury.h HINTS ${MERCURY_DIR})
find_library(MERCURY_LIBRARY
NAMES
mercury
mercury_debug
HINTS ${MERCURY_DIR}
)

find_library(MERCURY_NA_LIBRARY
NAMES
na
na_debug
HINTS ${MERCURY_DIR}
)

find_library(MERCURY_UTIL_LIBRARY
NAMES
mercury_util
HINTS ${MERCURY_DIR}
)

set(MERCURY_LIBRARIES ${MERCURY_LIBRARY} ${MERCURY_NA_LIBRARY} ${MERCURY_UTIL_LIBRARY})
set(MERCURY_INCLUDE_DIRS ${MERCURY_INCLUDE_DIR})
message(STATUS "mercury include dir = ${MERCURY_INCLUDE_DIRS}")
message(STATUS "mercury lib = ${MERCURY_LIBRARIES}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MERCURY DEFAULT_MSG MERCURY_LIBRARY MERCURY_INCLUDE_DIR)
else(MERCURY_FOUND)
set(MERCURY_LIBRARIES "")
endif()

mark_as_advanced(MERCURY_INCLUDE_DIR MERCURY_LIBRARY)
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ set(PDC_PACKAGE_TARNAME "${PDC_PACKAGE}")
if(NOT MPI_RUN_CMD)
set(MPI_RUN_CMD mpiexec)
endif()

#------------------------------------------------------------------------------
# general cmake flags:
# -DCMAKE_INSTALL_PREFIX=/usr/local -- the prefix for installing
# -DCMAKE_BUILD_TYPE=type -- type can be Debug, Release, ...
# -DCMAKE_PREFIX_PATH=/dir -- external packages
#
# note that CMAKE_PREFIX_PATH can be a list of directories:
# -DCMAKE_PREFIX_PATH='/dir1;/dir2;/dir3'
#------------------------------------------------------------------------------


#------------------------------------------------------------------------------
# Setup install and output Directories
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -79,6 +91,19 @@ if(NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif()

#------------------------------------------------------------------------------
# Setup CMake Prefix Paths for searching external libraries.
#------------------------------------------------------------------------------
# note that CMAKE_PREFIX_PATH can be a list of directories:
# -DCMAKE_PREFIX_PATH='/dir1;/dir2;/dir3'

if(NOT CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
endif()
# MERCURY
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{MERCURY_DIR})
# ANY Future external package goes here...

#------------------------------------------------------------------------------
# Setup CMake Environment
#------------------------------------------------------------------------------
Expand Down
13 changes: 3 additions & 10 deletions src/commons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ endif()


# Mercury
find_package(MERCURY REQUIRED)
find_package(MERCURY CONFIG REQUIRED)
if(MERCURY_FOUND)
message(STATUS "mercury dir = ${MERCURY_DIR}")
# NOTE: enable the following if you need ${MERCURY_INCLUDE_DIR} in the future
# NOTE: remember to add MERCURY_HOME to PATH or CMAKE_PREFIX_PATH if you enable the following.
find_path(MERCURY_INCLUDE_DIR mercury.h HINTS ${MERCURY_DIR})
find_library(MERCURY_LIBRARY mercury HINTS ${MERCURY_DIR})
message(STATUS "mercury include dir = ${MERCURY_INCLUDE_DIR}")
message(STATUS "mercury lib = ${MERCURY_LIBRARY}")
set(PDC_EXT_INCLUDE_DEPENDENCIES ${MERCURY_INCLUDE_DIR}
set(PDC_EXT_INCLUDE_DEPENDENCIES ${MERCURY_INCLUDE_DIRS}
${PDC_EXT_INCLUDE_DEPENDENCIES}
)
set(PDC_EXT_LIB_DEPENDENCIES mercury ${PDC_EXT_LIB_DEPENDENCIES})
set(PDC_EXT_LIB_DEPENDENCIES ${MERCURY_LIBRARIES} ${PDC_EXT_LIB_DEPENDENCIES})
endif()

include_directories(${PDC_EXT_INCLUDE_DEPENDENCIES})
Expand Down

0 comments on commit 8259f51

Please sign in to comment.