From: Stephen Kelly Date: Tue, 21 Aug 2012 11:12:57 +0000 (+0200) Subject: Make it possible to use static builds of Qt with CMake. X-Git-Tag: v5.0.0-beta1~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ae6d4c77eb338be3f2189bfaffdcd3c38cc57333;p=profile%2Fivi%2Fqtbase.git Make it possible to use static builds of Qt with CMake. Parse the prl files generated by qmake to get the link dependencies. They contain all the information we need, and they are the only location with all the right information. Change-Id: Id9dcc988f20a744297502eff008de085326cdbcf Reviewed-by: Brad King Reviewed-by: Clinton Stimpson Reviewed-by: Stephen Kelly --- diff --git a/mkspecs/cmake/Qt5BasicConfig.cmake.in b/mkspecs/cmake/Qt5BasicConfig.cmake.in index b3756d9..394ccce 100644 --- a/mkspecs/cmake/Qt5BasicConfig.cmake.in +++ b/mkspecs/cmake/Qt5BasicConfig.cmake.in @@ -67,54 +67,40 @@ endif() set(_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES \"$${CMAKE_QT5_MODULE_DEPS}\") !!IF !isEmpty(CMAKE_STATIC_TYPE) -# For static builds, we also list the dependencies of -# Qt so that consumers can build. -!!IF isEqual(CMAKE_MODULE_NAME, Core) +if (NOT Qt5_EXCLUDE_STATIC_DEPENDENCIES) + # For static builds, we also list the dependencies of + # Qt so that consumers can build easily. + + macro(macro_process_prl_file prl_file_location Configuration) + if (EXISTS \"${prl_file_location}\") + file(STRINGS \"${prl_file_location}\" prl_strings REGEX \"QMAKE_PRL_LIBS\") + string(REGEX REPLACE \"QMAKE_PRL_LIBS *= *([^\\n]*)\" \"\\\\1\" static_depends ${prl_strings} ) + string(STRIP ${static_depends} static_depends) + if (_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES) + set(_list_sep \";\") + endif() + set(_Qt5$${CMAKE_MODULE_NAME}_STATIC_${Configuration}_LIB_DEPENDENCIES \"${_list_sep}${static_depends}\") + endif() + endmacro() -set(_Qt5Core_LIB_DEPENDENCIES) -!!IF contains(QT_CONFIG, system-zlib) -find_package(ZLIB REQUIRED) -list(APPEND _Qt5Core_LIB_DEPENDENCIES ${ZLIB_LIBRARIES}) -!!ENDIF - -!!IF contains(QT_CONFIG, glib) -find_library(QT_GLIB_LIBRARY NAMES glib-2.0 ) -find_library(QT_GTHREAD_LIBRARY NAMES gthread-2.0 ) -mark_as_advanced(QT_GLIB_LIBRARY) -mark_as_advanced(QT_GTHREAD_LIBRARY) -list(APPEND _Qt5Core_LIB_DEPENDENCIES ${QT_GTHREAD_LIBRARY} ${QT_GLIB_LIBRARY}) +!!IF !isEmpty(CMAKE_DEBUG_TYPE) +!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE) + macro_process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG) +!!ELSE + macro_process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_DEBUG}\" DEBUG) !!ENDIF - -!!IF contains(QT_CONFIG, clock-monotonic) -find_library(QT_RT_LIBRARY NAMES rt) -mark_as_advanced(QT_RT_LIBRARY) -list(APPEND _Qt5Core_LIB_DEPENDENCIES ${QT_RT_LIBRARY}) !!ENDIF -set(CMAKE_THREAD_PREFER_PTHREADS 1) -find_package(Threads) -if(CMAKE_USE_PTHREADS_INIT) - list(APPEND _Qt5Core_LIB_DEPENDENCIES ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) -endif() - -!!ENDIF # Core - -!!IF isEqual(CMAKE_MODULE_NAME, Gui) - -set(_Qt5Gui_LIB_DEPENDENCIES) - -!!IF contains(QT_CONFIG, system-png) -find_package(PNG REQUIRED) -list(APPEND _Qt5Gui_LIB_DEPENDENCIES ${PNG_LIBRARIES}) +!!IF !isEmpty(CMAKE_RELEASE_TYPE) +!!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE) + macro_process_prl_file(\"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE) +!!ELSE + macro_process_prl_file(\"$${CMAKE_LIB_DIR}$${CMAKE_PRL_FILE_LOCATION_RELEASE}\" RELEASE) !!ENDIF - -!!IF contains(QT_CONFIG, system-jpeg) -find_package(JPEG REQUIRED) -list(APPEND _Qt5Gui_LIB_DEPENDENCIES ${JPEG_LIBRARIES}) !!ENDIF -!!ENDIF # Gui +endif() !!ENDIF # Static @@ -122,7 +108,7 @@ macro(_populate_imported_target_properties Configuration LIB_LOCATION IMPLIB_LOC set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) set_target_properties(Qt5::$${CMAKE_MODULE_NAME} PROPERTIES - \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}\" + \"IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}\" \"${_Qt5$${CMAKE_MODULE_NAME}_LIB_DEPENDENCIES}${_Qt5$${CMAKE_MODULE_NAME}_STATIC_${Configuration}_LIB_DEPENDENCIES}\" !!IF isEmpty(CMAKE_LIB_DIR_IS_ABSOLUTE) \"IMPORTED_LOCATION_${Configuration}\" \"${_qt5$${CMAKE_MODULE_NAME}_install_prefix}/$${CMAKE_LIB_DIR}${LIB_LOCATION}\" !!ELSE diff --git a/mkspecs/features/create_cmake.prf b/mkspecs/features/create_cmake.prf index 75e0cdf..450a6d9 100644 --- a/mkspecs/features/create_cmake.prf +++ b/mkspecs/features/create_cmake.prf @@ -64,6 +64,9 @@ macx { !isEmpty(CMAKE_STATIC_TYPE) { CMAKE_LIB_FILE_LOCATION_DEBUG = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}_debug.a CMAKE_LIB_FILE_LOCATION_RELEASE = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.a + + CMAKE_PRL_FILE_LOCATION_DEBUG = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}_debug.prl + CMAKE_PRL_FILE_LOCATION_RELEASE = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.prl } else { CONFIG(qt_framework, qt_framework|qt_no_framework) { CMAKE_LIB_FILE_LOCATION_DEBUG = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.framework/Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX} @@ -100,6 +103,9 @@ macx { !isEmpty(CMAKE_STATIC_TYPE) { CMAKE_IMPLIB_FILE_LOCATION_DEBUG = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d.lib CMAKE_IMPLIB_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.lib + + CMAKE_PRL_FILE_LOCATION_DEBUG = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d.prl + CMAKE_PRL_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.prl } else { CMAKE_IMPLIB_FILE_LOCATION_DEBUG = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}d$$eval(QT.$${MODULE}.MAJOR_VERSION).lib CMAKE_IMPLIB_FILE_LOCATION_RELEASE = Qt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}$$eval(QT.$${MODULE}.MAJOR_VERSION).lib @@ -109,6 +115,8 @@ macx { !isEmpty(CMAKE_STATIC_TYPE) { CMAKE_LIB_FILE_LOCATION_DEBUG = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.a CMAKE_LIB_FILE_LOCATION_RELEASE = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.a + CMAKE_PRL_FILE_LOCATION_DEBUG = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.prl + CMAKE_PRL_FILE_LOCATION_RELEASE = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.prl } else { CMAKE_LIB_FILE_LOCATION_DEBUG = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.so.$$eval(QT.$${MODULE}.VERSION) CMAKE_LIB_FILE_LOCATION_RELEASE = libQt$${CMAKE_MODULE_NAME}$${QT_LIBINFIX}.so.$$eval(QT.$${MODULE}.VERSION)