From ea709cd0c1bce64a8238ad422ccd7debe2f46123 Mon Sep 17 00:00:00 2001 From: lukemartinlogan Date: Wed, 8 Jan 2025 12:09:42 -0600 Subject: [PATCH] First draft of new cmake --- CMake/HermesCommonConfig.cmake | 42 +++++++++ CMake/HermesConfig.cmake | 124 +++++---------------------- CMakeLists.txt | 103 +++++----------------- benchmark/CMakeLists.txt | 2 - src/CMakeLists.txt | 2 + tasks/hermes_core/src/CMakeLists.txt | 4 +- 6 files changed, 89 insertions(+), 188 deletions(-) diff --git a/CMake/HermesCommonConfig.cmake b/CMake/HermesCommonConfig.cmake index e69de29bb..f1c115fbb 100644 --- a/CMake/HermesCommonConfig.cmake +++ b/CMake/HermesCommonConfig.cmake @@ -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() diff --git a/CMake/HermesConfig.cmake b/CMake/HermesConfig.cmake index 830582041..21d24ba19 100644 --- a/CMake/HermesConfig.cmake +++ b/CMake/HermesConfig.cmake @@ -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 "") \ No newline at end of file +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) diff --git a/CMakeLists.txt b/CMakeLists.txt index d47c40b12..b9ee85f74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() @@ -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) @@ -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 @@ -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 @@ -320,4 +256,9 @@ install( ${CMAKE_INSTALL_PREFIX}/cmake ) -install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX}) \ No newline at end of file +install(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX}) +install(EXPORT ${HERMES_EXPORTED_TARGETS} + FILE ${HERMES_EXPORTED_TARGETS}CoreConfig.cmake + NAMESPACE Hermes:: + DESTINATION cmake +) \ No newline at end of file diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 9542209aa..f2a2a603d 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -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}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e50b1ad5..bdc48878d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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} diff --git a/tasks/hermes_core/src/CMakeLists.txt b/tasks/hermes_core/src/CMakeLists.txt index 3f8c0a282..83ff93cc1 100644 --- a/tasks/hermes_core/src/CMakeLists.txt +++ b/tasks/hermes_core/src/CMakeLists.txt @@ -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