mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 10:42:29 +01:00
Add Qt5 and Qt6 compatibility to CMake
Because the WebEngine got renamed we have to make it this ugly. This will only work with Qt5 for now because Qt6 still breaks things.
This commit is contained in:
parent
2fb9e728d0
commit
d5276b8169
@ -4,25 +4,12 @@ set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
find_package(
|
||||
QT NAMES Qt6 Qt5
|
||||
COMPONENTS Quick Widgets Gui LinguistTools Svg WebSockets WebEngine QuickCompiler
|
||||
REQUIRED)
|
||||
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS Quick Widgets Gui LinguistTools Svg WebSockets WebEngine QuickCompiler
|
||||
REQUIRED)
|
||||
|
||||
message(STATUS "[PROJECT] QT_VERSION_MAJOR = ${QT_VERSION_MAJOR}")
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(benchmark CONFIG REQUIRED)
|
||||
find_package(doctest CONFIG REQUIRED)
|
||||
|
||||
# CURL must be included before sentry
|
||||
# because sentry needs the module
|
||||
# and does not include it itself on macos...
|
||||
# CURL must be included before sentry because sentry needs the module and does not include it itself on macos...
|
||||
find_package(CURL CONFIG REQUIRED)
|
||||
find_package(sentry CONFIG REQUIRED)
|
||||
|
||||
@ -77,16 +64,85 @@ set(l10n
|
||||
|
||||
set_source_files_properties(${l10n} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/translations")
|
||||
|
||||
qt5_add_translation(qmFiles ${l10n})
|
||||
qt5_add_big_resources(fonts fonts.qrc)
|
||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS Core
|
||||
Quick
|
||||
Gui
|
||||
Widgets
|
||||
WebSockets
|
||||
Svg
|
||||
WebEngineCore
|
||||
WebEngineQuick
|
||||
WebChannel
|
||||
Positioning
|
||||
LinguistTools)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
qt5_add_resources(qml qml.qrc assets.qrc)
|
||||
else()
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
qt_add_resources(qml qml.qrc assets.qrc)
|
||||
else()
|
||||
qtquick_compiler_add_resources(qml qml.qrc assets.qrc)
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts})
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE ScreenPlaySDK
|
||||
ScreenPlayUtil
|
||||
benchmark::benchmark
|
||||
benchmark::benchmark_main
|
||||
doctest::doctest
|
||||
sentry::sentry
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::WebSockets
|
||||
Qt${QT_VERSION_MAJOR}::Svg
|
||||
Qt6::WebEngineCore
|
||||
Qt6::WebEngineQuick)
|
||||
qt_add_translation(qmFiles ${l10n})
|
||||
else()
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS Core
|
||||
Quick
|
||||
Gui
|
||||
Widgets
|
||||
WebSockets
|
||||
Svg
|
||||
LinguistTools
|
||||
WebEngine)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
qt_add_resources(qml qml.qrc assets.qrc)
|
||||
else()
|
||||
qtquick_compiler_add_resources(qml qml.qrc assets.qrc)
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts})
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE ScreenPlaySDK
|
||||
ScreenPlayUtil
|
||||
benchmark::benchmark
|
||||
benchmark::benchmark_main
|
||||
doctest::doctest
|
||||
sentry::sentry
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::WebSockets
|
||||
Qt${QT_VERSION_MAJOR}::Svg
|
||||
Qt5::WebEngine)
|
||||
qt5_add_translation(qmFiles ${l10n})
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts})
|
||||
qt_add_big_resources(fonts fonts.qrc)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}")
|
||||
|
||||
@ -110,8 +166,9 @@ endif()
|
||||
|
||||
if(APPLE)
|
||||
# Creates a ScreenPlay.app
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
OUTPUT_NAME ${PROJECT_NAME}
|
||||
set_target_properties(
|
||||
${PROJECT_NAME}
|
||||
PROPERTIES OUTPUT_NAME ${PROJECT_NAME}
|
||||
MACOSX_BUNDLE TRUE
|
||||
MACOSX_RPATH TRUE
|
||||
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
|
||||
@ -119,45 +176,27 @@ if(APPLE)
|
||||
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@loader_path/Libraries"
|
||||
RESOURCE "${RESOURCE_FILES}"
|
||||
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE
|
||||
XCODE_ATTRIBUTE_EXECUTABLE_NAME ${PROJECT_NAME}
|
||||
)
|
||||
XCODE_ATTRIBUTE_EXECUTABLE_NAME ${PROJECT_NAME})
|
||||
|
||||
# Needed for the Steam Workshop qml plugin
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/Workshop)
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg
|
||||
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ )
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg
|
||||
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe
|
||||
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ )
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe
|
||||
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler
|
||||
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ )
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler
|
||||
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
|
||||
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::WebSockets
|
||||
Qt${QT_VERSION_MAJOR}::WebEngine
|
||||
Qt${QT_VERSION_MAJOR}::Svg
|
||||
ScreenPlaySDK
|
||||
ScreenPlayUtil
|
||||
benchmark::benchmark
|
||||
benchmark::benchmark_main
|
||||
doctest::doctest
|
||||
sentry::sentry)
|
||||
|
@ -20,10 +20,5 @@ add_library(${PROJECT_NAME} ${src} ${headers})
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC inc)
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Network)
|
||||
|
@ -42,7 +42,8 @@ file(MAKE_DIRECTORY ${DESTDIR})
|
||||
configure_file(qmldir ${DESTDIR} COPYONLY)
|
||||
|
||||
if(APPLE)
|
||||
add_custom_command(TARGET ${PROJECT_NAME}
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMENT "Copying into ScreenPlay.app bundle"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/$<TARGET_FILE_NAME:${PROJECT_NAME}>
|
||||
@ -52,14 +53,7 @@ else()
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
$<TARGET_FILE:ScreenPlayShader>
|
||||
${DESTDIR}/$<TARGET_FILE_NAME:ScreenPlayShader>)
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:ScreenPlayShader> ${DESTDIR}/$<TARGET_FILE_NAME:ScreenPlayShader>)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Gui)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::Gui)
|
||||
|
@ -61,9 +61,4 @@ add_custom_command(
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:ScreenPlaySysInfo> ${DESTDIR}/$<TARGET_FILE_NAME:ScreenPlaySysInfo>)
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
infoware)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Quick infoware)
|
||||
|
@ -23,7 +23,4 @@ target_include_directories(
|
||||
PUBLIC inc/public/
|
||||
PRIVATE src/)
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Core)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Core)
|
||||
|
@ -3,14 +3,8 @@ project(ScreenPlayWallpaper LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
find_package(
|
||||
QT NAMES Qt6 Qt5
|
||||
COMPONENTS Quick Widgets Gui WebEngine QuickCompiler
|
||||
REQUIRED)
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS Quick Widgets Gui WebEngine QuickCompiler
|
||||
REQUIRED)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core)
|
||||
|
||||
if(WIN32)
|
||||
set(src_plattform src/windowsdesktopproperties.cpp src/winwindow.cpp)
|
||||
@ -42,21 +36,52 @@ if(WIN32)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
MACOSX_BUNDLE TRUE
|
||||
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
|
||||
)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE TRUE MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa")
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ScreenPlaySDK ScreenPlayUtil)
|
||||
|
||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS Core
|
||||
Quick
|
||||
Gui
|
||||
Widgets
|
||||
WebSockets
|
||||
Svg
|
||||
WebEngineCore
|
||||
WebEngineQuick
|
||||
WebChannel
|
||||
Positioning)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
PRIVATE Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::WebEngine
|
||||
ScreenPlaySDK
|
||||
ScreenPlayUtil)
|
||||
|
||||
Qt${QT_VERSION_MAJOR}::WebSockets
|
||||
Qt${QT_VERSION_MAJOR}::Svg
|
||||
Qt6::WebEngineCore
|
||||
Qt6::WebEngineQuick)
|
||||
else()
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS Core
|
||||
Quick
|
||||
Gui
|
||||
Widgets
|
||||
WebSockets
|
||||
Svg
|
||||
WebEngine)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::WebSockets
|
||||
Qt${QT_VERSION_MAJOR}::Svg
|
||||
Qt5::WebEngine)
|
||||
endif()
|
||||
|
@ -3,15 +3,8 @@ project(ScreenPlayWidget LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
find_package(
|
||||
QT NAMES Qt6 Qt5
|
||||
COMPONENTS Quick Widgets Gui WebEngine QuickCompiler
|
||||
REQUIRED)
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS Quick Widgets Gui WebEngine QuickCompiler
|
||||
REQUIRED)
|
||||
|
||||
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core)
|
||||
set(src main.cpp src/widgetwindow.cpp)
|
||||
|
||||
set(headers src/widgetwindow.h)
|
||||
@ -31,19 +24,51 @@ if(WIN32)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
MACOSX_BUNDLE TRUE
|
||||
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
|
||||
)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE TRUE MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ScreenPlaySDK ScreenPlayUtil)
|
||||
|
||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS Core
|
||||
Quick
|
||||
Gui
|
||||
Widgets
|
||||
WebSockets
|
||||
Svg
|
||||
WebEngineCore
|
||||
WebEngineQuick
|
||||
WebChannel
|
||||
Positioning)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Quick
|
||||
PRIVATE Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::WebEngine
|
||||
ScreenPlaySDK
|
||||
ScreenPlayUtil)
|
||||
Qt${QT_VERSION_MAJOR}::WebSockets
|
||||
Qt${QT_VERSION_MAJOR}::Svg
|
||||
Qt6::WebEngineCore
|
||||
Qt6::WebEngineQuick)
|
||||
else()
|
||||
find_package(
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
COMPONENTS Core
|
||||
Quick
|
||||
Gui
|
||||
Widgets
|
||||
WebSockets
|
||||
Svg
|
||||
WebEngine)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE Qt${QT_VERSION_MAJOR}::Quick
|
||||
Qt${QT_VERSION_MAJOR}::Gui
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::WebSockets
|
||||
Qt${QT_VERSION_MAJOR}::Svg
|
||||
Qt5::WebEngine)
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user