Commit c2e85c87 authored by David M. Rogers's avatar David M. Rogers
Browse files

Completed refactor for install function.

parent 43691a50
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.17)

project(mpitest VERSION 1.0 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(install.cmake)
include(install)

#implicit option(BUILD_TESTING "Build tests accompanying this project" ON)
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
@@ -18,7 +18,6 @@ add_library(mpiwrap src/wrapper.cc)
add_executable(mpitest src/bcast.cc)
#####################################################################

target_compile_features(mpitest PUBLIC cxx_std_14)
target_compile_features(mpiwrap PUBLIC cxx_std_14)
target_link_libraries(mpiwrap PUBLIC MPI::MPI_CXX)
target_include_directories(mpiwrap PUBLIC
@@ -38,4 +37,4 @@ add_subdirectory(tests)

### Installation Instructions ###
install_bins(mpitest)
install_libs(mpiwrap PKG mpiwrap HEADERS include/mpiwrap.hh)
install_libs(TARGETS mpiwrap HEADERS include/mpiwrap.hh)
+2 −2
Original line number Diff line number Diff line
@PACKAGE_INIT@

include ( "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_LIB_PKG}Targets.cmake" )
include ( "${CMAKE_CURRENT_LIST_DIR}/mpitestTargets.cmake" )

find_dependency(MPI REQUIRED)

check_required_components(${INSTALL_LIB_PKG})
check_required_components(mpitest)

README.md

0 → 100644
+35 −0
Original line number Diff line number Diff line
# MPI-test - a minimal packaged library based on MPI

This project provides cmake code to configure and
compile an MPI wrapper library.  The basic idea
is that new HPC projects should be able to use this
cmake code as a starting point for their own
packaging recipes.  As such, it should be as small
as possible while still producing a portable
recipe for installing a library based on the
system's MPI.


# Add-ons

While MPI is basic, there are a few additional system-level
functionalities that would be great to be able to link
to "out of the box".

## CUDA/HIP Kernel Calling Layer

Configuring with ``-DENABLE_GPU=ON`` adds CUDA/HIP kernel
calls using the simple cuda2hip.h header from
the [Quip project](https://github.com/twhite-cray/quip).


## OpenMP

Configuring with ``-DENABLE_OMP=ON`` adds OpenMP pragma
support to the build.  Libraries built with MPI, CUDA/HIP,
and OpenMP should be able to fully exploit system-level
parallelism.  Note that executables and libraries built
this way should link to lots of system-level runtime libraries
that might be sensitive to change over time as HPC systems are
upgraded.
+38 −38
Original line number Diff line number Diff line
@@ -3,47 +3,47 @@ function(install_bins)
    install(TARGETS ${targets} DESTINATION bin)
endfunction()

# e.g. install_libs(mpiwrapper testhelpers PKG mpitest HEADERS include/a.h include/b.h)
function(install_libs targets)
    set(oneValueArgs PKG)
    set(multiValueArgs HEADERS)
    cmake_parse_arguments(INSTALL_LIBS ""
                          "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
    set(targets INSTALL_LIBS_UNPARSED_ARGUMENTS)
# e.g. install_libs(TARGETS mpiwrapper testhelpers HEADERS include/a.h include/b.h)
function(install_libs)
    set(multiValueArgs TARGETS HEADERS)
    cmake_parse_arguments(INSTALL_LIBS "" "" "${multiValueArgs}" ${ARGN})
    set(targets ${INSTALL_LIBS_TARGETS})
    set(pkg ${PROJECT_NAME})
    message(NOTICE "Will install library targets (${targets}) and headers (${INSTALL_LIBS_HEADERS}) under package name ${pkg}")

    # Attach these libraries to the list of exported libs.
    install(TARGETS ${targets}
            DESTINATION lib
          EXPORT "${INSTALL_LIBS_PKG}Targets")
            EXPORT "${pkg}Targets")

  install(FILES ${INSTALL_LIB_HEADERS} DESTINATION include)
    install(FILES ${INSTALL_LIBS_HEADERS} DESTINATION include)
  
    # Note: we choose the following location for cmake dependency info:
    # <prefix>/lib/cmake/${PKG}/
    # install the targets to export
  install(EXPORT "${INSTALL_LIB_PKG}Targets"
    FILE "${INSTALL_LIB_PKG}Targets.cmake"
    NAMESPACE "${INSTALL_LIB_PKG}::"
    DESTINATION "lib/cmake/${INSTALL_LIB_PKG}"
    install(EXPORT "${pkg}Targets"
      FILE "${pkg}Targets.cmake"
      NAMESPACE "${pkg}::"
      DESTINATION "lib/cmake/${pkg}"
    )

    # Create a config helper so others can call find_package(${PKG}::${LIBNAME})
    include(CMakePackageConfigHelpers)
    configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
    "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_LIB_PKG}Config.cmake"
    INSTALL_DESTINATION "lib/cmake/${INSTALL_LIB_PKG}"
      "${CMAKE_CURRENT_BINARY_DIR}/${pkg}Config.cmake"
      INSTALL_DESTINATION "lib/cmake/${pkg}"
      NO_SET_AND_CHECK_MACRO
      )
    # generate the version file for the config file
    write_basic_package_version_file(
    "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_LIB_PKG}ConfigVersion.cmake"
    VERSION "${${INSTALL_LIB_PKG}_VERSION_MAJOR}.${${INSTALL_LIB_PKG}_VERSION_MINOR}"
      "${CMAKE_CURRENT_BINARY_DIR}/${pkg}ConfigVersion.cmake"
      VERSION "${${pkg}_VERSION_MAJOR}.${${pkg}_VERSION_MINOR}"
      COMPATIBILITY AnyNewerVersion
    )
    # install the configuration file
    install(FILES
    "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_LIB_PKG}Config.cmake"
    "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_LIB_PKG}ConfigVersion.cmake"
    DESTINATION "lib/cmake/${INSTALL_LIB_PKG}"
      "${CMAKE_CURRENT_BINARY_DIR}/${pkg}Config.cmake"
      "${CMAKE_CURRENT_BINARY_DIR}/${pkg}ConfigVersion.cmake"
      DESTINATION "lib/cmake/${pkg}"
    )
endfunction()

tests/CMakeLists.txt

0 → 100644
+2 −0
Original line number Diff line number Diff line
add_executable(none none.cc)
add_test(NAME none COMMAND none)
Loading