Skip to content

Commit

Permalink
Fix install locations and rpaths for pip installs
Browse files Browse the repository at this point in the history
  • Loading branch information
scottwittenburg committed Dec 2, 2023
1 parent 8d32bed commit a0e2852
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 171 deletions.
41 changes: 35 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,39 @@ setup_version(2.9.0)

project(ADIOS2 VERSION ${ADIOS2_VERSION})

# Advanced option to tell CMake the build is on behalf of pip
set(ADIOS2_PIP_INSTALL OFF CACHE BOOL "Turn on for pip install")
mark_as_advanced(ADIOS2_PIP_INSTALL)

if (ADIOS2_PIP_INSTALL)
# Required for shared library placement.
if (WIN32)
# Defaults are fine; handled by `delvewheel`.
elseif (APPLE)
set(CMAKE_INSTALL_LIBDIR
# Store libraries in a subdirectory here.
"adios2/.dylibs")
else ()
set(CMAKE_INSTALL_LIBDIR
# Linux bundles what libraries we have when they're put beside the modules.
"adios2")
endif ()

if (APPLE)
# macOS loader settings.
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
set(CMAKE_INSTALL_NAME_DIR "@rpath")
list(APPEND CMAKE_INSTALL_RPATH
"@loader_path")
elseif (UNIX)
# ELF loader settings.
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
list(APPEND CMAKE_INSTALL_RPATH
"$ORIGIN")
endif ()
endif ()

#------------------------------------------------------------------------------#
# Some boilerplate to setup nice output directories
#------------------------------------------------------------------------------#
Expand Down Expand Up @@ -109,10 +142,6 @@ set(ADIOS2_EXECUTABLE_SUFFIX "${ADIOS2_LIBRARY_SUFFIX}" CACHE STRING
"Suffix to append to executable names")
mark_as_advanced(ADIOS2_LIBRARY_SUFFIX ADIOS2_EXECUTABLE_SUFFIX)

# Advanced option to tell CMake the build is on behalf of pip
set(ADIOS2_PIP_INSTALL OFF CACHE BOOL "Turn on for pip install")
mark_as_advanced(ADIOS2_PIP_INSTALL)

# Use meta-compile features if available, otherwise use specific language
# features
if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Intel|Clang|AppleClang|MSVC)$")
Expand Down Expand Up @@ -287,12 +316,12 @@ if(BUILD_SHARED_LIBS AND ADIOS2_RUN_INSTALL_TEST)
set(ADIOS2_RUN_INSTALL_TEST FALSE)
endif()
else()
set(CMAKE_INSTALL_RPATH "@loader_path/${relative_base}/${CMAKE_INSTALL_LIBDIR}")
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/${relative_base}/${CMAKE_INSTALL_LIBDIR}")
endif()

elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
# Linux needs some specialized RPATH handling
set(CMAKE_INSTALL_RPATH "$ORIGIN/${relative_base}/${CMAKE_INSTALL_LIBDIR}")
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/${relative_base}/${CMAKE_INSTALL_LIBDIR}")
endif()
endif()

Expand Down
31 changes: 20 additions & 11 deletions bindings/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ set_target_properties(adios2_py PROPERTIES
COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2
)


if(CMAKE_SYSTEM_NAME MATCHES "Linux")
if (ADIOS2_PIP_INSTALL)
set_target_properties(adios2_py PROPERTIES
INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}"
)
set_target_properties(adios2_py PROPERTIES
INSTALL_RPATH "${CMAKE_INSTALL_RPATH}"
)
else()
string(REGEX REPLACE "[^/]+" ".." relative_base "${CMAKE_INSTALL_PYTHONDIR}/adios2")
set_target_properties(adios2_py PROPERTIES
Expand All @@ -61,11 +60,21 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
endif()
endif()

install(TARGETS adios2_py
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/adios2
COMPONENT adios2_python-python
)
install(FILES ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/__init__.py
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/adios2
COMPONENT adios2_python-python
if (ADIOS2_PIP_INSTALL)
install(TARGETS adios2_py
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT adios2_python-python)
install(FILES ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/__init__.py
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT adios2_python-python)
else ()
install(TARGETS adios2_py
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}
COMPONENT adios2_python-python
)
install(FILES ${CMAKE_PYTHON_OUTPUT_DIRECTORY}/adios2/__init__.py
DESTINATION ${CMAKE_INSTALL_PYTHONDIR}
COMPONENT adios2_python-python
)
endif ()

38 changes: 16 additions & 22 deletions cmake/DetectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ if(NOT SHARED_LIBS_SUPPORTED)
endif()
endif()

if(ADIOS2_USE_Python STREQUAL AUTO)
if(ADIOS2_PIP_INSTALL)
find_package(Python 3 REQUIRED COMPONENTS Interpreter Development.Module NumPy)
elseif(ADIOS2_USE_Python STREQUAL AUTO)
find_package(Python 3 COMPONENTS Interpreter Development NumPy)
if(Python_FOUND AND ADIOS2_HAVE_MPI)
find_package(PythonModule COMPONENTS mpi4py mpi4py/mpi4py.h)
Expand Down Expand Up @@ -426,29 +428,21 @@ endif()

if(Python_Interpreter_FOUND)
# Setup output directories
if (ADIOS2_PIP_INSTALL)
# do it the pip way
set(CMAKE_INSTALL_PYTHONDIR ${Python_SITEARCH})
set(CMAKE_PYTHON_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${Python_SITEARCH}
)
if(Python_Development_FOUND)
lists_get_prefix("Python_INCLUDE_DIRS;Python_LIBRARIES;Python_SITEARCH" _Python_DEVPREFIX)
else()
if(Python_Development_FOUND)
lists_get_prefix("Python_INCLUDE_DIRS;Python_LIBRARIES;Python_SITEARCH" _Python_DEVPREFIX)
else()
lists_get_prefix("Python_EXECUTABLE;Python_SITEARCH" _Python_DEVPREFIX)
endif()
message("This is borked! _Python_DEVPREFIX = ${_Python_DEVPREFIX}, Python_SITEARCH = ${Python_SITEARCH}")
string_strip_prefix(
"${_Python_DEVPREFIX}" "${Python_SITEARCH}" CMAKE_INSTALL_PYTHONDIR_DEFAULT
)
set(CMAKE_INSTALL_PYTHONDIR "${CMAKE_INSTALL_PYTHONDIR_DEFAULT}"
CACHE PATH "Install directory for python modules"
)
set(CMAKE_PYTHON_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}
)
lists_get_prefix("Python_EXECUTABLE;Python_SITEARCH" _Python_DEVPREFIX)
endif()
message("This is borked! _Python_DEVPREFIX = ${_Python_DEVPREFIX}, Python_SITEARCH = ${Python_SITEARCH}")
string_strip_prefix(
"${_Python_DEVPREFIX}" "${Python_SITEARCH}" CMAKE_INSTALL_PYTHONDIR_DEFAULT
)
set(CMAKE_INSTALL_PYTHONDIR "${CMAKE_INSTALL_PYTHONDIR_DEFAULT}"
CACHE PATH "Install directory for python modules"
)
set(CMAKE_PYTHON_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PYTHONDIR}
)
mark_as_advanced(CMAKE_INSTALL_PYTHONDIR)
endif()

Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ classifiers = [
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
dependencies = [
"numpy",
]

[project.urls]
Homepage = "https://github.com/ornladios/adios2"
Issues = "https://github.com/ornladios/adios2/issues"

[tool.scikit-build]
wheel.packages = ["adios2"]
build-dir = "/data/scott/Documents/adios2/pip_build"

[tool.scikit-build.cmake.define]
ADIOS2_USE_Python = "ON"
Expand All @@ -37,9 +39,11 @@ ADIOS2_USE_MPI = "OFF"
ADIOS2_USE_HDF5 = "OFF"
ADIOS2_USE_HDF5_VOL = "OFF"
ADIOS2_USE_BZip2 = "OFF"
ADIOS2_USE_Blosc = "OFF"
ADIOS2_USE_Blosc2 = "OFF"
ADIOS2_USE_DataMan = "OFF"
ADIOS2_USE_SZ = "OFF"
ADIOS2_USE_ZeroMQ = "OFF"
ADIOS2_USE_ZFP = "OFF"
ADIOS2_PIP_INSTALL = "ON"
BUILD_TESTING = "OFF"
ADIOS2_INSTALL_GENERATE_CONFIG = "OFF"
26 changes: 14 additions & 12 deletions source/adios2/toolkit/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#

add_executable(remote_server ./remote_server.cpp remote_common.cpp)
if (NOT ADIOS2_PIP_INSTALL)
add_executable(remote_server ./remote_server.cpp remote_common.cpp)

target_link_libraries(remote_server PUBLIC EVPath::EVPath adios2_core adios2sys
PRIVATE $<$<PLATFORM_ID:Windows>:shlwapi>)
target_link_libraries(remote_server PUBLIC EVPath::EVPath adios2_core adios2sys
PRIVATE $<$<PLATFORM_ID:Windows>:shlwapi>)

get_property(pugixml_headers_path
TARGET pugixml
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
)
get_property(pugixml_headers_path
TARGET pugixml
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
)

target_include_directories(remote_server PRIVATE ${PROJECT_BINARY_DIR} ${pugixml_headers_path})
target_include_directories(remote_server PRIVATE ${PROJECT_BINARY_DIR} ${pugixml_headers_path})

set_property(TARGET remote_server PROPERTY OUTPUT_NAME remote_server${ADIOS2_EXECUTABLE_SUFFIX})
install(TARGETS remote_server EXPORT adios2
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT adios2_tools-runtime
)
set_property(TARGET remote_server PROPERTY OUTPUT_NAME remote_server${ADIOS2_EXECUTABLE_SUFFIX})
install(TARGETS remote_server EXPORT adios2
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT adios2_tools-runtime
)
endif ()
36 changes: 19 additions & 17 deletions source/adios2/toolkit/sst/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#

if(ADIOS2_HAVE_MPI)
set(maybe_adios2_core_mpi adios2_core_mpi)
else()
set(maybe_adios2_core_mpi)
endif()
if (NOT ADIOS2_PIP_INSTALL)
if(ADIOS2_HAVE_MPI)
set(maybe_adios2_core_mpi adios2_core_mpi)
else()
set(maybe_adios2_core_mpi)
endif()

# stt_conn_tool
add_executable(sst_conn_tool sst_conn_tool.c sst_conn_tool.cxx)
target_link_libraries(sst_conn_tool ${maybe_adios2_core_mpi} adios2_core)
set_property(TARGET sst_conn_tool PROPERTY OUTPUT_NAME sst_conn_tool${ADIOS2_EXECUTABLE_SUFFIX})
# stt_conn_tool
add_executable(sst_conn_tool sst_conn_tool.c sst_conn_tool.cxx)
target_link_libraries(sst_conn_tool ${maybe_adios2_core_mpi} adios2_core)
set_property(TARGET sst_conn_tool PROPERTY OUTPUT_NAME sst_conn_tool${ADIOS2_EXECUTABLE_SUFFIX})

if(WIN32)
target_link_libraries(sst_conn_tool getopt)
endif()
if(WIN32)
target_link_libraries(sst_conn_tool getopt)
endif()

target_link_libraries(sst_conn_tool sst adios2::thirdparty::EVPath)
target_link_libraries(sst_conn_tool sst adios2::thirdparty::EVPath)

target_include_directories(sst_conn_tool PRIVATE .. ../cp )
target_include_directories(sst_conn_tool PRIVATE .. ../cp )

install(TARGETS sst_conn_tool EXPORT adios2
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT adios2_tools-runtime
)
install(TARGETS sst_conn_tool EXPORT adios2
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT adios2_tools-runtime
)
endif ()
Loading

0 comments on commit a0e2852

Please sign in to comment.