|
| 1 | +# Alembic (.abc) vertex-animation import — Anim epic Slice B (#519), sub-slice B2. |
| 2 | +# |
| 3 | +# Vendors Imath 3 + Alembic (both BSD-3-Clause) via FetchContent, statically, |
| 4 | +# with every optional component OFF (no HDF5, Python, tests, binaries, install). |
| 5 | +# Exposes an imported target `qtmesh_alembic` that the app links; the C++ side |
| 6 | +# is #ifdef ENABLE_ALEMBIC-guarded so a build without this still compiles. |
| 7 | +# |
| 8 | +# Why build from source rather than find_package: Alembic + Imath system |
| 9 | +# packages are absent or version-skewed across our three targets (macOS via |
| 10 | +# brew, Ubuntu CI, Windows MinGW). FetchContent gives one reproducible version |
| 11 | +# everywhere, matching how the project already vendors ONNX Runtime / libsodium |
| 12 | +# / tinyexr. |
| 13 | +# |
| 14 | +# Dependency chain: Alembic FIND_PACKAGE(Imath) → we build Imath as a |
| 15 | +# subproject first, point Imath_DIR at its generated build-tree config so |
| 16 | +# Alembic's find_package(Imath CONFIG) resolves to the target we just built. |
| 17 | + |
| 18 | +if(TARGET qtmesh_alembic) |
| 19 | + return() |
| 20 | +endif() |
| 21 | + |
| 22 | +include(FetchContent) |
| 23 | + |
| 24 | +set(QTMESH_IMATH_TAG "v3.1.12" CACHE STRING "Imath git tag") |
| 25 | +set(QTMESH_ALEMBIC_TAG "1.8.8" CACHE STRING "Alembic git tag") |
| 26 | + |
| 27 | +# ---- Imath --------------------------------------------------------------- |
| 28 | +# Static, no tests/python. IMATH_INSTALL stays ON: Alembic's own |
| 29 | +# INSTALL(EXPORT AlembicTargets) is unconditional and references Imath, so |
| 30 | +# Imath MUST be in an export set too or CMake's generate step fails |
| 31 | +# ("target Alembic requires target Imath that is not in any export set"). |
| 32 | +# We never actually run `make install` from the app build, so an ON install |
| 33 | +# rule is harmless — it just keeps the export sets consistent. |
| 34 | +set(IMATH_INSTALL ON CACHE BOOL "" FORCE) |
| 35 | +set(IMATH_INSTALL_PKG_CONFIG OFF CACHE BOOL "" FORCE) |
| 36 | +set(PYTHON OFF CACHE BOOL "" FORCE) |
| 37 | +set(BUILD_TESTING OFF CACHE BOOL "" FORCE) |
| 38 | +set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) |
| 39 | + |
| 40 | +FetchContent_Declare( |
| 41 | + qtmesh_imath |
| 42 | + GIT_REPOSITORY https://github.com/AcademySoftwareFoundation/Imath.git |
| 43 | + GIT_TAG ${QTMESH_IMATH_TAG} |
| 44 | + GIT_SHALLOW TRUE |
| 45 | +) |
| 46 | +FetchContent_MakeAvailable(qtmesh_imath) |
| 47 | + |
| 48 | +# Alembic's find_package(Imath) resolves against a CONFIG. Imath-as-subproject |
| 49 | +# writes its package config under the build dir; point find_package there. |
| 50 | +if(NOT DEFINED Imath_DIR) |
| 51 | + set(Imath_DIR "${qtmesh_imath_BINARY_DIR}/config" CACHE PATH "" FORCE) |
| 52 | +endif() |
| 53 | + |
| 54 | +# ---- Alembic ------------------------------------------------------------- |
| 55 | +# Everything optional OFF: no HDF5 backend (we only read the modern Ogawa |
| 56 | +# backend), no tests/binaries/python/prman/maya/arnold, static lib. |
| 57 | +set(USE_HDF5 OFF CACHE BOOL "" FORCE) |
| 58 | +set(USE_TESTS OFF CACHE BOOL "" FORCE) |
| 59 | +set(USE_BINARIES OFF CACHE BOOL "" FORCE) |
| 60 | +set(USE_EXAMPLES OFF CACHE BOOL "" FORCE) |
| 61 | +set(USE_PYALEMBIC OFF CACHE BOOL "" FORCE) |
| 62 | +set(USE_ARNOLD OFF CACHE BOOL "" FORCE) |
| 63 | +set(USE_PRMAN OFF CACHE BOOL "" FORCE) |
| 64 | +set(USE_MAYA OFF CACHE BOOL "" FORCE) |
| 65 | +set(ALEMBIC_SHARED_LIBS OFF CACHE BOOL "" FORCE) |
| 66 | +set(ALEMBIC_ILMBASE_LINK_STATIC ON CACHE BOOL "" FORCE) |
| 67 | +set(ALEMBIC_LIB_INSTALL_DIR "lib" CACHE STRING "" FORCE) |
| 68 | + |
| 69 | +FetchContent_Declare( |
| 70 | + qtmesh_alembic |
| 71 | + GIT_REPOSITORY https://github.com/alembic/alembic.git |
| 72 | + GIT_TAG ${QTMESH_ALEMBIC_TAG} |
| 73 | + GIT_SHALLOW TRUE |
| 74 | +) |
| 75 | +FetchContent_MakeAvailable(qtmesh_alembic) |
| 76 | + |
| 77 | +# Alembic's core library target is `Alembic` (with an `Alembic::Alembic` alias |
| 78 | +# in recent versions). Wrap whichever exists behind our stable name so the app |
| 79 | +# links `qtmesh_alembic` regardless. |
| 80 | +if(TARGET Alembic::Alembic) |
| 81 | + add_library(qtmesh_alembic INTERFACE) |
| 82 | + target_link_libraries(qtmesh_alembic INTERFACE Alembic::Alembic Imath::Imath) |
| 83 | +elseif(TARGET Alembic) |
| 84 | + add_library(qtmesh_alembic INTERFACE) |
| 85 | + target_link_libraries(qtmesh_alembic INTERFACE Alembic Imath::Imath) |
| 86 | + # The plain `Alembic` target's public include dirs cover its own headers; |
| 87 | + # Imath::Imath carries the Imath headers Alembic's public API exposes. |
| 88 | +else() |
| 89 | + message(FATAL_ERROR "Alembic.cmake: neither Alembic nor Alembic::Alembic target was created") |
| 90 | +endif() |
| 91 | + |
| 92 | +message(STATUS "Alembic ${QTMESH_ALEMBIC_TAG} + Imath ${QTMESH_IMATH_TAG} vendored (static)") |
0 commit comments