From de028072694ed9da746f454f2b04f0852b676c3b Mon Sep 17 00:00:00 2001 From: Seth Parker Date: Sat, 27 Jun 2026 00:37:55 +0200 Subject: [PATCH 1/3] fix(cmake): correct install dirs and use GNUInstallDirs find_package(EduceLabCore) could not locate the package because the config files were installed to lib/cmake/EduceLab, which does not match CMake's //cmake/EduceLabCore* search glob. Install them to lib/cmake/EduceLabCore instead. Replace hardcoded lib/include destinations with GNUInstallDirs (CMAKE_INSTALL_LIBDIR/INCLUDEDIR/BINDIR). Drop the PUBLIC_HEADER install, which flattened all headers into a single directory and broke nested includes like "educelab/core/io/MeshIO.hpp". Install the include tree directly so the io/, types/, and utils/ subdirectories are preserved. Co-Authored-By: Claude Opus 4.8 (1M context) --- CMakeLists.txt | 19 +++++++++++-------- cmake/InstallProject.cmake | 8 ++++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e107e59..c58564a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # Modules include(FetchContent) include(CMakeDependentOption) +include(GNUInstallDirs) # Get Git hash include(GetGitRevisionDescription) @@ -68,17 +69,19 @@ target_compile_features(core PUBLIC cxx_std_17) if(EDUCE_CORE_CHARCONV_DEFS) target_compile_definitions(core PUBLIC ${EDUCE_CORE_CHARCONV_DEFS}) endif() -set_target_properties(core - PROPERTIES - PUBLIC_HEADER "${public_hdrs}" -) install( TARGETS core EXPORT EduceLabCoreTargets - ARCHIVE DESTINATION "lib" - LIBRARY DESTINATION "lib" - INCLUDES DESTINATION "include/educelab/core" - PUBLIC_HEADER DESTINATION "include/educelab/core" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) +# Install headers preserving their directory structure under include/educelab/core +install( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + FILES_MATCHING PATTERN "*.hpp" ) # Docs diff --git a/cmake/InstallProject.cmake b/cmake/InstallProject.cmake index 863dbff..66b2860 100644 --- a/cmake/InstallProject.cmake +++ b/cmake/InstallProject.cmake @@ -6,16 +6,20 @@ write_basic_package_version_file( ) configure_file(cmake/EduceLabCoreConfig.cmake.in EduceLabCoreConfig.cmake @ONLY) +# Package config must live in a directory matching find_package(EduceLabCore)'s +# search glob (//cmake/EduceLabCore*), otherwise it is not found. +set(EduceLabCore_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/EduceLabCore") + install( EXPORT EduceLabCoreTargets FILE EduceLabCoreTargets.cmake NAMESPACE educelab:: - DESTINATION lib/cmake/EduceLab + DESTINATION "${EduceLabCore_INSTALL_CMAKEDIR}" ) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/EduceLabCoreConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/EduceLabCoreConfigVersion.cmake" - DESTINATION lib/cmake/EduceLab + DESTINATION "${EduceLabCore_INSTALL_CMAKEDIR}" ) From d9a52ecb090ebcb33853eee515bbe4fde49b0c17 Mon Sep 17 00:00:00 2001 From: Seth Parker Date: Sat, 27 Jun 2026 00:38:59 +0200 Subject: [PATCH 2/3] build: add Flags.hpp to public headers list Co-Authored-By: Claude Opus 4.8 (1M context) --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c58564a..baf340e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,7 @@ set(public_hdrs include/educelab/core/types/Uuid.hpp include/educelab/core/types/Vec.hpp include/educelab/core/utils/Caching.hpp + include/educelab/core/utils/Flags.hpp include/educelab/core/utils/MeshUtils.hpp include/educelab/core/utils/Filesystem.hpp include/educelab/core/utils/Iteration.hpp From d45fea8ade93e7ec4e6468c9fae1ecc86208e88c Mon Sep 17 00:00:00 2001 From: Seth Parker Date: Sat, 27 Jun 2026 00:40:59 +0200 Subject: [PATCH 3/3] ci: add install + find_package regression test Builds, installs to a prefix, then configures and builds a small consumer project via find_package(EduceLabCore) to guard against broken install layouts and packaging regressions. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/unit_test.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 6127521..53b7b21 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -20,8 +20,28 @@ jobs: - name: Build libcore run: | - cmake -S . -B build $EXTRA_CMAKE_FLAGS + cmake -S . -B build $EXTRA_CMAKE_FLAGS -DCMAKE_INSTALL_PREFIX="$PWD/install" cmake --build build/ -j 4 - name: Run tests run: ctest -V --test-dir build/ + + - name: Install libcore + run: cmake --install build/ + + - name: Test find_package from a consumer project + run: | + mkdir -p consumer + cat > consumer/CMakeLists.txt <<'EOF' + cmake_minimum_required(VERSION 3.15) + project(consumer CXX) + find_package(EduceLabCore REQUIRED) + add_executable(consumer main.cpp) + target_link_libraries(consumer PRIVATE educelab::core) + EOF + cat > consumer/main.cpp <<'EOF' + #include "educelab/core/io/MeshIO.hpp" + int main() { return 0; } + EOF + cmake -S consumer -B consumer/build -DCMAKE_PREFIX_PATH="$PWD/install" + cmake --build consumer/build -j 4