2014-01-07 17:29:49 +01:00
|
|
|
#
|
|
|
|
# This helper is for templates using cmake.
|
|
|
|
#
|
|
|
|
do_configure() {
|
2016-05-26 07:33:58 +02:00
|
|
|
local cmake_args=
|
2015-06-29 13:19:50 +02:00
|
|
|
[ ! -d ${cmake_builddir:=build} ] && mkdir -p ${cmake_builddir}
|
|
|
|
cd ${cmake_builddir}
|
2014-01-07 17:29:49 +01:00
|
|
|
|
2020-11-01 13:37:41 +01:00
|
|
|
if [ -z "$CHROOT_READY" ]; then
|
|
|
|
cat >bootstrap.cmake <<_EOF
|
|
|
|
SET(CMAKE_SYSTEM_NAME Linux)
|
|
|
|
SET(CMAKE_SYSTEM_VERSION 1)
|
|
|
|
|
|
|
|
SET(CMAKE_C_COMPILER ${CC})
|
|
|
|
SET(CMAKE_CXX_COMPILER ${CXX})
|
|
|
|
|
2020-11-21 06:14:37 +01:00
|
|
|
SET(CMAKE_FIND_ROOT_PATH "${XBPS_MASTERDIR}/usr;${XBPS_MASTERDIR}")
|
2020-11-01 13:37:41 +01:00
|
|
|
|
|
|
|
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
|
|
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
|
|
_EOF
|
|
|
|
configure_args+=" -DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake"
|
|
|
|
elif [ "$CROSS_BUILD" ]; then
|
2018-10-03 08:07:08 +02:00
|
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
|
|
x86_64*) _CMAKE_SYSTEM_PROCESSOR=x86_64 ;;
|
|
|
|
i686*) _CMAKE_SYSTEM_PROCESSOR=x86 ;;
|
|
|
|
aarch64*) _CMAKE_SYSTEM_PROCESSOR=aarch64 ;;
|
|
|
|
arm*) _CMAKE_SYSTEM_PROCESSOR=arm ;;
|
|
|
|
mips*) _CMAKE_SYSTEM_PROCESSOR=mips ;;
|
2019-01-05 23:45:27 +01:00
|
|
|
ppc64le*) _CMAKE_SYSTEM_PROCESSOR=ppc64le ;;
|
2019-01-01 00:24:00 +01:00
|
|
|
ppc64*) _CMAKE_SYSTEM_PROCESSOR=ppc64 ;;
|
2020-04-30 01:06:03 +02:00
|
|
|
ppcle*) _CMAKE_SYSTEM_PROCESSOR=ppcle ;;
|
2019-05-31 19:27:12 +02:00
|
|
|
ppc*) _CMAKE_SYSTEM_PROCESSOR=ppc ;;
|
2018-10-03 08:07:08 +02:00
|
|
|
*) _CMAKE_SYSTEM_PROCESSOR=generic ;;
|
|
|
|
esac
|
2014-01-07 17:29:49 +01:00
|
|
|
cat > cross_${XBPS_CROSS_TRIPLET}.cmake <<_EOF
|
|
|
|
SET(CMAKE_SYSTEM_NAME Linux)
|
|
|
|
SET(CMAKE_SYSTEM_VERSION 1)
|
|
|
|
|
2017-08-16 18:07:14 +02:00
|
|
|
SET(CMAKE_C_COMPILER ${CC})
|
|
|
|
SET(CMAKE_CXX_COMPILER ${CXX})
|
2014-01-07 17:29:49 +01:00
|
|
|
SET(CMAKE_CROSSCOMPILING TRUE)
|
|
|
|
|
2018-10-03 08:07:08 +02:00
|
|
|
SET(CMAKE_SYSTEM_PROCESSOR ${_CMAKE_SYSTEM_PROCESSOR})
|
|
|
|
|
2020-11-21 06:14:37 +01:00
|
|
|
SET(CMAKE_FIND_ROOT_PATH "${XBPS_CROSS_BASE}/usr;${XBPS_CROSS_BASE}")
|
2014-01-07 17:29:49 +01:00
|
|
|
|
|
|
|
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
|
|
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
|
|
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
|
|
_EOF
|
2020-10-08 16:47:01 +02:00
|
|
|
cmake_args+=" -DCMAKE_TOOLCHAIN_FILE=${wrksrc}/${build_wrksrc}/${cmake_builddir}/cross_${XBPS_CROSS_TRIPLET}.cmake"
|
2014-01-07 17:29:49 +01:00
|
|
|
fi
|
2019-01-12 14:34:46 +01:00
|
|
|
cmake_args+=" -DCMAKE_INSTALL_PREFIX=/usr"
|
2021-03-14 14:18:03 +01:00
|
|
|
cmake_args+=" -DCMAKE_BUILD_TYPE=None"
|
2020-12-22 22:06:08 +01:00
|
|
|
cmake_args+=" -DCMAKE_INSTALL_LIBDIR=lib${XBPS_TARGET_WORDSIZE}"
|
2022-09-05 15:59:44 +02:00
|
|
|
cmake_args+=" -DCMAKE_INSTALL_SYSCONFDIR=/etc"
|
2022-08-10 17:43:23 +02:00
|
|
|
|
|
|
|
if [ "$CROSS_BUILD" ]; then
|
|
|
|
cmake_args+=" -DQT_HOST_PATH=/usr"
|
|
|
|
# QT_HOST_PATH isn't enough in my system,
|
|
|
|
# which have binfmts support on and off
|
|
|
|
cmake_args+=" -DQT_HOST_PATH_CMAKE_DIR=/usr/lib/cmake"
|
|
|
|
fi
|
2015-01-14 10:50:48 +01:00
|
|
|
|
2019-10-19 15:25:45 +02:00
|
|
|
if [[ $build_helper = *"qemu"* ]]; then
|
2019-04-15 03:07:52 +02:00
|
|
|
echo "SET(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static)" \
|
|
|
|
>> cross_${XBPS_CROSS_TRIPLET}.cmake
|
|
|
|
fi
|
|
|
|
|
2016-06-26 00:48:46 +02:00
|
|
|
cmake_args+=" -DCMAKE_INSTALL_SBINDIR=bin"
|
2014-01-07 17:29:49 +01:00
|
|
|
|
2021-01-29 16:24:17 +01:00
|
|
|
export CMAKE_GENERATOR="${CMAKE_GENERATOR:-Ninja}"
|
2021-07-15 23:56:25 +02:00
|
|
|
# Remove -pipe: https://gitlab.kitware.com/cmake/cmake/issues/19590
|
|
|
|
CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
|
2021-02-24 14:17:26 +01:00
|
|
|
cmake ${cmake_args} ${configure_args} \
|
|
|
|
${LIBS:+-DCMAKE_C_STANDARD_LIBRARIES="$LIBS"} \
|
|
|
|
${LIBS:+-DCMAKE_CXX_STANDARD_LIBRARIES="$LIBS"} \
|
|
|
|
${wrksrc}/${build_wrksrc}
|
2017-01-15 02:50:14 +01:00
|
|
|
|
2021-02-20 06:16:56 +01:00
|
|
|
# Replace -isystem with -I
|
|
|
|
if [ "$CMAKE_GENERATOR" = "Unix Makefiles" ]; then
|
2021-02-20 07:10:46 +01:00
|
|
|
find . -name flags.make -exec sed -i -e 's/-isystem/-I/g' "{}" +
|
2021-02-20 06:16:56 +01:00
|
|
|
elif [ "$CMAKE_GENERATOR" = Ninja ]; then
|
|
|
|
sed -i -e 's/-isystem/-I/g' build.ninja
|
|
|
|
fi
|
2014-01-07 17:29:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
do_build() {
|
2021-01-29 16:24:17 +01:00
|
|
|
: ${make_cmd:=ninja}
|
2014-01-07 17:29:49 +01:00
|
|
|
|
2015-06-29 13:19:50 +02:00
|
|
|
cd ${cmake_builddir:=build}
|
2014-01-07 17:29:49 +01:00
|
|
|
${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}
|
|
|
|
}
|
|
|
|
|
2017-11-20 23:34:40 +01:00
|
|
|
do_check() {
|
2021-02-19 16:56:57 +01:00
|
|
|
: ${make_cmd:=ninja}
|
|
|
|
|
2018-03-05 10:46:51 +01:00
|
|
|
cd ${cmake_builddir:=build}
|
|
|
|
|
2021-02-19 16:56:57 +01:00
|
|
|
if [ -z "$make_check_target" ]; then
|
|
|
|
case $make_cmd in
|
|
|
|
make)
|
|
|
|
if make -q test 2>/dev/null; then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
if [ $? -eq 2 ]; then
|
|
|
|
msg_warn 'No target to "make test".\n'
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
ninja)
|
|
|
|
if ! ninja -t query test >/dev/null 2>&1; then
|
|
|
|
msg_warn 'No target to "ninja test".\n'
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
msg_warn "Can't run tests with '$make_cmd', define do_check.\n"
|
|
|
|
;;
|
|
|
|
esac
|
2017-11-20 23:34:40 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
: ${make_check_target:=test}
|
|
|
|
|
2022-06-10 21:04:57 +02:00
|
|
|
${make_check_pre} ${make_cmd} ${makejobs} ${make_check_args} ${make_check_target}
|
2017-11-20 23:34:40 +01:00
|
|
|
}
|
|
|
|
|
2014-01-07 17:29:49 +01:00
|
|
|
do_install() {
|
2021-01-29 16:24:17 +01:00
|
|
|
: ${make_cmd:=ninja}
|
2014-01-07 17:29:49 +01:00
|
|
|
: ${make_install_target:=install}
|
|
|
|
|
2015-06-29 13:19:50 +02:00
|
|
|
cd ${cmake_builddir:=build}
|
2020-02-06 10:34:32 +01:00
|
|
|
DESTDIR=${DESTDIR} ${make_cmd} ${make_install_args} ${make_install_target}
|
2014-01-07 17:29:49 +01:00
|
|
|
}
|