void-packages/common/build-style/cmake.sh
Jürgen Buchmüller 8679124272 build-style cmake: replace -isystem with -I
Many packages depending on Qt5 or Qt4 and built with cmake
generate "flags.make" files with -isystem for include paths.
With gcc6 this results in e.g. "#include_next <stdlib.h>" giving
an error, because a -isystem /usr/include is in the wrong place.
The simple fix is to replace "-isystem" with just "-I".
2017-01-15 02:50:14 +01:00

56 lines
1.5 KiB
Bash

#
# This helper is for templates using cmake.
#
do_configure() {
local cmake_args=
[ ! -d ${cmake_builddir:=build} ] && mkdir -p ${cmake_builddir}
cd ${cmake_builddir}
if [ "$CROSS_BUILD" ]; then
cat > cross_${XBPS_CROSS_TRIPLET}.cmake <<_EOF
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)
SET(CMAKE_C_COMPILER ${XBPS_CROSS_TRIPLET}-gcc)
SET(CMAKE_CXX_COMPILER ${XBPS_CROSS_TRIPLET}-g++)
SET(CMAKE_CROSSCOMPILING TRUE)
SET(CMAKE_FIND_ROOT_PATH ${XBPS_CROSS_BASE})
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
cmake_args+=" -DCMAKE_TOOLCHAIN_FILE=cross_${XBPS_CROSS_TRIPLET}.cmake"
fi
cmake_args+=" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release"
if [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
cmake_args+=" -DCMAKE_INSTALL_LIBDIR=lib32"
else
cmake_args+=" -DCMAKE_INSTALL_LIBDIR=lib"
fi
cmake_args+=" -DCMAKE_INSTALL_SBINDIR=bin"
cmake ${cmake_args} ${configure_args} $(echo ${cmake_builddir}|sed \
-e 's|[^/]$|/|' -e 's|[^/]*||g' -e 's|/|../|g')
# Replace -isystem with -I for Qt4 and Qt5 packages
find -name flags.make -exec sed -i "{}" -e"s;-isystem;-I;g" \;
}
do_build() {
: ${make_cmd:=make}
cd ${cmake_builddir:=build}
${make_cmd} ${makejobs} ${make_build_args} ${make_build_target}
}
do_install() {
: ${make_cmd:=make}
: ${make_install_target:=install}
cd ${cmake_builddir:=build}
${make_cmd} DESTDIR=${DESTDIR} ${make_install_args} ${make_install_target}
}