Problem
When building with ODR_BUNDLE_ASSETS=ON (the default), CMakeLists.txt copies third-party data files into odrcore's data dir, e.g.:
file(COPY_FILE "${LIBMAGIC_DATABASE_PATH}" "${ODR_BUILD_ODR_DATA_PATH}/magic.mgc")
But LIBMAGIC_DATABASE_PATH (and the analogous FONTCONFIG_DATA_PATH, POPPLER_DATA_PATH, PDF2HTMLEX_DATA_PATH) is only consumed by CMake — it is never discovered by CMake. It has to be injected from outside via -DLIBMAGIC_DATABASE_PATH=....
Today only odrcore's own conanfile.py provides it, by reading the dependency's runenv (MAGIC) and forwarding it as a CMake variable:
tc.variables["LIBMAGIC_DATABASE_PATH"] = envvars.get("MAGIC")
This has two consequences:
- Any other recipe that builds odrcore (e.g. the
conan-odr-index recipe) must replicate this runenv→CMake bridging, or ODR_BUNDLE_ASSETS silently breaks: the variable is empty, so file(COPY_FILE "" ...) fails with cannot copy a directory.
- It couples the CMake build to a conan runenv convention rather than to CMake package metadata.
Why find_package doesn't already provide it
find_package(libmagic) (via conan CMakeDeps) exposes the target, include dirs and lib dirs, and libmagic_PACKAGE_FOLDER_<CONFIG>, but not the data-file path — because the libmagic recipe advertises magic.mgc only via a runtime env var (self.runenv_info.define_path("MAGIC", .../res/magic.mgc)), and does not declare cpp_info.resdirs. So libmagic_RES_DIRS_<CONFIG> is empty and there is no CMake-native path to the file.
Suggested direction
Let odrcore's CMake discover the data files from the dependencies rather than requiring injected absolute paths, e.g.:
- Use
libmagic_RES_DIRS (and equivalents) if the upstream packages are taught to declare cpp_info.resdirs, or
- Derive the path from
libmagic_PACKAGE_FOLDER_<CONFIG> / the imported target location within CMakeLists.txt, so find_package(libmagic) is sufficient and no recipe needs to bridge runenv→CMake.
Workaround in the meantime
Consumers that provide the data paths at runtime (e.g. Android via odr::GlobalParams::set_libmagic_database_path) can build with ODR_BUNDLE_ASSETS=OFF and ship the data files themselves — which is what OpenDocument.droid now does (see opendocument-app/OpenDocument.droid#480).
Problem
When building with
ODR_BUNDLE_ASSETS=ON(the default),CMakeLists.txtcopies third-party data files into odrcore's data dir, e.g.:But
LIBMAGIC_DATABASE_PATH(and the analogousFONTCONFIG_DATA_PATH,POPPLER_DATA_PATH,PDF2HTMLEX_DATA_PATH) is only consumed by CMake — it is never discovered by CMake. It has to be injected from outside via-DLIBMAGIC_DATABASE_PATH=....Today only odrcore's own
conanfile.pyprovides it, by reading the dependency's runenv (MAGIC) and forwarding it as a CMake variable:This has two consequences:
conan-odr-indexrecipe) must replicate this runenv→CMake bridging, orODR_BUNDLE_ASSETSsilently breaks: the variable is empty, sofile(COPY_FILE "" ...)fails withcannot copy a directory.Why
find_packagedoesn't already provide itfind_package(libmagic)(via conan CMakeDeps) exposes the target, include dirs and lib dirs, andlibmagic_PACKAGE_FOLDER_<CONFIG>, but not the data-file path — because the libmagic recipe advertisesmagic.mgconly via a runtime env var (self.runenv_info.define_path("MAGIC", .../res/magic.mgc)), and does not declarecpp_info.resdirs. Solibmagic_RES_DIRS_<CONFIG>is empty and there is no CMake-native path to the file.Suggested direction
Let odrcore's CMake discover the data files from the dependencies rather than requiring injected absolute paths, e.g.:
libmagic_RES_DIRS(and equivalents) if the upstream packages are taught to declarecpp_info.resdirs, orlibmagic_PACKAGE_FOLDER_<CONFIG>/ the imported target location withinCMakeLists.txt, sofind_package(libmagic)is sufficient and no recipe needs to bridge runenv→CMake.Workaround in the meantime
Consumers that provide the data paths at runtime (e.g. Android via
odr::GlobalParams::set_libmagic_database_path) can build withODR_BUNDLE_ASSETS=OFFand ship the data files themselves — which is what OpenDocument.droid now does (see opendocument-app/OpenDocument.droid#480).