#
# Copyright 2012-2014 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name "zstd"
default_version "1.5.6"

license "BSD"
license_file "LICENSE"
skip_transitive_dependency_licensing true

dependency "libarchive"

version("1.5.6") { source sha256: "8c29e06cf42aacc1eafc4077ae2ec6c6fcb96a626157e0593d5e82a34fd403c1" }

source url: "https://github.com/facebook/zstd/releases/download/v#{version}/zstd-#{version}.tar.gz"

relative_path "zstd-#{version}"

build do
  env = with_standard_compiler_flags(with_embedded_path)

  cmake_build_dir = "#{project_dir}/build/cmake/builddir"

  command "mkdir #{cmake_build_dir}", env: env

  cmake_options = [
    "-DZSTD_BUILD_PROGRAMS=OFF",
    "-DZSTD_BUILD_STATIC=OFF",
    "-DZSTD_BUILD_SHARED=ON",
  ]

  cmake(*cmake_options, env: env, cwd: cmake_build_dir, prefix: "#{install_dir}/embedded")
end
