Fix Qt5::WindowsIntegrationPlugin being included on non-windows platforms

This commit is contained in:
Phillip Stephens 2021-02-26 15:12:44 -08:00
parent cb2d826cbd
commit 92fe1a9577
1 changed files with 124 additions and 117 deletions

View File

@ -4,23 +4,23 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
if(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) if (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
set(QT_HOMEBREW_PATH /usr/local/opt/qt) set(QT_HOMEBREW_PATH /usr/local/opt/qt)
elseif(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL arm64) elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
set(QT_HOMEBREW_PATH /opt/homebrew/opt/qt) set(QT_HOMEBREW_PATH /opt/homebrew/opt/qt)
else() else ()
set(QT_HOMEBREW_PATH "") set(QT_HOMEBREW_PATH "")
endif() endif ()
find_package(Qt6Widgets QUIET PATHS ${QT_HOMEBREW_PATH}) find_package(Qt6Widgets QUIET PATHS ${QT_HOMEBREW_PATH})
if(Qt6Widgets_FOUND) if (Qt6Widgets_FOUND)
find_package(Qt6 COMPONENTS Core5Compat Network Widgets Xml Gui REQUIRED PATHS ${QT_HOMEBREW_PATH}) find_package(Qt6 COMPONENTS Core5Compat Network Widgets Xml Gui REQUIRED PATHS ${QT_HOMEBREW_PATH})
set(QUAZIP_QT_MAJOR_VERSION 6 CACHE STRING "") set(QUAZIP_QT_MAJOR_VERSION 6 CACHE STRING "")
else() else ()
find_package(Qt5Widgets REQUIRED PATHS ${QT_HOMEBREW_PATH}) find_package(Qt5Widgets REQUIRED PATHS ${QT_HOMEBREW_PATH})
find_package(Qt5 COMPONENTS Network Widgets Xml Gui REQUIRED PATHS ${QT_HOMEBREW_PATH}) find_package(Qt5 COMPONENTS Network Widgets Xml Gui REQUIRED PATHS ${QT_HOMEBREW_PATH})
set(QUAZIP_QT_MAJOR_VERSION 5 CACHE STRING "") set(QUAZIP_QT_MAJOR_VERSION 5 CACHE STRING "")
endif() endif ()
set(BUILD_SHARED_LIBS OFF CACHE BOOL "") set(BUILD_SHARED_LIBS OFF CACHE BOOL "")
set(QUAZIP_INSTALL OFF CACHE BOOL "") set(QUAZIP_INSTALL OFF CACHE BOOL "")
@ -58,7 +58,7 @@ add_executable(hecl-gui WIN32 MACOSX_BUNDLE
main.cpp main.cpp
${QUAZIP_SRCS} ${QUAZIP_SRCS}
) )
target_compile_definitions(hecl-gui PRIVATE target_compile_definitions(hecl-gui PRIVATE
# Disable implicit conversions from ASCII to QString. # Disable implicit conversions from ASCII to QString.
@ -79,9 +79,9 @@ target_compile_definitions(hecl-gui PRIVATE
# Allows for more efficient string concatenation, resulting in less temporaries. # Allows for more efficient string concatenation, resulting in less temporaries.
-DQT_USE_QSTRINGBUILDER -DQT_USE_QSTRINGBUILDER
) )
if(Qt6Widgets_FOUND) if (Qt6Widgets_FOUND)
set(Qt_LIBS set(Qt_LIBS
Qt6::Core Qt6::Core
Qt6::Core5Compat Qt6::Core5Compat
@ -89,26 +89,33 @@ if(Qt6Widgets_FOUND)
Qt6::Network Qt6::Network
Qt6::Widgets Qt6::Widgets
Qt6::Xml) Qt6::Xml)
else() set(QT5_WINDOWS_INTEGRATION_PLUGIN "")
else ()
set(Qt_LIBS set(Qt_LIBS
Qt5::Core Qt5::Core
Qt5::Gui Qt5::Gui
Qt5::Network Qt5::Network
Qt5::Widgets Qt5::Widgets
Qt5::Xml Qt5::Xml)
if (WIN32)
set(QT5_WINDOWS_INTEGRATION_PLUGIN
Qt5::WindowsIntegrationPlugin) Qt5::WindowsIntegrationPlugin)
endif() else ()
set(QT5_WINDOWS_INTEGRATION_PLUGIN "")
endif ()
endif ()
target_link_libraries(hecl-gui PRIVATE target_link_libraries(hecl-gui PRIVATE
${Qt_LIBS} ${Qt_LIBS}
hecl-light hecl-light
zeus zeus
QuaZip::QuaZip QuaZip::QuaZip
) ${QT5_WINDOWS_INTEGRATION_PLUGIN})
target_include_directories(hecl-gui PRIVATE quazip/quazip) target_include_directories(hecl-gui PRIVATE quazip/quazip)
target_compile_definitions(hecl-gui PRIVATE QUAZIP_STATIC=1) target_compile_definitions(hecl-gui PRIVATE QUAZIP_STATIC=1)
if(APPLE) if (APPLE)
target_sources(hecl-gui PRIVATE target_sources(hecl-gui PRIVATE
MacOSSystemVersion.hpp MacOSSystemVersion.hpp
MacOSSystemVersion.mm MacOSSystemVersion.mm
@ -118,39 +125,39 @@ if(APPLE)
) )
find_library(FOUNDATION_LIBRARY Foundation) find_library(FOUNDATION_LIBRARY Foundation)
target_link_libraries(hecl-gui PRIVATE ${FOUNDATION_LIBRARY}) target_link_libraries(hecl-gui PRIVATE ${FOUNDATION_LIBRARY})
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
target_link_libraries(hecl-gui PRIVATE target_link_libraries(hecl-gui PRIVATE
dl dl
pthread pthread
) )
endif() endif ()
if(WIN32) if (WIN32)
target_sources(hecl-gui PRIVATE target_sources(hecl-gui PRIVATE
platforms/win/hecl-gui.manifest platforms/win/hecl-gui.manifest
platforms/win/hecl-gui.rc platforms/win/hecl-gui.rc
) )
target_link_libraries(hecl-gui PRIVATE target_link_libraries(hecl-gui PRIVATE
Version) Version)
elseif(APPLE) elseif (APPLE)
target_sources(hecl-gui PRIVATE platforms/mac/mainicon.icns) target_sources(hecl-gui PRIVATE platforms/mac/mainicon.icns)
set_source_files_properties(platforms/mac/mainicon.icns PROPERTIES set_source_files_properties(platforms/mac/mainicon.icns PROPERTIES
MACOSX_PACKAGE_LOCATION Resources MACOSX_PACKAGE_LOCATION Resources
) )
endif() endif ()
add_subdirectory(platforms/freedesktop) add_subdirectory(platforms/freedesktop)
declare_qticon_target() declare_qticon_target()
target_sources(hecl-gui PRIVATE mainicon_qt.cpp) target_sources(hecl-gui PRIVATE mainicon_qt.cpp)
if(COMMAND add_sanitizers) if (COMMAND add_sanitizers)
add_sanitizers(hecl-gui) add_sanitizers(hecl-gui)
endif() endif ()
if (NOT MSVC) if (NOT MSVC)
target_compile_options(hecl-gui PRIVATE -Wno-misleading-indentation) target_compile_options(hecl-gui PRIVATE -Wno-misleading-indentation)
endif() endif ()
set_target_properties(hecl-gui PROPERTIES set_target_properties(hecl-gui PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platforms/mac/Info.plist" MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/platforms/mac/Info.plist"
) )