Files
libakstdlib/tests/consumer/CMakeLists.txt
Andrew Kesterson 7940276f87 Test the installed package, not just the build tree
Found by building a consumer against a fresh install: an installed
libakstdlib was not usable. akstdlibConfig.cmake calls
find_dependency(akerror), and the top-level build pulls the submodule in
EXCLUDE_FROM_ALL, so `cmake --install` on this project installs only
this project and leaves that dependency unresolvable.

CI had been hiding it by installing libakerror@main in a separate step
-- a different libakerror from the one actually compiled, which is the
inconsistency TODO.md 2.3 recorded and the previous commit removed.
Removing it exposed the real gap.

CI now installs deps/libakerror, the same commit the top-level build
compiles, so there is one libakerror in play and the install is
consumable.

tests/consumer/ is the check that would have caught it: a standalone
project, configured against CMAKE_PREFIX_PATH rather than as part of
this build, because being part of this build is exactly what would let
it pass without testing anything. It exercises what only an install has
-- find_package with a version request against the generated version
file, find_dependency(akerror) resolving, and the exported
akstdlib::akstdlib target -- and touches one function from each of the
four sources, so a library installed with a source file missing from its
link line fails there rather than in the next consumer to find it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-31 08:05:09 -04:00

22 lines
1.0 KiB
CMake

# A consumer of the *installed* package, not of the build tree.
#
# The test suite links the build tree, so it says nothing about whether an
# installed libakstdlib is usable -- and the two have come apart before. This is
# the smallest thing that exercises the paths only an install has: the version
# file (find_package with a version request), akstdlibConfig.cmake's
# find_dependency(akerror), and the exported akstdlib::akstdlib target.
#
# Configured standalone against CMAKE_PREFIX_PATH rather than being part of the
# main build, because being part of the main build is exactly what would let it
# pass without testing anything.
cmake_minimum_required(VERSION 3.10)
project(akstdlib_consumer LANGUAGES C)
# A version request, so akstdlibConfigVersion.cmake has to be present and has to
# agree. Deliberately MAJOR.MINOR rather than the full version: that is the
# compatibility promise the soname makes, so it is the one worth asserting.
find_package(akstdlib 0.2 REQUIRED)
add_executable(consumer main.c)
target_link_libraries(consumer PRIVATE akstdlib::akstdlib)