Skip to content

build: find core-cpp with find_package before CPMAddPackage, so packaged builds need no fetch #840

Description

@Yaraslaut

Problem

Since the move to core-cpp (#806), core-cpp is always added with CPMAddPackage, and the CPM bootstrap (cmake/CPM.cmake) always runs file(DOWNLOAD ...) for CPM.cmake itself. There is no find_package(core-cpp) first, unlike glaze, which is found first and fetched only when missing.

That makes morph awkward to package. A package manager build (vcpkg, Conan, a distro) must not reach the network during the build, and should use its own copy of every dependency. Today a vcpkg port has to:

  1. download core-cpp itself and pass -DCPM_core-cpp_SOURCE=<dir> so CPMAddPackage uses it, and
  2. pre-seed CPM_SOURCE_CACHE/cpm/CPM_<version>.cmake with the exact bootstrap file, so the unconditional file(DOWNLOAD) is skipped by its hash check.

Both work, but they depend on CPM internals (the cache layout and the CPM_<name>_SOURCE variable) and break silently if the pinned CPM version or cache layout changes.

Expected

The same treatment glaze gets:

find_package(core-cpp 0.5 CONFIG QUIET)
if(NOT core-cpp_FOUND)
    CPMAddPackage(NAME core-cpp ...)
endif()

and the CPM bootstrap only included when something actually needs fetching. With core-cpp installed (it already installs a core-cpp CMake package), a packaged build would then need no CPM at all.

Notes

  • morphConfig.cmake already does find_dependency(core-cpp 0.5 CONFIG), so an installed core-cpp is the expected consumer shape.
  • If core-cpp is found rather than built in-tree, morph's install should not try to install core-cpp again (currently CORE_CPP_INSTALL follows MORPH_INSTALL).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: ciSubsystem: cienhancementNew feature or requesttriage: validWell-framed; implement as written

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions