distributable:
  url: https://github.com/assimp/assimp/archive/v{{version}}.tar.gz
  strip-components: 1
versions:
  github: assimp/assimp
dependencies:
  zlib.net: '*'
build:
  dependencies:
    gnu.org/make: '*'
    cmake.org: '*'
    ninja-build.org: '*'
    darwin:
      curl.se: '*'
      gnu.org/patch: '*'
  script:
    - run: curl $PATCH | patch -p1 || true
      if: <5.3.0
    - cmake -S . -B build -G Ninja $CMAKE_ARGS
    - cmake --build build
    - cmake --install build
    - run: cp -a contrib {{prefix}}/include
      if: '>=5.3.0'
  env:
    PATCH: https://github.com/assimp/assimp/commit/5a89d6fee138f8bc979b508719163a74ddc9a384.patch?full_index=1
    CMAKE_ARGS:
      - -DCMAKE_INSTALL_PREFIX="{{prefix}}
      - -DCMAKE_INSTALL_LIBDIR=lib
      - -DCMAKE_BUILD_TYPE=Release
      - -DCMAKE_FIND_FRAMEWORK=LAST
      - -DCMAKE_VERBOSE_MAKEFILE=ON
      - -Wno-dev
      - -DASSIMP_BUILD_TESTS=OFF
      - -DASSIMP_BUILD_ASSIMP_TOOLS=ON
      - -DCMAKE_INSTALL_RPATH="{{prefix}}"
provides:
  - bin/assimp
test:
  script:
    - cc -std=c++11 test.cpp -lassimp -o test
    - ./test
    - assimp export test.obj test.ply
    - assimp version | grep {{version.marketing}}
