[Development] Improving CMake support for static builds
Jean-Michaël Celerier
jeanmichael.celerier at gmail.com
Fri Oct 12 20:32:10 CEST 2018
> but there is no information for the
flags needed to link against system libraries (freetype, harfbuzz,
etc.)
it would be so nice to add them ! currently I have to use the following
chthonic horror:
https://github.com/OSSIA/score/blob/master/base/app/StaticApp.cmake
I think that in Qt the pkg-config files are generated by a perl script,
maybe the same could be used for static builds ?
-------
Jean-Michaël Celerier
http://www.jcelerier.name
On Fri, Oct 12, 2018 at 9:12 PM Kyle Edwards <kyle.edwards at kitware.com>
wrote:
> Hello everyone,
>
> New Qt developer here. I'm trying to improve Qt's support for static
> builds using CMake - specifically, encoding transitive dependencies in
> the *Config.cmake files. I see that these files already have inter-
> module dependencies encoded in the exported targets'
> INTERFACE_LINK_LIBRARIES property, but there is no information for the
> flags needed to link against system libraries (freetype, harfbuzz,
> etc.)
>
> With dynamic builds, this isn't an issue, because the Qt modules
> themselves link against these libraries. However, static builds need
> this information to generate a fully linked binary. I've started a
> patch to add this support, but I'm not very familiar with Qt's
> buildsystem, and I was hoping someone could help me figure out how to
> get the information that I need. The start of my patch is below:
>
> -------------------------------------------------------------
>
> diff --git a/mkspecs/features/create_cmake.prf
> b/mkspecs/features/create_cmake.prf
> index 2ed708e..2d5ab55 100644
> --- a/mkspecs/features/create_cmake.prf
> +++ b/mkspecs/features/create_cmake.prf
> @@ -180,6 +180,7 @@ CMAKE_MKSPEC = $$[QMAKE_XSPEC]
> sorted_deps = $$sort_depends(QT.$${MODULE}.depends, QT.)
> mod_deps =
> lib_deps =
> +mod_link_flags =
> aux_mod_deps =
> aux_lib_deps =
> # Until CMake 3.0 is the minimum requirement of Qt 5, we need to
> filter
> @@ -197,6 +198,7 @@ for (dep, sorted_deps) {
> }
> CMAKE_MODULE_DEPS = $$join(mod_deps, ";")
> CMAKE_QT5_MODULE_DEPS = $$join(lib_deps, ";")
> +CMAKE_MODULE_LINK_FLAGS = $$join(mod_link_flags, ";")
> CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";")
> CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";")
>
> diff --git a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
> b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
> index 3ed6dd5..a320902 100644
> --- a/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
> +++ b/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
> @@ -64,6 +64,11 @@
> macro(_populate_$${CMAKE_MODULE_NAME}_target_properties Configuration
> LIB_LOCATI
> !!IF !isEmpty(CMAKE_LIB_SONAME)
> \"IMPORTED_SONAME_${Configuration}\" \"$${CMAKE_LIB_SONAME}\"
> !!ENDIF
> +!!IF !isEmpty(CMAKE_STATIC_TYPE)
> +!!IF !isEmpty(CMAKE_MODULE_LINK_FLAGS)
> + \"INTERFACE_LINK_OPTIONS\"
> \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_LINK_FLAGS}\"
> +!!ENDIF
> +!!ENDIF
> # For backward compatibility with CMake < 2.8.12
> \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\"
> \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\"
> )
> @@ -215,6 +220,10 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
> !!ENDIF
>
> !!IF !isEmpty(CMAKE_STATIC_TYPE)
> +!!IF !isEmpty(CMAKE_MODULE_LINK_FLAGS)
> + set(_Qt5$${CMAKE_MODULE_NAME}_LIB_LINK_FLAGS
> \"$${CMAKE_MODULE_LINK_FLAGS}\")
> +
> +!!ENDIF
> add_library(Qt5::$${CMAKE_MODULE_NAME} STATIC IMPORTED)
> set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY
> IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
> !!ELSE
>
> -------------------------------------------------------------
>
> I've figured out how to pass information into Qt5BasicConfig.cmake.in
> from create_cmake.prf, but I'm not sure where to get the link flags
> that need to be passed in. Any advice would be appreciated.
>
> Kyle
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20181012/2e3adf65/attachment.html>
More information about the Development
mailing list