WIP: cmake-static
This commit is contained in:
parent
0e94d12398
commit
e97a875c6c
|
@ -0,0 +1,22 @@
|
|||
pkgname=cmake-static
|
||||
pkgver=1
|
||||
pkgrel=1
|
||||
arch=('any')
|
||||
pkgdesc='CMake wrapper for using static libraries and glibc compat header'
|
||||
depends=('cmake')
|
||||
license=("GPL")
|
||||
url='https://github.com/martchus/pkgbuilds'
|
||||
source=(cmake-static.sh
|
||||
toolchain-static.cmake
|
||||
glibc-2.17.h::https://raw.githubusercontent.com/billziss-gh/glibc-compat/master/glibc-2.17.h)
|
||||
sha256sums=('SKIP' 'SKIP' 'TODO')
|
||||
|
||||
package() {
|
||||
install -d "${pkgdir}"/usr/bin
|
||||
install -d "${pkgdir}"/usr/share/cmake-static
|
||||
install -d "${pkgdir}"/usr/static/{toolchain,include}
|
||||
install -m 644 toolchain-static.cmake "${pkgdir}"/usr/static/toolchain
|
||||
install -m 644 glibc-2.17.h "${pkgdir}"/usr/static/include
|
||||
install -m 755 cmake-static "${pkgdir}"/usr/bin/cmake-static
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
static_prefix=/usr/static
|
||||
|
||||
PATH=${static_prefix}/bin:$PATH cmake \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH="${static_prefix}" \
|
||||
-DCMAKE_INSTALL_LIBDIR:PATH=lib \
|
||||
-DBUILD_SHARED_LIBS:BOOL=OFF \
|
||||
-DCMAKE_TOOLCHAIN_FILE=/usr/share/static/toolchain/toolchain-static.cmake \
|
||||
"$@"
|
|
@ -0,0 +1,39 @@
|
|||
# This toolchain file helps building a mostly statically linked executable by
|
||||
# defining certain variables. It is mainly focusing on dependencies used by Qt.
|
||||
|
||||
# prefer libraries from "static" sub-prefix
|
||||
set(CMAKE_FIND_ROOT_PATH "/usr/static;${CMAKE_FIND_ROOT_PATH}")
|
||||
|
||||
# prefer static libraries
|
||||
# note: It is of no use to set the real variable CMAKE_FIND_LIBRARY_SUFFIXES
|
||||
# here because it gets overridden by CMake after loading the toolchain
|
||||
# file. The project needs to make the actual override if enforcing static
|
||||
# libraries is required.
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES_OVERRIDE ".a;.so")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "$ENV{LDFLAGS} -static-libgcc -static-libstdc++" CACHE STRING "linker flags for static builds" FORCE)
|
||||
set(CMAKE_C_FLAGS "$ENV{CFLAGS} -include /usr/static/include/glibc-2.17.h" CACHE STRING "C flags for static builds" FORCE)
|
||||
set(CMAKE_CPP_FLAGS "$ENV{CPPFLAGS} -include /usr/static/include/glibc-2.17.h" CACHE STRING "Cpp flags for static builds" FORCE)
|
||||
set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -include /usr/static/include/glibc-2.17.h" CACHE STRING "C++ flags for static builds" FORCE)
|
||||
set(OPENSSL_USE_STATIC_LIBS ON)
|
||||
set(BOOST_USE_STATIC_LIBS ON)
|
||||
|
||||
# workaround limitations in upstream pkg-config files and CMake find modules
|
||||
set(pkgcfg_lib_libbrotlicommon_brotlicommon "/usr/lib/libbrotlicommon-static.a" CACHE INTERNAL "static libbrotlicommon")
|
||||
set(pkgcfg_lib_libbrotlienc_brotlienc "/usr/lib/libbrotlienc-static.a;/usr/lib/libbrotlicommon-static.a" CACHE INTERNAL "static libbrotliend")
|
||||
set(pkgcfg_lib_libbrotlidec_brotlidec "/usr/lib/libbrotlidec-static.a;/usr/lib/libbrotlicommon-static.a" CACHE INTERNAL "static libbrotlidec")
|
||||
set(libbrotlicommon_STATIC_LDFLAGS "${pkgcfg_lib_libbrotlicommon_brotlicommon}" CACHE INTERNAL "static libbrotlicommon")
|
||||
set(libbrotlienc_STATIC_LDFLAGS "${pkgcfg_lib_libbrotlienc_brotlienc}" CACHE INTERNAL "static libbrotliend")
|
||||
set(libbrotlidec_STATIC_LDFLAGS "${pkgcfg_lib_libbrotlidec_brotlidec}" CACHE INTERNAL "static libbrotlidec")
|
||||
|
||||
# define dependencies of various static libraries as CMake doesn't pull them
|
||||
# reliably automatically
|
||||
# note: It would be possible to deduce the dependencies via pkg-config. However,
|
||||
# for simplicity I'm hard-coding the dependencies for now. In some cases the
|
||||
# pkg-config file wouldn't work anyways because it is only covering the shared
|
||||
# version (despite use of `-static`).
|
||||
set(OPENSSL_DEPENDENCIES "-ldl;-pthread" CACHE INTERNAL "dependencies of static OpenSSL libraries")
|
||||
set(LIBPNG_DEPENDENCIES "-lz" CACHE INTERNAL "dependencies of static libpng")
|
||||
set(GLIB2_DEPENDENCIES "-pthread" CACHE INTERNAL "dependencies of static Glib2")
|
||||
set(FREETYPE_DEPENDENCIES "-lbz2;-lharfbuzz;-lfreetype;-lbrotlidec-static;-lbrotlicommon-static" CACHE INTERNAL "dependencies of static FreeType2 library")
|
||||
set(HARFBUZZ_DEPENDENCIES "-lglib-2.0;${GLIB2_DEPENDENCIES};-lm;-lfreetype;-lgraphite2" CACHE INTERNAL "dependencies of static HarfBuzz library")
|
||||
set(DBUS1_DEPENDENCIES "-pthread" CACHE INTERNAL "dependencies of static D-Bus1 library")
|
Loading…
Reference in New Issue