Skip to content

Commit

Permalink
Add support for using the build directory as an installation (#1249)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethrj authored May 23, 2024
1 parent 65ed16e commit 5082d52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-spack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ jobs:
fi
ctest --parallel $(nproc) --timeout 15 --output-on-failure \
--test-output-size-passed=32768 --test-output-size-failed=1048576
- name: Check using build directory as install
run: |
. ${SPACK_VIEW}/rc
CELER_INSTALL_DIR=${PWD}/build ./scripts/ci/test-examples.sh
- name: Install
working-directory: build
run: |
Expand Down
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ celeritas_set_default(CMAKE_INSTALL_MESSAGE LAZY)
# Output locations for Celeritas products (used by CeleritasUtils.cmake and
# install code below) will mirror the installation layout
set(CELERITAS_CMAKE_CONFIG_DIRECTORY
"${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake")
"${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(CELERITAS_HEADER_CONFIG_DIRECTORY
"${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}")
set(CELERITAS_LIBRARY_OUTPUT_DIRECTORY
Expand Down Expand Up @@ -558,7 +558,7 @@ endif()

# Where to install configured cmake files
set(CELERITAS_INSTALL_CMAKECONFIGDIR
"${CMAKE_INSTALL_LIBDIR}/cmake/Celeritas")
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")

# Build list of CMake files to install
set(_cmake_files
Expand All @@ -585,6 +585,11 @@ install(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/backport"
COMPONENT development
)

# Copy CMake files to support using Celeritas build dir as an install dir
file(COPY ${_cmake_files}
DESTINATION "${CELERITAS_INSTALL_CMAKECONFIGDIR}"
)

# Export all cache variables that start with CELERITAS_
set(CELERITAS_EXPORT_VARIABLES)
macro(celeritas_export_var varname)
Expand Down Expand Up @@ -664,6 +669,12 @@ install(EXPORT celeritas-targets
COMPONENT development
)

# Export targets to the build tree
export(EXPORT celeritas-targets
FILE "${CELERITAS_CMAKE_CONFIG_DIRECTORY}/CeleritasTargets.cmake"
NAMESPACE Celeritas::
)

if(Celeritas_VERSION VERSION_EQUAL "0.0.0")
install(CODE "
message(WARNING \"The Celeritas version was not detected during configuration.
Expand Down

0 comments on commit 5082d52

Please sign in to comment.