# Build recipe for cmake.
#
# Copyright (c) 2018-2021 Matias Fonzo, <selk@dragora.org>.
#
# 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.

# Exit immediately on any error
set -e

program=cmake
version=3.19.5
release=1

# Define a category for the output of the package name
pkgcategory=devel

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch="https://cmake.org/files/v${version%.*}/$tarname"

description="
Cross-platform make system.

CMake is a family of tools designed to build, test and package
software.  CMake is used to control the software compilation process
using simple platform and compiler independent configuration files.
"

homepage=https://www.cmake.org
license=Custom

build()
{
    unpack "${tardir}/$tarname"

    cd "$srcdir"

    # Set sane permissions
    chmod -R u+w,go-w,a+rX-s .

    mkdir BUILD
    cd BUILD

    ../configure CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     --prefix=/usr \
     --mandir=$mandir \
     --docdir=$docsdir \
     --system-curl \
     --system-expat \
     --system-zlib \
     --system-bzip2 \
     --system-libarchive \
     --no-system-jsoncpp \
     --parallel=$jobs

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install
}

