Skip to content
Snippets Groups Projects
  • Vladimir Davydov's avatar
    f3b31aee
    cmake: allow to bundle static dependencies in main project · f3b31aee
    Vladimir Davydov authored
    The BUILD_STATIC cmake config option forces the build system link
    Tarantool binary statically with its dependencies. It expects that all
    static libraries on which Tarantool binary depends are available at
    build time.
    
    We don't use this option directly to create static binaries because it
    would produce different results on different build systems. Instead, we
    use the separate cmake config located in the static-build directory,
    which fetches all Tarantool dependencies from a predefined location
    before building a static binary.
    
    Having a separate cmake config is inconvenient. Let's enable bundling of
    static binary dependencies right in the main project cmake config, like
    we bundle, for example, libcurl. To achieve that, the new build option
    was introduced BUILD_STATIC_WITH_BUNDLED_LIBS. It implies BUILD_STATIC
    and also fetches and builds all required dependencies, like the
    static-build cmake config used to. The latter doesn't do it anymore;
    from now on, it just sets BUILD_STATIC_WITH_BUNDLED_LIBS when building
    Tarantool. We can't remove the static-build cmake config yet because
    there are quire a few CI workflows depending on it.
    
    Note that, just like BUILD_STATIC, BUILD_STATIC_WITH_BUNDLED_LIBS
    doesn't imply OPENSSL_USE_STATIC_LIBS so the latter should be set
    explicitly if one wants to use the static openssl library. However,
    setting OPENSSL_USE_STATIC_LIBS with BUILD_STATIC_WITH_BUNDLED_LIBS will
    force the build system use bundled static openssl library.
    
    This patch is relatively straightforward. It just moves the external
    projects from /static-build/cmake/AddDependencyProjects.cmake to /cmake
    adding build dependencies where required and setting variables that are
    set by the corresponding /cmake/FindXXX.cmake configs.
    
    There are a few things that should be noted separately though:
     - We dropped the ZLIB_FOUND check from the main project cmake config.
       It was used for building EE but the latter is going to be broken
       anyway once this patch is committed. We'll fix it in following
       commits.
     - FindLibUnwind referenced zlib library by ZLIB::ZLIB. We don't set
       it for bundled zlib so let's use ZLIB_LIBRARIES instead.
     - We don't need to detect dependency cflags while building bundled
       libraries as we can reuse the flags set by the main project.
     - We don't use HARDENING_LDFLAGS because it makes no sense when
       building static libraries.
    
    Closes #9242
    
    NO_DOC=build
    NO_TEST=build
    NO_CHANGELOG=build
    
    (cherry picked from commit 98b38e89)
    f3b31aee
    History
    cmake: allow to bundle static dependencies in main project
    Vladimir Davydov authored
    The BUILD_STATIC cmake config option forces the build system link
    Tarantool binary statically with its dependencies. It expects that all
    static libraries on which Tarantool binary depends are available at
    build time.
    
    We don't use this option directly to create static binaries because it
    would produce different results on different build systems. Instead, we
    use the separate cmake config located in the static-build directory,
    which fetches all Tarantool dependencies from a predefined location
    before building a static binary.
    
    Having a separate cmake config is inconvenient. Let's enable bundling of
    static binary dependencies right in the main project cmake config, like
    we bundle, for example, libcurl. To achieve that, the new build option
    was introduced BUILD_STATIC_WITH_BUNDLED_LIBS. It implies BUILD_STATIC
    and also fetches and builds all required dependencies, like the
    static-build cmake config used to. The latter doesn't do it anymore;
    from now on, it just sets BUILD_STATIC_WITH_BUNDLED_LIBS when building
    Tarantool. We can't remove the static-build cmake config yet because
    there are quire a few CI workflows depending on it.
    
    Note that, just like BUILD_STATIC, BUILD_STATIC_WITH_BUNDLED_LIBS
    doesn't imply OPENSSL_USE_STATIC_LIBS so the latter should be set
    explicitly if one wants to use the static openssl library. However,
    setting OPENSSL_USE_STATIC_LIBS with BUILD_STATIC_WITH_BUNDLED_LIBS will
    force the build system use bundled static openssl library.
    
    This patch is relatively straightforward. It just moves the external
    projects from /static-build/cmake/AddDependencyProjects.cmake to /cmake
    adding build dependencies where required and setting variables that are
    set by the corresponding /cmake/FindXXX.cmake configs.
    
    There are a few things that should be noted separately though:
     - We dropped the ZLIB_FOUND check from the main project cmake config.
       It was used for building EE but the latter is going to be broken
       anyway once this patch is committed. We'll fix it in following
       commits.
     - FindLibUnwind referenced zlib library by ZLIB::ZLIB. We don't set
       it for bundled zlib so let's use ZLIB_LIBRARIES instead.
     - We don't need to detect dependency cflags while building bundled
       libraries as we can reuse the flags set by the main project.
     - We don't use HARDENING_LDFLAGS because it makes no sense when
       building static libraries.
    
    Closes #9242
    
    NO_DOC=build
    NO_TEST=build
    NO_CHANGELOG=build
    
    (cherry picked from commit 98b38e89)
.gitignore 3.25 KiB
_CPack_Packages
*.a
*.cbp
*.d
*.dylib
*.gcno
*.gcda
*.gcov
.git-ignore/
.pc/
coverity/
coverage/
coverage.info
*.o
*.reject
*.orig
*.rej
*.so
*~
*.swp*
.gitignore
.gdb_history
.tdbg_history*
CMakeFiles
CMakeCache.txt
CPackConfig.cmake
CPackSourceConfig.cmake
CTestTestfile.cmake
Testing/
./build
/build
.idea/
# Ignore Makefile in the stupid way for `tar --exclude-vcs-ignores`
/Makefile
./Makefile
src/Makefile
src/*/Makefile
src/*/*/Makefile
src/*/*/*/Makefile
doc/Makefile
doc/*/Makefile
extra/Makefile
extra/*/Makefile
extra/luarocks/hardcoded.lua
extra/luarocks/hardcoded.lua.c
perf/Makefile
test/Makefile
test/*/Makefile
test/*/*/Makefile
Doxyfile.API
RPM
*.src.rpm
*.i386.rpm
*.x86_64.rpm
tags
extra/txt2c
extra/bin2c
extra/lemon
extra/mkkeywordhash
extra/dist/tarantoolctl
extra/dist/tarantoolctl.1
extra/dist/tarantool.logrotate
extra/dist/tarantool@.service
extra/dist/tarantool.tmpfiles.conf
extra/dist/tarantool-generator
extra/exports.*
cmake_install.cmake
config.mk
config.guess
config.sub
doc/doxygen
doc/api
doc/www/content/doc/dev_guide.html
doc/www/content/doc/tnt.css
doc/www/content/doc/user_guide.html
doc/www/content/doc/user_guide/
doc/developer/dev_guide.txt
doc/man/tarantool.1
doc/man/tarantool_box.1
doc/user/tarantool_user_guide.txt
doc/tnt.ent
rpm/tarantool-1*.spec
extra/rpm.spec
extra/rpm/tarantool.rpm.spec
include/tarantool/config.h
src/trivia/config.h
install_manifest.txt
lcov
src/box/bootstrap.h
src/lua/*.lua.c
src/box/lua/*.lua.c
third_party/lua/*.lua.c
src/tarantool
src/module.h
tarantool-*.tar.gz
perf/*.perftest
test/enterprise-luatest
test/enterprise-tap
test/enterprise-unit
test/lib/
test/unit/*.test
test/unit/fiob
test/small/*.test
test/var
test/luajit-tap
test/unit/popen-child
third_party/luajit/src/luajit
third_party/luajit/lib/vmdef.lua
third_party/luajit/src/buildvm
third_party/luajit/src/lj_bcdef.h
third_party/luajit/src/lj_ffdef.h
third_party/luajit/src/lj_folddef.h
third_party/luajit/src/lj_libdef.h
third_party/luajit/src/lj_recdef.h
third_party/luajit/src/lj_vm.s
VERSION
src/00000000000000000001.snap
doc/sphinx/_build/*
!doc/sphinx/_build/.gitignore
doc/www/content/doc
extra/dist/default/tarantool
extra/com.tarantool.tarantool.plist
extra/postflight
build-area/*
debian/files
debian/stamp-makefile-build
debian/stamp-makefile-install
debian/tarantool-common.debhelper.log
debian/tarantool-common.postinst.debhelper
debian/tarantool-common.postrm.debhelper
debian/tarantool-common.prerm.debhelper
debian/tarantool-common.substvars
debian/tarantool-common.install
debian/tarantool-common/*
debian/tarantool-dev.debhelper.log
debian/tarantool-dev.substvars
debian/tarantool-dev.postinst.debhelper
debian/tarantool-dev.postrm.debhelper
debian/tarantool-dev/*
debian/tarantool.debhelper.log
debian/tarantool.substvars
debian/tarantool.postinst.debhelper
debian/tarantool.postrm.debhelper
debian/tarantool/*
debian/tmp/*
obj-*/
*.cdbs-config_list
parts/
prime/
stage/
ftp.log
sftp.log
ftpscript.txt
sftpscript.txt
*.md5sum
extra/deploy_key
compile_commands.json
jepsen-tests-prefix
.terraform
terraform.tfstate
terraform.tfstate.backup

# autogenerated files
src/box/sql/keywordhash.h
src/box/sql/parse.h
src/box/sql/parse.c
src/box/sql/opcodes.h
src/box/sql/opcodes.c

# static-build
static-build/*-prefix
static-build/Makefile
static-build/build

# macOS files
.DS_Store