cmake: implement Linux 'release-static' build target

This commit is contained in:
xiphon 2020-06-21 00:08:37 +00:00
parent 0b2e74cdb5
commit e1e862bce4
3 changed files with 84 additions and 38 deletions

View file

@ -198,21 +198,6 @@ if(MINGW)
string(REGEX MATCH "^[^/]:/[^/]*" msys2_install_path "${CMAKE_C_COMPILER}") string(REGEX MATCH "^[^/]:/[^/]*" msys2_install_path "${CMAKE_C_COMPILER}")
message(STATUS "MSYS location: ${msys2_install_path}") message(STATUS "MSYS location: ${msys2_install_path}")
set(CMAKE_INCLUDE_PATH "${msys2_install_path}/mingw${ARCH_WIDTH}/include") set(CMAKE_INCLUDE_PATH "${msys2_install_path}/mingw${ARCH_WIDTH}/include")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/Qt/labs/folderlistmodel")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/Qt/labs/settings")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtGraphicalEffects")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtGraphicalEffects/private")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtMultimedia")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtQuick.2")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtQuick/Controls")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtQuick/Controls.2")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtQuick/Dialogs")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtQuick/Dialogs/Private")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtQuick/Layouts")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtQuick/PrivateWidgets")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtQuick/Templates.2")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtQuick/Window.2")
link_directories("${msys2_install_path}/mingw${ARCH_WIDTH}/qml/QtQuick/XmlListModel")
# This is necessary because otherwise CMake will make Boost libraries -lfoo # This is necessary because otherwise CMake will make Boost libraries -lfoo
# rather than a full path. Unfortunately, this makes the shared libraries get # rather than a full path. Unfortunately, this makes the shared libraries get
# linked due to a bug in CMake which misses putting -static flags around the # linked due to a bug in CMake which misses putting -static flags around the
@ -230,6 +215,7 @@ set(QT5_LIBRARIES
Qt5Network Qt5Network
Qt5Qml Qt5Qml
Qt5Svg Qt5Svg
Qt5Xml
) )
if(WITH_SCANNER) if(WITH_SCANNER)
@ -242,24 +228,28 @@ if(Qt5QmlModels_FOUND)
list(APPEND QT5_LIBRARIES Qt5QmlModels) list(APPEND QT5_LIBRARIES Qt5QmlModels)
endif() endif()
# TODO: drop this once we switch to Qt 5.12+
find_package(Qt5XmlPatterns QUIET)
if(Qt5XmlPatterns_FOUND)
list(APPEND QT5_LIBRARIES Qt5XmlPatterns)
endif()
foreach(QT5_MODULE ${QT5_LIBRARIES}) foreach(QT5_MODULE ${QT5_LIBRARIES})
find_package(${QT5_MODULE} REQUIRED) find_package(${QT5_MODULE} REQUIRED)
endforeach() endforeach()
find_package(PkgConfig) find_package(PkgConfig REQUIRED)
if(PKGCONFIG_FOUND) pkg_check_modules(QT5_PKG_CONFIG REQUIRED ${QT5_LIBRARIES})
pkg_check_modules(QT5_PKG_CONFIG ${QT5_LIBRARIES})
if(QT5_PKG_CONFIG_FOUND) if(QT5_PKG_CONFIG_FOUND)
set(QT5_PKG_CONFIG "QT5_PKG_CONFIG") set(QT5_PKG_CONFIG "QT5_PKG_CONFIG")
if(STATIC) if(STATIC)
set(QT5_PKG_CONFIG "${QT5_PKG_CONFIG}_STATIC") set(QT5_PKG_CONFIG "${QT5_PKG_CONFIG}_STATIC")
endif()
set(QT5_LIBRARIES ${${QT5_PKG_CONFIG}_LIBRARIES} ${${QT5_PKG_CONFIG}_LDFLAGS_OTHER})
include_directories(${${QT5_PKG_CONFIG}_INCLUDE_DIRS})
link_directories(${${QT5_PKG_CONFIG}_LIBRARY_DIRS})
endif() endif()
set(QT5_LIBRARIES ${${QT5_PKG_CONFIG}_LIBRARIES} ${${QT5_PKG_CONFIG}_LDFLAGS_OTHER})
include_directories(${${QT5_PKG_CONFIG}_INCLUDE_DIRS})
link_directories(${${QT5_PKG_CONFIG}_LIBRARY_DIRS})
endif() endif()
list(APPEND QT5_LIBRARIES list(APPEND QT5_LIBRARIES
@ -270,37 +260,91 @@ list(APPEND QT5_LIBRARIES
) )
if(STATIC) if(STATIC)
set(QT5_LIBRARIES set(QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/Qt/labs/folderlistmodel)
qtquickcontrols2plugin # has to be the first one, depends on Qt5QuickControls2 list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/Qt/labs/settings)
${QT5_LIBRARIES} list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtGraphicalEffects)
declarative_multimedia list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtGraphicalEffects/private)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtMultimedia)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtQuick.2)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtQuick/Controls)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtQuick/Controls.2)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtQuick/Dialogs)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtQuick/Dialogs/Private)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtQuick/Layouts)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtQuick/PrivateWidgets)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtQuick/Templates.2)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtQuick/Window.2)
list(APPEND QT5_EXTRA_PATHS ${QT5_PKG_CONFIG_Qt5Qml_PREFIX}/qml/QtQuick/XmlListModel)
set(QT5_EXTRA_LIBRARIES_LIST
qtquicktemplates2plugin
Qt5QuickTemplates2
qtquickcontrols2plugin
Qt5QuickControls2
dialogplugin dialogplugin
dialogsprivateplugin dialogsprivateplugin
qmlfolderlistmodelplugin qmlfolderlistmodelplugin
qmlsettingsplugin qmlsettingsplugin
qmlxmllistmodelplugin qmlxmllistmodelplugin
qquicklayoutsplugin qquicklayoutsplugin
)
if(UNIX AND NOT APPLE)
list(APPEND QT5_EXTRA_LIBRARIES_LIST
Qt5XcbQpa
xcb-static
Qt5ServiceSupport
)
endif()
if(WITH_SCANNER)
list(APPEND QT5_EXTRA_LIBRARIES_LIST
declarative_multimedia
Qt5MultimediaQuick_p
)
endif()
list(APPEND QT5_EXTRA_LIBRARIES_LIST
Qt5EventDispatcherSupport Qt5EventDispatcherSupport
Qt5FontDatabaseSupport Qt5FontDatabaseSupport
Qt5MultimediaQuick_p
Qt5PacketProtocol Qt5PacketProtocol
Qt5ThemeSupport Qt5ThemeSupport
qtgraphicaleffectsplugin qtgraphicaleffectsplugin
qtgraphicaleffectsprivate qtgraphicaleffectsprivate
qtquick2plugin qtquick2plugin
qtquickcontrolsplugin qtquickcontrolsplugin
qtquicktemplates2plugin
widgetsplugin widgetsplugin
windowplugin windowplugin
) )
set(QT5_EXTRA_LIBRARIES)
foreach(LIBRARY ${QT5_EXTRA_LIBRARIES_LIST})
find_library(${LIBRARY}_LIBRARY ${LIBRARY} PATHS ${QT5_EXTRA_PATHS})
list(APPEND QT5_EXTRA_LIBRARIES ${${LIBRARY}_LIBRARY})
endforeach()
if(MINGW) if(MINGW)
list(APPEND QT5_LIBRARIES qtfreetype) list(APPEND QT5_EXTRA_LIBRARIES qtfreetype)
if(CMAKE_BUILD_TYPE STREQUAL "Debug") if(CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND QT5_LIBRARIES D3D11 Dwrite D2d1) list(APPEND QT5_EXTRA_LIBRARIES D3D11 Dwrite D2d1)
endif() endif()
endif() endif()
set(QT5_LIBRARIES
${QT5_EXTRA_LIBRARIES}
${QT5_LIBRARIES}
)
if(UNIX AND NOT APPLE)
pkg_check_modules(X11_XCB REQUIRED x11-xcb)
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
list(APPEND QT5_LIBRARIES
${FONTCONFIG_STATIC_LIBRARIES}
${X11_XCB_STATIC_LIBRARIES}
)
endif()
endif() endif()
message(STATUS "Using Boost include dir at ${Boost_INCLUDE_DIRS}") message(STATUS "Using Boost include dir at ${Boost_INCLUDE_DIRS}")

View file

@ -31,6 +31,9 @@ scanner:
release: release:
mkdir -p $(builddir)/release && cd $(builddir)/release && cmake -D DEV_MODE=$(or ${DEV_MODE},OFF) -D ARCH="x86-64" -D CMAKE_BUILD_TYPE=Release $(topdir) && $(MAKE) mkdir -p $(builddir)/release && cd $(builddir)/release && cmake -D DEV_MODE=$(or ${DEV_MODE},OFF) -D ARCH="x86-64" -D CMAKE_BUILD_TYPE=Release $(topdir) && $(MAKE)
release-static:
mkdir -p $(builddir)/release && cd $(builddir)/release && cmake -D STATIC=ON -D DEV_MODE=$(or ${DEV_MODE},OFF) -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Release $(topdir) && $(MAKE)
debug-static-win64: debug-static-win64:
mkdir -p $(builddir)/debug && cd $(builddir)/debug && cmake -D STATIC=ON -G "MSYS Makefiles" -D DEV_MODE=$(or ${DEV_MODE},ON) -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Debug -D BUILD_TAG="win-x64" -D CMAKE_TOOLCHAIN_FILE=$(topdir)/cmake/64-bit-toolchain.cmake -D MSYS2_FOLDER=$(shell cd ${MINGW_PREFIX}/.. && pwd -W) -D MINGW=ON $(topdir) && $(MAKE) mkdir -p $(builddir)/debug && cd $(builddir)/debug && cmake -D STATIC=ON -G "MSYS Makefiles" -D DEV_MODE=$(or ${DEV_MODE},ON) -D ARCH="x86-64" -D BUILD_64=ON -D CMAKE_BUILD_TYPE=Debug -D BUILD_TAG="win-x64" -D CMAKE_TOOLCHAIN_FILE=$(topdir)/cmake/64-bit-toolchain.cmake -D MSYS2_FOLDER=$(shell cd ${MINGW_PREFIX}/.. && pwd -W) -D MINGW=ON $(topdir) && $(MAKE)

View file

@ -94,11 +94,8 @@
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin); Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
#endif #endif
Q_IMPORT_PLUGIN(QSvgIconPlugin) Q_IMPORT_PLUGIN(QSvgIconPlugin)
Q_IMPORT_PLUGIN(QGifPlugin)
Q_IMPORT_PLUGIN(QICNSPlugin) Q_IMPORT_PLUGIN(QICNSPlugin)
Q_IMPORT_PLUGIN(QICOPlugin)
Q_IMPORT_PLUGIN(QJpegPlugin) Q_IMPORT_PLUGIN(QJpegPlugin)
Q_IMPORT_PLUGIN(QMngPlugin)
Q_IMPORT_PLUGIN(QSvgPlugin) Q_IMPORT_PLUGIN(QSvgPlugin)
Q_IMPORT_PLUGIN(QTgaPlugin) Q_IMPORT_PLUGIN(QTgaPlugin)
Q_IMPORT_PLUGIN(QTiffPlugin) Q_IMPORT_PLUGIN(QTiffPlugin)
@ -130,7 +127,9 @@ Q_IMPORT_PLUGIN(QtQuick2PrivateWidgetsPlugin)
Q_IMPORT_PLUGIN(QtQuickControls2Plugin) Q_IMPORT_PLUGIN(QtQuickControls2Plugin)
Q_IMPORT_PLUGIN(QtQuickTemplates2Plugin) Q_IMPORT_PLUGIN(QtQuickTemplates2Plugin)
Q_IMPORT_PLUGIN(QmlXmlListModelPlugin) Q_IMPORT_PLUGIN(QmlXmlListModelPlugin)
#ifdef WITH_SCANNER
Q_IMPORT_PLUGIN(QMultimediaDeclarativeModule) Q_IMPORT_PLUGIN(QMultimediaDeclarativeModule)
#endif
#endif #endif