objectbox / objectbox/objectbox-dart

`linux/CMakeLists.txt`: support offline/sandboxed builds via OBJECTBOX_PREBUILT_DIR

Open Beginner friendly
#808 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Dart
Stars
1.2k
Forks
162
Avg merge
15m
Merged PRs (30d)
1

Description

Is there an existing issue?
Use case

objectbox_flutter_libs downloads libobjectbox.so at CMake configure time via
FetchContent_Populate. This makes it impossible to build in any network-isolated
environment — Flatpak/Flathub sandboxes, NixOS, Gentoo, Guix, and any distro build
system that restricts network access during the build.

The usual cmake workaround — setting FETCHCONTENT_SOURCE_DIR_OBJECTBOX-DOWNLOAD
has no effect here. FetchContent_Populate (the pre-3.14 deprecated API) internally
spawns a cmake subbuild: a separate cmake process. Cache variables set in the
parent do not propagate to that subbuild. This is a documented cmake limitation.

Proposed solution

Check a cmake variable OBJECTBOX_PREBUILT_DIR before calling FetchContent_Populate.
If the variable points to an already-extracted archive, skip the download entirely:

if(DEFINED OBJECTBOX_PREBUILT_DIR AND EXISTS "${OBJECTBOX_PREBUILT_DIR}/lib/libobjectbox.so")
    set(objectbox-download_SOURCE_DIR "${OBJECTBOX_PREBUILT_DIR}")
else()
    FetchContent_GetProperties(objectbox-download)
    if(NOT objectbox-download_POPULATED)
        FetchContent_Populate(objectbox-download)
    endif()
endif()

Distro packagers would pass:

-DOBJECTBOX_PREBUILT_DIR=/path/to/extracted/objectbox-c
Describe alternatives you've considered
Current workaround

We maintain a local patch in the Flatpak manifest for
ebalistyka-app that checks a hardcoded
relative path. It works but is fragile and app-specific.

Additional context

This patch proposes no breaking changes

Flathub has growing Flutter adoption. Every Flutter app using objectbox needs this
patch to pass Flathub CI (which runs flatpak-builder --sandbox with no network).
A one-line upstream fix lets all downstream packagers drop their local patches.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with linux/CMakeLists.txt and inspect the existing FetchContent_Populate flow for objectbox-download. Verify that an extracted directory passed through -DOBJECTBOX_PREBUILT_DIR is used without downloading, while the existing download path still works; done means sandboxed or network-isolated configuration can complete with the prebuilt library.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.