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)