From 65d6c2e991d70dd00709c2ae12b2275f7bc884a2 Mon Sep 17 00:00:00 2001 From: Seth R Johnson Date: Thu, 23 May 2024 08:13:32 +0100 Subject: [PATCH 1/2] Support using build directory as an install dir --- CMakeLists.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab7084451c..7406289146 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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 @@ -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) @@ -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. From 4b86e772c3d684da68584b2a1f76323a80a3c420 Mon Sep 17 00:00:00 2001 From: Seth R Johnson Date: Thu, 23 May 2024 08:28:54 +0100 Subject: [PATCH 2/2] Add test of build-as-install to CI --- .github/workflows/build-spack.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-spack.yml b/.github/workflows/build-spack.yml index 3327772b25..6e9e788a88 100644 --- a/.github/workflows/build-spack.yml +++ b/.github/workflows/build-spack.yml @@ -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: |