Try to build a static build on MSYS2

This commit is contained in:
David Hrdlička
2022-02-07 20:25:31 +01:00
parent 1fa9db221b
commit bb25829dbc
2 changed files with 62 additions and 70 deletions

View File

@@ -79,25 +79,6 @@ if(APPLE)
endif()
endif()
if(QT)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (USE_QT6)
set(QT_MAJOR 6)
else()
set(QT_MAJOR 5)
endif()
# if we want to use qt5-static to eliminate need for bundling qt dlls (windows)
#set(QT_STATIC ON)
# needed to build with qt5-static if both qt5 and qt5-static are installed
#set(CMAKE_PREFIX_PATH "path/to/qt5-static")
find_package(Qt${QT_MAJOR} COMPONENTS Core Widgets OpenGL REQUIRED)
find_package(Qt${QT_MAJOR}LinguistTools REQUIRED)
endif()
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
if(APPLE)
@@ -174,13 +155,6 @@ else()
install(TARGETS 86Box)
endif()
# prepare everything for Qt5 bundle creation
if (APPLE AND QT)
set(prefix "86Box.app/Contents")
set(INSTALL_RUNTIME_DIR "${prefix}/MacOS")
set(INSTALL_CMAKE_DIR "${prefix}/Resources")
endif()
# loads a macro to install Qt5 plugins on macOS
# based on https://stackoverflow.com/questions/35612687/cmake-macos-x-bundle-with-bundleutiliies-for-qt-application
macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var _prefix)
@@ -201,15 +175,11 @@ endmacro()
# Install our dependencies to the macOS bundle
if(APPLE)
if (NOT QT)
install(CODE "
include(BundleUtilities)
get_filename_component(CMAKE_INSTALL_PREFIX_ABSOLUTE \${CMAKE_INSTALL_PREFIX} ABSOLUTE)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/86Box.app\" \"\" \"\")"
COMPONENT Runtime)
endif()
if (QT)
set(prefix "86Box.app/Contents")
set(INSTALL_RUNTIME_DIR "${prefix}/MacOS")
set(INSTALL_CMAKE_DIR "${prefix}/Resources")
# using the install_qt5_plugin to add Qt plugins into the macOS app bundle
if (USE_QT6)
install_qt5_plugin("Qt6::QCocoaIntegrationPlugin" QT_PLUGINS ${prefix})
@@ -249,7 +219,12 @@ if(APPLE)
install(CODE "include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"${QT_PLUGINS}\" \"${DIRS}\")")
endif()
else()
install(CODE "
include(BundleUtilities)
get_filename_component(CMAKE_INSTALL_PREFIX_ABSOLUTE \${CMAKE_INSTALL_PREFIX} ABSOLUTE)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/86Box.app\" \"\" \"\")"
COMPONENT Runtime)
endif()

View File

@@ -3,8 +3,25 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (USE_QT6)
set(QT_MAJOR 6)
else()
set(QT_MAJOR 5)
endif()
set(QT_STATIC ${STATIC_BUILD})
if(QT_STATIC AND MINGW)
set(CMAKE_PREFIX_PATH "$ENV{MSYSTEM_PREFIX}/qt5-static")
endif()
find_package(Threads REQUIRED)
find_package(Qt${QT_MAJOR} COMPONENTS Core Widgets OpenGL REQUIRED)
find_package(Qt${QT_MAJOR}LinguistTools REQUIRED)
add_library(plat STATIC
qt.c