Skip to content

Commit

Permalink
First draft of new cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemartinlogan committed Jan 8, 2025
1 parent a25257a commit ea709cd
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 188 deletions.
42 changes: 42 additions & 0 deletions CMake/HermesCommonConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#-----------------------------------------------------------------------------
# Find all packages needed by Hermes
#-----------------------------------------------------------------------------
# This is for compatability with SPACK
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Chimaera
find_package(Chimaera CONFIG REQUIRED)
message(STATUS "found chimaera at ${Chimaera_INCLUDE_DIRS}")

# Catch2
find_package(Catch2 3.0.1 REQUIRED)
message(STATUS "found catch2.h at ${Catch2_CXX_INCLUDE_DIRS}")

# MPICH
if(BUILD_MPI_TESTS)
find_package(MPI REQUIRED COMPONENTS C CXX)
message(STATUS "found mpi.h at ${MPI_CXX_INCLUDE_DIRS}")
endif()

# OpenMP
if(BUILD_OpenMP_TESTS)
find_package(OpenMP REQUIRED COMPONENTS C CXX)
message(STATUS "found omp.h at ${OpenMP_CXX_INCLUDE_DIRS}")
endif()

# Boost
find_package(Boost REQUIRED COMPONENTS regex system filesystem fiber REQUIRED)
message(STATUS "found boost at ${Boost_INCLUDE_DIRS}")

# Libelf
pkg_check_modules(libelf REQUIRED libelf)
message(STATUS "found libelf at ${libelf_INCLUDE_DIRS}")

# LIBAIO
#find_library(LIBAIO_LIBRARY NAMES aio)
#if(LIBAIO_LIBRARY)
# message(STATUS "found libaio at ${LIBAIO_LIBRARY}")
#else()
# set(LIBAIO_LIBRARY aio)
# message(STATUS "Assuming it was installed with our aio spack")
#endif()
124 changes: 21 additions & 103 deletions CMake/HermesConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,106 +16,24 @@ set(HERMES_VERSION_PATCH @HERMES_VERSION_PATCH@)

set(BUILD_MPI_TESTS @BUILD_MPI_TESTS@)
set(BUILD_OpenMP_TESTS @BUILD_OpenMP_TESTS@)
set(HERMES_ENABLE_COMPRESS @HERMES_ENABLE_COMPRESS@)
set(HERMES_ENABLE_ENCRYPT @HERMES_ENABLE_ENCRYPT@)

#-----------------------------------------------------------------------------
# Find hermes header
#-----------------------------------------------------------------------------
find_path(
Hermes_INCLUDE_DIR
hermes/hermes_types.h
HINTS ENV PATH ENV CPATH
)
if (NOT Hermes_INCLUDE_DIR)
message(STATUS "FindHermes: Could not find Hermes.h")
set(Hermes_FOUND FALSE)
return()
endif()
get_filename_component(Hermes_DIR ${Hermes_INCLUDE_DIR} PATH)

#-----------------------------------------------------------------------------
# Find hermes library
#-----------------------------------------------------------------------------
find_library(
Hermes_LIBRARY
NAMES hermes
HINTS ENV LD_LIBRARY_PATH ENV PATH
)
if (NOT Hermes_LIBRARY)
message(STATUS "FindHermes: Could not find libhermes.so")
set(Hermes_FOUND OFF)
message(STATUS "LIBS: $ENV{LD_LIBRARY_PATH}")
return()
endif()

#-----------------------------------------------------------------------------
# Find all packages needed by Hermes
#-----------------------------------------------------------------------------

# HermesShm
find_package(HermesShm CONFIG REQUIRED)
message(STATUS "found hermes_shm.h at ${HermesShm_INCLUDE_DIRS}")

# Chimaera
find_package(Chimaera CONFIG REQUIRED)
message(STATUS "found chimaera at ${Chimaera_INCLUDE_DIRS}")

# YAML-CPP
find_package(yaml-cpp REQUIRED)
message(STATUS "found yaml-cpp at ${yaml-cpp_DIR}")

# Catch2
find_package(Catch2 3.0.1 REQUIRED)
message(STATUS "found catch2.h at ${Catch2_CXX_INCLUDE_DIRS}")

# MPICH
if(BUILD_MPI_TESTS)
find_package(MPI REQUIRED COMPONENTS C CXX)
message(STATUS "found mpi.h at ${MPI_CXX_INCLUDE_DIRS}")
endif()

# OpenMP
if(BUILD_OpenMP_TESTS)
find_package(OpenMP REQUIRED COMPONENTS C CXX)
message(STATUS "found omp.h at ${OpenMP_CXX_INCLUDE_DIRS}")
endif()

# Cereal
find_package(cereal REQUIRED)
message(STATUS "found cereal")

# Boost
find_package(Boost REQUIRED COMPONENTS regex system filesystem fiber REQUIRED)
message(STATUS "found boost at ${Boost_INCLUDE_DIRS}")

# Thallium
find_package(thallium CONFIG REQUIRED)
if(thallium_FOUND)
message(STATUS "found thallium at ${thallium_DIR}")
endif()

#-----------------------------------------------------------------------------
# Mark hermes as found and set all needed packages
#-----------------------------------------------------------------------------
set(Hermes_LIBRARY_DIR "")
get_filename_component(Hermes_LIBRARY_DIRS ${Hermes_LIBRARY} PATH)
# Set uncached variables as per standard.
set(Hermes_FOUND ON)
# Set Hermes dirs
set(Hermes_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${Hermes_INCLUDE_DIR})
set(_Hermes_CLIENT_LIBRARIES
${HermesShm_LIBRARIES}
${CHIMAERA_CLIENT_LIBRARIES}
yaml-cpp
cereal::cereal
-ldl -lrt -lc -pthread
${Boost_LIBRARIES})
# Set Hermes client dirs (equal to Hermes dirs)
set(Hermes_CLIENT_LIBRARIES
${Hermes_LIBRARY}
client_deps)
set(Hermes_CLIENT_LIBRARY_DIRS
${HermeShm_LIBRARY_DIRS})
set(Hermes_RUNTIME_LIBRARY_DIRS ${HermeShm_LIBRARY_DIRS})
set(Hermes_RUNTIME_DEPS "")
set(HERMES_ENABLE_COVERAGE @HERMES_ENABLE_COVERAGE@)
set(HERMES_ENABLE_DOXYGEN @HERMES_ENABLE_DOXYGEN@)
set(HERMES_REMOTE_DEBUG @HERMES_REMOTE_DEBUG@)

set(HERMES_ENABLE_POSIX_ADAPTER @HERMES_ENABLE_POSIX_ADAPTER@)
set(HERMES_ENABLE_STDIO_ADAPTER @HERMES_ENABLE_STDIO_ADAPTER@)
set(HERMES_ENABLE_MPIIO_ADAPTER @HERMES_ENABLE_MPIIO_ADAPTER@)
set(HERMES_ENABLE_VFD @HERMES_ENABLE_VFD@)
set(HERMES_ENABLE_PUBSUB_ADAPTER @HERMES_ENABLE_PUBSUB_ADAPTER@)
set(HERMES_ENABLE_KVSTORE @HERMES_ENABLE_KVSTORE@)
set(HERMES_ENABLE_PYTHON @HERMES_ENABLE_PYTHON@)
set(HERMES_ENABLE_ADIOS @HERMES_ENABLE_ADIOS@)

set(HERMES_MPICH @HERMES_MPICH@)
set(HERMES_OPENMPI @HERMES_OPENMPI@)

# Find the Hermes Package
find_package(HermesCore REQUIRED)

# Find the Hermes dependencies
find_package(HermesCommon REQUIRED)
103 changes: 22 additions & 81 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ add_compile_options(-march=native -fomit-frame-pointer)
# by other projects.
#-----------------------------------------------------------------------------
if(NOT HERMES_EXPORTED_TARGETS)
set(HERMES_EXPORTED_TARGETS "hrun-targets")
set(HERMES_EXPORTED_TARGETS "Hermes")
endif()


Expand Down Expand Up @@ -113,89 +113,17 @@ add_custom_target(coverage COMMAND bash ${CMAKE_SOURCE_DIR}/ci/coverage.sh
#-----------------------------------------------------------------------------
# Find Packages
#-----------------------------------------------------------------------------
# This is for compatability with SPACK
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# HermesShm
find_package(HermesShm CONFIG REQUIRED)
message(STATUS "found hermes_shm.h at ${HermesShm_INCLUDE_DIRS}")
include_directories(${HermesShm_INCLUDE_DIRS})
link_directories(${HermesShm_LIBRARY_DIRS})

# Chimaera
find_package(Chimaera CONFIG REQUIRED)
message(STATUS "found chimaera at ${Chimaera_LIBRARY_DIR}")
include_directories(${Chimaera_INCLUDE_DIRS})
link_directories(${Chimaera_LIBRARY_DIRS})

# YAML-CPP
find_package(yaml-cpp REQUIRED)
message(STATUS "found yaml-cpp at ${yaml-cpp_DIR}")

# Catch2
find_package(Catch2 3.0.1 REQUIRED)
message(STATUS "found catch2.h at ${Catch2_CXX_INCLUDE_DIRS}")

# MPI
if(BUILD_MPI_TESTS)
find_package(MPI REQUIRED COMPONENTS C CXX)
message(STATUS "found mpi.h at ${MPI_CXX_INCLUDE_DIRS}")
endif()

# OpenMP
if(BUILD_OpenMP_TESTS)
find_package(OpenMP REQUIRED COMPONENTS C CXX)
message(STATUS "found omp.h at ${OpenMP_CXX_INCLUDE_DIRS}")
endif()

# Cereal
find_package(cereal REQUIRED)
if(cereal)
message(STATUS "found cereal")
endif()

# Pkg-Config
find_package(PkgConfig REQUIRED)
if(PkgConfig)
message(STATUS "found pkg config")
endif()

# LIBAIO
#find_library(LIBAIO_LIBRARY NAMES aio)
#if(LIBAIO_LIBRARY)
# message(STATUS "found libaio at ${LIBAIO_LIBRARY}")
#else()
# set(LIBAIO_LIBRARY aio)
# message(STATUS "Assuming it was installed with our aio spack")
#endif()
include(CMake/HermesCommonConfig.cmake)
set(Hermes_CLIENT_DEPS hermes_client)
set(Hermes_RUNTIME_DEPS hermes_runtime)

# Zeromq
#pkg_check_modules(ZMQ REQUIRED libzmq)
#include_directories(${ZMQ_INCLUDE_DIRS})
#message("Found libzmq at: ${ZMQ_INCLUDE_DIRS}")

# Thallium
find_package(thallium CONFIG REQUIRED)
if(thallium_FOUND)
message(STATUS "found thallium at ${thallium_DIR}")
endif()

# Boost
# find_package(Boost REQUIRED COMPONENTS regex system filesystem fiber REQUIRED)
find_package(Boost REQUIRED COMPONENTS fiber REQUIRED)
if (Boost_FOUND)
message(STATUS "found boost at ${Boost_INCLUDE_DIRS}")
endif()
include_directories(${Boost_INCLUDE_DIRS})
message("Boost: ${Boost_LIBRARIES}")

# Libelf
pkg_check_modules(libelf REQUIRED libelf)
message(STATUS "found libelf at ${libelf_INCLUDE_DIRS}")
include_directories(${libelf_INCLUDE_DIRS})
link_directories(${libelf_LIBRARY_DIRS})

# HDF5
# HDF5 (only for VFD, not the basic client)
if(HERMES_ENABLE_VFD)
set(HERMES_REQUIRED_HDF5_VERSION 1.14.0)
set(HERMES_REQUIRED_HDF5_COMPONENTS C)
Expand Down Expand Up @@ -226,18 +154,21 @@ if(HERMES_ENABLE_VFD)
endif()
endif()

set(Hermes_CLIENT_DEPS hermes_client)
set(Hermes_RUNTIME_DEPS hermes_runtime)

# Dependencies for the client
add_library(client_deps INTERFACE)
target_link_libraries(client_deps INTERFACE
Chimaera::client)
target_include_directories(client_deps INTERFACE ${libelf_INCLUDE_DIRS})
target_link_directories(client_deps INTERFACE ${libelf_LIBRARY_DIRS})
target_link_libraries(client_deps INTERFACE ${libelf_LIBRARIES})

# Dependencies for the runtime
add_library(runtime_deps INTERFACE)
target_link_libraries(runtime_deps INTERFACE
Chimaera::runtime)
target_include_directories(runtime_deps INTERFACE ${libelf_INCLUDE_DIRS})
target_link_directories(runtime_deps INTERFACE ${libelf_LIBRARY_DIRS})
target_link_libraries(runtime_deps INTERFACE ${libelf_LIBRARIES})

#------------------------------------------------------------------------------
# Setup CMake Environment
Expand Down Expand Up @@ -308,6 +239,11 @@ add_subdirectory(test)
#-----------------------------------------------------------------------------
# Install Hermes Headers
#-----------------------------------------------------------------------------
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/CMake/HermesCommonConfig.cmake
${PROJECT_BINARY_DIR}/CMakeFiles/HermesCommonConfig.cmake @ONLY
)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/CMake/HermesConfig.cmake
${PROJECT_BINARY_DIR}/CMakeFiles/HermesConfig.cmake @ONLY
Expand All @@ -320,4 +256,9 @@ install(
${CMAKE_INSTALL_PREFIX}/cmake
)

install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX})
install(EXPORT ${HERMES_EXPORTED_TARGETS}
FILE ${HERMES_EXPORTED_TARGETS}CoreConfig.cmake
NAMESPACE Hermes::
DESTINATION cmake
)
2 changes: 0 additions & 2 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ target_link_libraries(hermes_api_bench
install(TARGETS
test_performance_exec
hermes_api_bench
EXPORT
${HERMES_EXPORTED_TARGETS}
LIBRARY DESTINATION ${HERMES_INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${HERMES_INSTALL_LIB_DIR}
RUNTIME DESTINATION ${HERMES_INSTALL_BIN_DIR})
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ install(
hermes_runtime
client_deps
runtime_deps
EXPORT
${HERMES_EXPORTED_TARGETS}
LIBRARY DESTINATION ${HERMES_INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${HERMES_INSTALL_LIB_DIR}
RUNTIME DESTINATION ${HERMES_INSTALL_BIN_DIR}
Expand Down
4 changes: 2 additions & 2 deletions tasks/hermes_core/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ install(
ARCHIVE DESTINATION ${HERMES_INSTALL_LIB_DIR}
RUNTIME DESTINATION ${HERMES_INSTALL_BIN_DIR}
)
install(FILES hermes_core_monitor.py
DESTINATION ${HERMES_INSTALL_LIB_DIR})
# install(FILES hermes_core_monitor.py
# DESTINATION ${HERMES_INSTALL_LIB_DIR})

#------------------------------------------------------------------------------
# Coverage
Expand Down

0 comments on commit ea709cd

Please sign in to comment.