mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-14 07:45:06 +00:00
cmake: Support building with Qt5 and Qt6
This allows developers to pick their flavor of Qt, potentially enabling more advanced integrations with Qt in the future. Eventually Qt5 support may be dropped in favor of Qt6. Fixes #811
This commit is contained in:
parent
f10096da98
commit
2acaf7c280
1 changed files with 89 additions and 29 deletions
|
@ -899,7 +899,7 @@ endfunction()
|
||||||
function(feature_frontend RESOLVE)
|
function(feature_frontend RESOLVE)
|
||||||
is_feature_enabled(FRONTEND T_CHECK)
|
is_feature_enabled(FRONTEND T_CHECK)
|
||||||
if(RESOLVE AND T_CHECK)
|
if(RESOLVE AND T_CHECK)
|
||||||
if(NOT HAVE_QT)
|
if(NOT (Qt6_FOUND OR Qt5_FOUND))
|
||||||
message(WARNING "${LOGPREFIX}Front-End requires Qt. Disabling...")
|
message(WARNING "${LOGPREFIX}Front-End requires Qt. Disabling...")
|
||||||
set_feature_disabled(FRONTEND ON)
|
set_feature_disabled(FRONTEND ON)
|
||||||
elseif(NOT HAVE_OBS_FRONTEND_API)
|
elseif(NOT HAVE_OBS_FRONTEND_API)
|
||||||
|
@ -1095,13 +1095,46 @@ if(REQUIRE_NVIDIA_CUDA AND D_PLATFORM_WINDOWS)
|
||||||
set(HAVE_NVIDIA_CUDA ON)
|
set(HAVE_NVIDIA_CUDA ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#- Qt5
|
#- Qt
|
||||||
set(HAVE_QT OFF)
|
|
||||||
if(REQUIRE_QT)
|
if(REQUIRE_QT)
|
||||||
find_package(Qt5
|
# Try Qt6 first...
|
||||||
COMPONENTS Widgets Core REQUIRED
|
find_package(Qt6
|
||||||
|
COMPONENTS Core Gui Widgets
|
||||||
|
CONFIG
|
||||||
|
HINTS
|
||||||
|
"${Qt6_DIR}"
|
||||||
|
"${Qt6_DIR}/lib"
|
||||||
|
"${Qt6_DIR}/lib/cmake"
|
||||||
|
"${Qt6_DIR}/lib/cmake/Qt6"
|
||||||
|
"${QTDIR}"
|
||||||
|
"${QTDIR}/lib"
|
||||||
|
"${QTDIR}/lib/cmake"
|
||||||
|
"${QTDIR}/lib/cmake/Qt6"
|
||||||
|
"${DepsPath}"
|
||||||
|
"${DepsPath}/lib"
|
||||||
|
"${DepsPath}/lib/cmake"
|
||||||
|
"${DepsPath}/lib/cmake/Qt6"
|
||||||
)
|
)
|
||||||
set(HAVE_QT ${Qt5_FOUND})
|
if(NOT Qt6_FOUND)
|
||||||
|
# If Qt6 isn't present, try Qt5
|
||||||
|
find_package(Qt5
|
||||||
|
COMPONENTS Core Gui Widgets
|
||||||
|
CONFIG
|
||||||
|
HINTS
|
||||||
|
"${Qt5_DIR}"
|
||||||
|
"${Qt5_DIR}/lib"
|
||||||
|
"${Qt5_DIR}/lib/cmake"
|
||||||
|
"${Qt5_DIR}/lib/cmake/Qt5"
|
||||||
|
"${QTDIR}"
|
||||||
|
"${QTDIR}/lib"
|
||||||
|
"${QTDIR}/lib/cmake"
|
||||||
|
"${QTDIR}/lib/cmake/Qt5"
|
||||||
|
"${DepsPath}"
|
||||||
|
"${DepsPath}/lib"
|
||||||
|
"${DepsPath}/lib/cmake"
|
||||||
|
"${DepsPath}/lib/cmake/Qt5"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Verify Requirements
|
# Verify Requirements
|
||||||
|
@ -1303,8 +1336,12 @@ if(REQUIRE_OBS_FRONTEND_API AND HAVE_OBS_FRONTEND_API)
|
||||||
list(APPEND PROJECT_LIBRARIES obs-frontend-api)
|
list(APPEND PROJECT_LIBRARIES obs-frontend-api)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(REQUIRE_QT AND HAVE_QT)
|
if(REQUIRE_QT)
|
||||||
list(APPEND PROJECT_LIBRARIES Qt5::Core Qt5::Widgets)
|
if(Qt5_FOUND)
|
||||||
|
list(APPEND PROJECT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets)
|
||||||
|
elseif(Qt6_FOUND)
|
||||||
|
list(APPEND PROJECT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -1949,7 +1986,7 @@ set_source_files_properties(${PROJECT_DATA} ${PROJECT_TEMPLATES} ${PROJECT_UI} P
|
||||||
)
|
)
|
||||||
|
|
||||||
# Prevent non-UI files from being Qt'd
|
# Prevent non-UI files from being Qt'd
|
||||||
if(HAVE_QT)
|
if(Qt5_Found OR Qt6_FOUND)
|
||||||
set_source_files_properties(${PROJECT_DATA} ${PROJECT_TEMPLATES} ${PROJECT_PRIVATE_GENERATED} ${PROJECT_PRIVATE_SOURCE} PROPERTIES
|
set_source_files_properties(${PROJECT_DATA} ${PROJECT_TEMPLATES} ${PROJECT_PRIVATE_GENERATED} ${PROJECT_PRIVATE_SOURCE} PROPERTIES
|
||||||
SKIP_AUTOGEN ON
|
SKIP_AUTOGEN ON
|
||||||
SKIP_AUTOMOC ON
|
SKIP_AUTOMOC ON
|
||||||
|
@ -2197,7 +2234,7 @@ if(D_PLATFORM_WINDOWS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Enable Qt if needed
|
# Enable Qt if needed
|
||||||
if(HAVE_QT)
|
if(Qt5_FOUND OR Qt6_FOUND)
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||||
AUTOUIC ON
|
AUTOUIC ON
|
||||||
AUTOUIC_SEARCH_PATHS "${PROJECT_SOURCE_DIR};${PROJECT_SOURCE_DIR}/ui"
|
AUTOUIC_SEARCH_PATHS "${PROJECT_SOURCE_DIR};${PROJECT_SOURCE_DIR}/ui"
|
||||||
|
@ -2254,8 +2291,9 @@ if(D_PLATFORM_MAC)
|
||||||
message(STATUS "${LOGPREFIX}Added post-build step for adjusting libobs-frontend-api linking path.")
|
message(STATUS "${LOGPREFIX}Added post-build step for adjusting libobs-frontend-api linking path.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Qt5
|
# Qt
|
||||||
if(REQUIRE_QT AND HAVE_QT)
|
if(REQUIRE_QT)
|
||||||
|
if(Qt5_FOUND)
|
||||||
# Figure out the linker location for Qt5::Core
|
# Figure out the linker location for Qt5::Core
|
||||||
mac_get_linker_id(TARGET Qt5::Core OUTPUT T_QT5CORE_LINK)
|
mac_get_linker_id(TARGET Qt5::Core OUTPUT T_QT5CORE_LINK)
|
||||||
|
|
||||||
|
@ -2276,6 +2314,28 @@ if(D_PLATFORM_MAC)
|
||||||
message(STATUS "${LOGPREFIX}Added post-build step for adjusting Qt5::Core linking path (Found: ${Qt5_DIR} resolved to ${T_QT5CORE_LINK}).")
|
message(STATUS "${LOGPREFIX}Added post-build step for adjusting Qt5::Core linking path (Found: ${Qt5_DIR} resolved to ${T_QT5CORE_LINK}).")
|
||||||
message(STATUS "${LOGPREFIX}Added post-build step for adjusting Qt5::Gui linking path (Found: ${Qt5_DIR} resolved to ${T_QT5GUI_LINK}).")
|
message(STATUS "${LOGPREFIX}Added post-build step for adjusting Qt5::Gui linking path (Found: ${Qt5_DIR} resolved to ${T_QT5GUI_LINK}).")
|
||||||
message(STATUS "${LOGPREFIX}Added post-build step for adjusting Qt5::Widgets linking path (Found: ${Qt5_DIR} resolved to ${T_QT5WIDGETS_LINK}).")
|
message(STATUS "${LOGPREFIX}Added post-build step for adjusting Qt5::Widgets linking path (Found: ${Qt5_DIR} resolved to ${T_QT5WIDGETS_LINK}).")
|
||||||
|
elseif(Qt6_FOUND)
|
||||||
|
# Figure out the linker location for Qt6::Core
|
||||||
|
mac_get_linker_id(TARGET Qt6::Core OUTPUT T_QT6CORE_LINK)
|
||||||
|
|
||||||
|
# Figure out the linker location for Qt6::Gui
|
||||||
|
mac_get_linker_id(TARGET Qt6::Gui OUTPUT T_QT6GUI_LINK)
|
||||||
|
|
||||||
|
# Figure out the linker location for Qt6::Widsgets
|
||||||
|
mac_get_linker_id(TARGET Qt6::Widgets OUTPUT T_QT6WIDGETS_LINK)
|
||||||
|
|
||||||
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||||
|
# - QtCore
|
||||||
|
COMMAND install_name_tool ARGS -change "${T_QT6CORE_LINK}" "@executable_path/../Frameworks/QtCore.framework/Versions/6/QtCore" $<TARGET_FILE:${PROJECT_NAME}>
|
||||||
|
# - QtGui
|
||||||
|
COMMAND install_name_tool ARGS -change "${T_QT6GUI_LINK}" "@executable_path/../Frameworks/QtGui.framework/Versions/6/QtGui" $<TARGET_FILE:${PROJECT_NAME}>
|
||||||
|
# - QtWidgets
|
||||||
|
COMMAND install_name_tool ARGS -change "${T_QT6WIDGETS_LINK}" "@executable_path/../Frameworks/QtWidgets.framework/Versions/6/QtWidgets" $<TARGET_FILE:${PROJECT_NAME}>
|
||||||
|
)
|
||||||
|
message(STATUS "${LOGPREFIX}Added post-build step for adjusting Qt6::Core linking path (Found: ${Qt6_DIR} resolved to ${T_QT6CORE_LINK}).")
|
||||||
|
message(STATUS "${LOGPREFIX}Added post-build step for adjusting Qt6::Gui linking path (Found: ${Qt6_DIR} resolved to ${T_QT6GUI_LINK}).")
|
||||||
|
message(STATUS "${LOGPREFIX}Added post-build step for adjusting Qt6::Widgets linking path (Found: ${Qt6_DIR} resolved to ${T_QT6WIDGETS_LINK}).")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue