Skip to content

CMake: install(EXPORT) fails with BUILD_SHARED_LIBS=OFF #717

@lnagel

Description

@lnagel

Problem

When building with BUILD_SHARED_LIBS=OFF, the install(EXPORT libdigidocppExport ...) at src/CMakeLists.txt:256 fails because the export set includes digidocpp but not its private link dependencies (minizip, digidocpp_priv/digidocpp_tsl). CMake requires all linked targets to be in the export set for static libraries.

Error:

CMake Error: install(EXPORT "libdigidocppExport" ...) includes target "digidocpp"
which requires target "minizip" that is not in any export set.

Suggested fix

Either:

  1. Add the private targets (minizip, digidocpp_priv) to the export set, or
  2. Guard the export install with a static build check:
if(BUILD_SHARED_LIBS AND NOT ANDROID)
    install(EXPORT libdigidocppExport ...)
endif()

Current workaround

Setting ANDROID=TRUE before add_subdirectory() skips the export install via the existing if(NOT ANDROID) guard at line 264, but this is a misuse of that flag.

Context

Found while building Python bindings with BUILD_SHARED_LIBS=OFF for self-contained wheel packaging. Affects v4.3.0 and current main.

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