Commit 7ceaa52a authored by Atkins, Charles Vernon's avatar Atkins, Charles Vernon
Browse files

Add package config files for build and install dirs.

Fixes #153
parent a84774d6
......@@ -17,8 +17,8 @@ project(ADIOS2 VERSION 2.0.0)
#------------------------------------------------------------------------------#
# Some boilerplate to setup nice output directories
#------------------------------------------------------------------------------#
include(GNUInstallDirs)
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/adios2")
list(INSERT CMAKE_MODULE_PATH 0 "${ADIOS2_SOURCE_DIR}/cmake")
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
......@@ -83,9 +83,8 @@ if(ADIOS2_HAVE_MPI)
add_definitions(-DOMPI_SKIP_MPICXX)
endif()
GenerateADIOSConfig(MPI ZFP BZip2 ADIOS1 HDF5 DataMan Python SysVShMem)
install(
FILES ${ADIOS2_BINARY_DIR}/adios2/ADIOSConfig.h
GenerateADIOSHeaderConfig(MPI ZFP BZip2 ADIOS1 HDF5 DataMan Python SysVShMem)
install(FILES ${ADIOS2_BINARY_DIR}/source/adios2/ADIOSConfig.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2
)
......@@ -125,6 +124,11 @@ if(BUILD_TESTING)
add_subdirectory(testing)
endif()
#------------------------------------------------------------------------------#
# Generating package configs
#------------------------------------------------------------------------------#
GenerateADIOSPackageConfig()
#------------------------------------------------------------------------------#
# Configuration summary
#------------------------------------------------------------------------------#
......
......@@ -26,14 +26,11 @@ endif()
string(REGEX REPLACE "^${PYTHON_PREFIX}/" ""
CMAKE_INSTALL_PYTHONDIR "${PYTHON_SITE_PACKAGES}"
)
set(CMAKE_INSTALL_PYTHONDIR "${CMAKE_INSTALL_PYTHONDIR}"
CACHE INTERNAL "" FORCE
)
set_target_properties(adios2py PROPERTIES
OUTPUT_NAME adios2
LIBRARY_OUTPUT_DIRECTORY ${ADIOS2_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}
RUNTIME_OUTPUT_DIRECTORY ${ADIOS2_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}
)
install(TARGETS adios2py
install(TARGETS adios2py
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}
)
list(INSERT CMAKE_MODULE_PATH 0 "@ADIOS2_SOURCE_DIR@/cmake")
include("${CMAKE_CURRENT_LIST_DIR}/ADIOS2ConfigCommon.cmake")
cmake_minimum_required(VERSION 3.5)
include(CMakeFindDependencyMacro)
if(NOT @BUILD_SHARED_LIBS@)
set(ADIOS2_HAVE_BZip2 @ADIOS2_HAVE_BZip2@)
if(ADIOS2_HAVE_BZip2)
find_dependency(BZip2)
endif()
set(ADIOS2_HAVE_ZFP @ADIOS2_HAVE_ZFP@)
if(ADIOS2_HAVE_ZFP)
find_dependency(ZFP)
endif()
set(ADIOS2_HAVE_MPI @ADIOS2_HAVE_MPI@)
if(ADIOS2_HAVE_MPI)
find_dependency(MPI)
endif()
set(ADIOS2_HAVE_ZeroMQ @ADIOS2_HAVE_ZeroMQ@)
if(ADIOS2_HAVE_ZeroMQ)
find_dependency(ZeroMQ)
endif()
set(ADIOS2_HAVE_HDF5 @ADIOS2_HAVE_HDF5@)
if(ADIOS2_HAVE_HDF5)
find_dependency(HDF5 COMPONENTS C)
endif()
set(ADIOS2_HAVE_ADIOS1 @ADIOS2_HAVE_ADIOS1@)
if(ADIOS2_HAVE_ADIOS1)
if(ADIOS2_HAVE_MPI)
find_dependency(ADIOS1 1.12.0)
else()
find_dependency(ADIOS1 1.12.0 sequential)
endif()
endif()
endif()
include("${CMAKE_CURRENT_LIST_DIR}/ADIOS2ConfigVersion.cmake")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ADIOS2 DEFAULT_MESSAGE ADIOS2_VERSION)
include("${CMAKE_CURRENT_LIST_DIR}/ADIOS2Targets.cmake")
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/Modules")
include("${CMAKE_CURRENT_LIST_DIR}/ADIOS2ConfigCommon.cmake")
......@@ -3,22 +3,6 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
function(GenerateADIOSConfig)
foreach(OPT IN LISTS ARGN)
string(TOUPPER ${OPT} OPT_UPPER)
if(ADIOS2_HAVE_${OPT})
set(ADIOS2_HAVE_${OPT_UPPER} 1)
else()
set(ADIOS2_HAVE_${OPT_UPPER})
endif()
endforeach()
configure_file(
${ADIOS2_SOURCE_DIR}/source/adios2/ADIOSConfig.h.in
${ADIOS2_BINARY_DIR}/adios2/ADIOSConfig.h
)
endfunction()
function(adios_option name description default)
set(ADIOS2_USE_${name} ${default} CACHE STRING "${description}")
set_property(CACHE ADIOS2_USE_${name} PROPERTY
......@@ -46,3 +30,92 @@ function(python_add_test name script)
ENVIRONMENT "PYTHONPATH=${ADIOS2_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}:$ENV{PYTHONPATH}"
)
endfunction()
function(GenerateADIOSHeaderConfig)
foreach(OPT IN LISTS ARGN)
string(TOUPPER ${OPT} OPT_UPPER)
if(ADIOS2_HAVE_${OPT})
set(ADIOS2_HAVE_${OPT_UPPER} 1)
else()
set(ADIOS2_HAVE_${OPT_UPPER})
endif()
endforeach()
configure_file(
${ADIOS2_SOURCE_DIR}/source/adios2/ADIOSConfig.h.in
${ADIOS2_BINARY_DIR}/source/adios2/ADIOSConfig.h
)
endfunction()
function(GenerateADIOSPackageConfig)
include(CMakePackageConfigHelpers)
# Build interface configs
write_basic_package_version_file(
${ADIOS2_BINARY_DIR}/ADIOS2ConfigVersion.cmake
COMPATIBILITY AnyNewerVersion
)
export(EXPORT adios2Exports
FILE ${ADIOS2_BINARY_DIR}/ADIOS2Targets.cmake
NAMESPACE adios2::
)
configure_file(
${ADIOS2_SOURCE_DIR}/cmake/ADIOS2ConfigCommon.cmake.in
${ADIOS2_BINARY_DIR}/ADIOS2ConfigCommon.cmake
@ONLY
)
configure_file(
${ADIOS2_SOURCE_DIR}/cmake/ADIOS2Config.cmake.in
${ADIOS2_BINARY_DIR}/ADIOS2Config.cmake
@ONLY
)
# Install interface configs
install(
FILES
${ADIOS2_BINARY_DIR}/ADIOS2ConfigVersion.cmake
${ADIOS2_BINARY_DIR}/ADIOS2ConfigCommon.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
)
install(EXPORT adios2Exports
FILE ADIOS2Targets.cmake
NAMESPACE adios2::
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
)
configure_file(
${ADIOS2_SOURCE_DIR}/cmake/ADIOS2ConfigInstall.cmake.in
${ADIOS2_BINARY_DIR}/ADIOS2ConfigInstall.cmake
@ONLY
)
install(FILES ${ADIOS2_BINARY_DIR}/ADIOS2ConfigInstall.cmake
RENAME ADIOS2Config.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
)
# Install helper find modules if needed
if(NOT BUILD_SHARED_LIBS)
if(ADIOS2_HAVE_BZip2)
install(FILES cmake/FindBZip2.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/Modules
)
install(FILES cmake/upstream/FindBZip2.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/Modules/upstream
)
endif()
if(ADIOS2_HAVE_ZFP)
install(FILES cmake/FindZFP.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/Modules
)
endif()
if(ADIOS2_HAVE_ZeroMQ)
install(FILES cmake/FindZeroMQ.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/Modules
)
endif()
if(ADIOS2_HAVE_ADIOS1)
install(FILES cmake/FindADIOS1.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/Modules
)
endif()
endif()
endfunction()
......@@ -3,6 +3,10 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
# We'll need to install the private find modules to ensure our import libs
# are properly resovled
set(adios2_find_modules)
# This file contains the option and dependency logic. The configuration
# options are designed to be tertiary: ON, OFF, or AUTO. If AUTO, we try to
# determine if dependencies are available and enable the option if we find
......@@ -121,5 +125,5 @@ if(ADIOS2_USE_SysVShMem STREQUAL AUTO)
set(ADIOS2_HAVE_SysVShMem OFF)
endif()
elseif(ADIOS2_USE_SysVShMem)
set(ADIOS2_HAVE_SysVShMem)
endif()
\ No newline at end of file
set(ADIOS2_HAVE_SysVShMem TRUE)
endif()
......@@ -44,9 +44,8 @@ add_library(adios2
target_include_directories(adios2
PUBLIC
$<BUILD_INTERFACE:${ADIOS2_SOURCE_DIR}/source>
$<BUILD_INTERFACE:${ADIOS2_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
PRIVATE ${ADIOS2_SOURCE_DIR}/source
$<BUILD_INTERFACE:${ADIOS2_BINARY_DIR}/source>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(adios2 PRIVATE adios2sys pugixml)
......@@ -139,19 +138,16 @@ set_target_properties(adios2 PROPERTIES
SOVERSION ${ADIOS2_VERSION_MAJOR}
)
install(
FILES ADIOSMacros.h ADIOSTypes.h ADIOSMPICommOnly.h
install(FILES ADIOSMacros.h ADIOSTypes.h ADIOSMPICommOnly.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/core
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/core
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/adios2
FILES_MATCHING REGEX "[^/]*\.(h|inl)$"
)
# Library installation
install(
TARGETS adios2 EXPORT adios2
install(TARGETS adios2 EXPORT adios2Exports
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
......
......@@ -10,31 +10,42 @@ if(MSVC)
message(FATAL_ERROR "DataMan is not currently compatible with MSVC")
endif()
set(dataman_targets)
add_library(dataman
DataManBase.cpp DataManBase.h
DataMan.cpp DataMan.h
CacheMan.cpp CacheMan.h
)
target_include_directories(dataman PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(dataman
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
target_link_libraries(dataman
PRIVATE adios2sys
PUBLIC NLohmannJson
)
list(APPEND dataman_targets dataman)
set_target_properties(dataman PROPERTIES
VERSION ${ADIOS2_VERSION}
SOVERSION ${ADIOS2_VERSION_MAJOR}
)
install(TARGETS dataman EXPORT adios2Exports
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dataman
)
# Add the dataman plugins as MODULE libraries instead of SHARED libraries.
# MODULE libraries are designed to be plugins, i.e. shared libs that nobody
# else links to.
set(dataman_modules)
add_library(dumpman MODULE DumpMan.h DumpMan.cpp)
target_link_libraries(dumpman PRIVATE dataman)
list(APPEND dataman_targets dumpman)
list(APPEND dataman_modules dumpman)
add_library(temporalman MODULE TemporalMan.h TemporalMan.cpp)
target_link_libraries(temporalman PRIVATE dataman)
list(APPEND dataman_targets temporalman)
list(APPEND dataman_modules temporalman)
if(ADIOS2_HAVE_ZeroMQ)
find_package(ZeroMQ REQUIRED)
......@@ -44,14 +55,14 @@ if(ADIOS2_HAVE_ZeroMQ)
ZmqMan.h ZmqMan.cpp
)
target_link_libraries(zmqman PRIVATE dataman ZeroMQ::ZMQ)
list(APPEND dataman_targets zmqman)
list(APPEND dataman_modules zmqman)
add_library(mdtmman MODULE
StreamMan.h StreamMan.cpp
MdtmMan.h MdtmMan.cpp
)
target_link_libraries(mdtmman PRIVATE dataman ZeroMQ::ZMQ)
list(APPEND dataman_targets mdtmman)
list(APPEND dataman_modules mdtmman)
endif()
if(ADIOS2_HAVE_ZFP)
......@@ -60,18 +71,10 @@ if(ADIOS2_HAVE_ZFP)
add_library(zfpman MODULE ZfpMan.h ZfpMan.cpp)
target_link_libraries(zfpman PRIVATE dataman zfp::zfp)
list(APPEND dataman_targets zfpman)
list(APPEND dataman_modules zfpman)
endif()
# Library versioning like this only makes sense for libdataman. The others are plugins
# loaded via dlopen.
set_target_properties(dataman PROPERTIES
VERSION ${ADIOS2_VERSION}
SOVERSION ${ADIOS2_VERSION_MAJOR}
)
install(
TARGETS ${dataman_targets} EXPORT adios2
install(TARGETS ${dataman_modules}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
......
add_library(NLohmannJson INTERFACE)
target_include_directories(NLohmannJson
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/json/src
add_library(NLohmann::Json INTERFACE IMPORTED GLOBAL)
set_target_properties(NLohmann::Json PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/json/src
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment