Skip to content

All non-CMakePresets.json builds broken #188

@pszenher

Description

@pszenher

Overview

This project's CMakeLists.txt unconditionally requires beman-install-library to be resolvable via find_package, but does not guarantee its own ./infra/cmake/beman-install-library-config.cmake file is resolvable.

find_package(beman-install-library REQUIRED)

Nothing in the CMakeLists.txt file takes steps to check/provide this before hard-erroring, and all README-described build steps are broken (except for the preset builds, see below).

Broken Build Output

[pszenher ~/src/optional]$ cmake -B .build -S . -DOPTIONAL_ENABLE_TESTING=OFF
-- The CXX compiler identification is GNU 15.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/kbw2j1vag664b3sj3rjwz9v53cqx87sb-gcc-wrapper-15.2.0/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:61 (find_package):
  By not providing "Findbeman-install-library.cmake" in CMAKE_MODULE_PATH
  this project has asked CMake to find a package configuration file provided
  by "beman-install-library", but CMake did not find one.

  Could not find a package configuration file provided by
  "beman-install-library" with any of the following names:

    beman-install-libraryConfig.cmake
    beman-install-library-config.cmake

  Add the installation prefix of "beman-install-library" to CMAKE_PREFIX_PATH
  or set "beman-install-library_DIR" to a directory containing one of the
  above files.  If "beman-install-library" provides a separate development
  package or SDK, be sure it has been installed.

Details

I had originally drafted up an issue about incompatibility of this package being fetched/built via CMake FetchContent, but realized midway through that the primary build instructions are broken.

There are only three currently working build-flows:

  1. Setting -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=.infra/cmake/use-fetch-content.cmake at configure-time
    • note that this is not the readme-recommended cmake/use-fetch-content.cmake from the top-level cmake dir; build using the readme-suggested CMAKE_PROJECT_TOP_LEVEL_INCLUDES file are broken
  2. Any of the CMake preset builds, which use the infra toolchain files, each of which call list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}")
    • note that these would work without the toolchain cmake files, as the _root-config base preset also sets CMAKE_PROJECT_TOP_LEVEL_INCLUDES to ./infra/cmake/use-fetch-content.cmake, reducing to the same case as above
  3. Building on a system/in a context where beman-install-library is resolvable from CMAKE_PREFIX_PATH

It appears that all of the CI workflows explicitly inject "./infra/cmake" into CMAKE_PREFIX_PATH via the strategy matrix, which is why CI flows remain green.

Recommendation

This project's top-level CMakeLists.txt file should likely change:

find_package(beman-install-library REQUIRED)

to:

find_package(
    beman-install-library REQUIRED
    HINTS "${CMAKE_CURRENT_LIST_DIR}/infra/cmake"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions