Always build Frontend and Updater

We now require these features all the time, as they are becoming more of a core part of the StreamFX UI. Additionally several components rely on these already being present, so omitting them is not a great idea.
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2023-09-30 01:34:27 +02:00 committed by Xaymar
parent 72b0daca05
commit e6c81ca71e

View file

@ -286,15 +286,7 @@ endif()
# Version override # Version override
set(${PREFIX}VERSION "" CACHE STRING "Specify an override for the automatically detected version. Accepts a mixture of SemVer 2.0 and CMake Version.") set(${PREFIX}VERSION "" CACHE STRING "Specify an override for the automatically detected version. Accepts a mixture of SemVer 2.0 and CMake Version.")
# Features # Compile/Link Related
## FrontEnd & UI
set(${PREFIX}ENABLE_FRONTEND ON CACHE BOOL "Enable Frontend code.")
set(${PREFIX}ENABLE_UPDATER ON CACHE BOOL "Enable automatic update checks.")
## Code Related
set(${PREFIX}ENABLE_PROFILING OFF CACHE BOOL "Enable CPU and GPU performance tracking, which has a non-zero overhead at all times. Do not enable this for release builds.")
## Compile/Link Related
set(${PREFIX}ENABLE_LTO ${D_HAS_IPO} CACHE BOOL "Enable Link Time Optimization for faster and smaller binaries.") set(${PREFIX}ENABLE_LTO ${D_HAS_IPO} CACHE BOOL "Enable Link Time Optimization for faster and smaller binaries.")
set(${PREFIX}ENABLE_FASTMATH ON CACHE BOOL "Enable fast math optimizations, which sacrifice precision and stability.") set(${PREFIX}ENABLE_FASTMATH ON CACHE BOOL "Enable fast math optimizations, which sacrifice precision and stability.")
if(D_PLATFORM_ARCH_X86) if(D_PLATFORM_ARCH_X86)
@ -394,71 +386,9 @@ endif()
set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "User-Interface Files/Generated") set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "User-Interface Files/Generated")
################################################################################ ################################################################################
# Components (Old System) # Dependencies
################################################################################ ################################################################################
# Component resolving:
# 1. Check which features are enabled. For each feature, set what they require to ON.
# 2. Try and find required items.
# 3. Again check which features are enabled, if their requirements are missing, warn about it and disable them.
# TODO: Consider making this an error instead.
macro(is_feature_enabled FEATURE OUTPUT)
set(T_ENABLED ${${PREFIX}ENABLE_${FEATURE}})
set(T_DISABLED ${${PREFIX}DISABLE_${FEATURE}})
if(T_ENABLED AND NOT T_DISABLED)
set(${OUTPUT} ON)
else()
# set(${PREFIX}DISABLE_${FEATURE} ON CACHE INTERNAL "" FORCE)
set(${OUTPUT} OFF)
endif()
endmacro()
macro(set_feature_disabled FEATURE DISABLED)
set(${PREFIX}DISABLE_${FEATURE} ${DISABLED} CACHE INTERNAL "" FORCE)
endmacro()
function(feature_frontend RESOLVE)
is_feature_enabled(FRONTEND T_CHECK)
if(RESOLVE AND T_CHECK)
if(NOT (Qt6_FOUND OR Qt5_FOUND))
message(WARNING "Front-End requires Qt. Disabling...")
set_feature_disabled(FRONTEND ON)
elseif(NOT obs-frontend-api_FOUND)
message(WARNING "Front-End requires OBS FrontEnd API. Disabling...")
set_feature_disabled(FRONTEND ON)
elseif(NOT HAVE_JSON)
message(WARNING "Front-End requires nlohmann::json. Disabling...")
set_feature_disabled(FRONTEND ON)
endif()
elseif(T_CHECK)
set(REQUIRE_QT ON PARENT_SCOPE)
set(REQUIRE_OBS_FRONTEND_API ON PARENT_SCOPE)
set(REQUIRE_JSON ON PARENT_SCOPE)
endif()
endfunction()
function(feature_updater RESOLVE)
is_feature_enabled(UPDATER T_CHECK)
if(RESOLVE AND T_CHECK)
if(NOT CURL_FOUND)
message(WARNING "Updater requires CURL. Disabling...")
set_feature_disabled(UPDATER ON)
elseif(NOT HAVE_JSON)
message(WARNING "Updater requires nlohmann::json. Disabling...")
set_feature_disabled(UPDATER ON)
endif()
elseif(T_CHECK)
set(REQUIRE_CURL ON PARENT_SCOPE)
set(REQUIRE_JSON ON PARENT_SCOPE)
endif()
endfunction()
# Set Requirements
feature_frontend(OFF)
feature_updater(OFF)
# Fulfill Requirements
#- OBS: Library #- OBS: Library
if(STANDALONE) if(STANDALONE)
find_package("libobs" REQUIRED CONFIG) find_package("libobs" REQUIRED CONFIG)
@ -483,35 +413,25 @@ if(D_PLATFORM_MAC)
endif() endif()
#- OBS: Front-End API #- OBS: Front-End API
set(obs-frontend-api_FOUND OFF) if(STANDALONE)
if(REQUIRE_OBS_FRONTEND_API) find_package("obs-frontend-api" CONFIG)
if(STANDALONE) set(obs-frontend-api_FOUND "${obs-frontend-api_FOUND}")
find_package("obs-frontend-api" CONFIG) elseif(TARGET obs-frontend-api)
set(obs-frontend-api_FOUND "${obs-frontend-api_FOUND}") set(obs-frontend-api_FOUND ON)
elseif(TARGET obs-frontend-api) endif()
set(obs-frontend-api_FOUND ON) if(NOT TARGET OBS::obs-frontend-api)
endif() add_library(OBS::obs-frontend-api ALIAS obs-frontend-api)
if(NOT TARGET OBS::obs-frontend-api)
add_library(OBS::obs-frontend-api ALIAS obs-frontend-api)
endif()
endif() endif()
#- CURL #- CURL
set(CURL_FOUND OFF) find_package("CURL")
if(REQUIRE_CURL)
find_package("CURL")
endif()
#- JSON #- JSON
set(HAVE_JSON OFF) if(NOT EXISTS "${PROJECT_SOURCE_DIR}/third-party/nlohmann-json/single_include")
if(REQUIRE_JSON) message(FATAL_ERROR "Please make sure to update git submodules to their latest supported version.")
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/third-party/nlohmann-json/single_include") return()
message(FATAL_ERROR "Please make sure to update git submodules to their latest supported version.") else()
return() set(JSON_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/third-party/nlohmann-json/single_include")
else()
set(JSON_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/third-party/nlohmann-json/single_include")
set(HAVE_JSON ON)
endif()
endif() endif()
#- NVIDIA Augmented Reality SDK #- NVIDIA Augmented Reality SDK
@ -556,31 +476,11 @@ if(REQUIRE_NVIDIA_CUDA AND D_PLATFORM_WINDOWS)
set(HAVE_NVIDIA_CUDA ON) set(HAVE_NVIDIA_CUDA ON)
endif() endif()
#- Qt #- Qt 6
if(REQUIRE_QT) find_package("Qt6"
# Try Qt6 first... COMPONENTS Core Gui Widgets
find_package("Qt6" CONFIG
COMPONENTS Core Gui Widgets )
CONFIG
)
# If Qt6 isn't present, try Qt5
if(NOT Qt6_FOUND)
find_package("Qt5"
COMPONENTS Core Gui Widgets
CONFIG
)
endif()
if(Qt6_FOUND)
message(STATUS "Using Qt6.")
elseif(Qt5_FOUND)
message(STATUS "Using Qt5.")
endif()
endif()
# Verify Requirements
feature_frontend(ON)
feature_updater(ON)
################################################################################ ################################################################################
# Code # Code
@ -629,18 +529,14 @@ LIST(APPEND PROJECT_PRIVATE_GENERATED "${PROJECT_BINARY_DIR}/generated/module.cp
# Minimum Dependencies # Minimum Dependencies
list(APPEND PROJECT_LIBRARIES OBS::libobs) list(APPEND PROJECT_LIBRARIES OBS::libobs)
# Components # Dependencies
if(CURL_FOUND) list(APPEND PROJECT_PRIVATE_SOURCE
list(APPEND PROJECT_PRIVATE_SOURCE "source/util/util-curl.hpp"
"source/util/util-curl.hpp" "source/util/util-curl.cpp"
"source/util/util-curl.cpp" )
) list(APPEND PROJECT_LIBRARIES CURL::libcurl)
list(APPEND PROJECT_LIBRARIES CURL::libcurl)
endif()
if(HAVE_JSON) list(APPEND PROJECT_INCLUDE_DIRS ${JSON_INCLUDE_DIR})
list(APPEND PROJECT_INCLUDE_DIRS ${JSON_INCLUDE_DIR})
endif()
if(TRUE) # OpenGL if(TRUE) # OpenGL
if(NOT TARGET khronos_glad) if(NOT TARGET khronos_glad)
@ -737,20 +633,12 @@ if(HAVE_NVIDIA_CUDA)
) )
endif() endif()
if(REQUIRE_OBS_FRONTEND_API AND obs-frontend-api_FOUND) list(APPEND PROJECT_LIBRARIES OBS::obs-frontend-api)
list(APPEND PROJECT_LIBRARIES OBS::obs-frontend-api) list(APPEND PROJECT_UI_SOURCE
list(APPEND PROJECT_UI_SOURCE "source/obs/browser/obs-browser-panel.hpp"
"source/obs/browser/obs-browser-panel.hpp" )
)
endif()
if(REQUIRE_QT) list(APPEND PROJECT_LIBRARIES Qt6::Core Qt6::Gui Qt6::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()
################################################################################ ################################################################################
# Features # Features
@ -850,66 +738,51 @@ list(APPEND PROJECT_INCLUDE_DIRS
) )
# Profiling # Profiling
is_feature_enabled(PROFILING T_CHECK) list(APPEND PROJECT_PRIVATE_SOURCE
if(T_CHECK) "source/util/util-profiler.cpp"
list(APPEND PROJECT_PRIVATE_SOURCE "source/util/util-profiler.hpp"
"source/util/util-profiler.cpp" )
"source/util/util-profiler.hpp"
)
list(APPEND PROJECT_DEFINITIONS
ENABLE_PROFILING
)
endif()
# Updater # Updater
is_feature_enabled(UPDATER T_CHECK) list(APPEND PROJECT_PRIVATE_SOURCE
if(T_CHECK) "source/updater.hpp"
list(APPEND PROJECT_PRIVATE_SOURCE "source/updater.cpp"
"source/updater.hpp" )
"source/updater.cpp" list(APPEND PROJECT_DEFINITIONS
) ENABLE_UPDATER
list(APPEND PROJECT_DEFINITIONS )
ENABLE_UPDATER
)
endif()
# Frontend # Frontend
is_feature_enabled(FRONTEND T_CHECK) list(APPEND PROJECT_UI
if(T_CHECK) "ui/streamfx.qrc"
list(APPEND PROJECT_UI "ui/about.ui"
"ui/streamfx.qrc" "ui/about-entry.ui"
"ui/about.ui" )
"ui/about-entry.ui" list(APPEND PROJECT_UI_SOURCE
) "source/ui/ui-common.hpp"
list(APPEND PROJECT_UI_SOURCE "source/ui/ui.hpp"
"source/ui/ui-common.hpp" "source/ui/ui.cpp"
"source/ui/ui.hpp" "source/ui/ui-about.hpp"
"source/ui/ui.cpp" "source/ui/ui-about.cpp"
"source/ui/ui-about.hpp" "source/ui/ui-about-entry.hpp"
"source/ui/ui-about.cpp" "source/ui/ui-about-entry.cpp"
"source/ui/ui-about-entry.hpp" "source/ui/ui-obs-browser-widget.hpp"
"source/ui/ui-about-entry.cpp" "source/ui/ui-obs-browser-widget.cpp"
"source/ui/ui-obs-browser-widget.hpp" )
"source/ui/ui-obs-browser-widget.cpp" list(APPEND PROJECT_INCLUDE_DIRS
) "source/ui"
list(APPEND PROJECT_INCLUDE_DIRS )
"source/ui" list(APPEND PROJECT_DEFINITIONS
) ENABLE_FRONTEND
list(APPEND PROJECT_DEFINITIONS )
ENABLE_FRONTEND
)
is_feature_enabled(UPDATER T_CHECK) list(APPEND PROJECT_UI_SOURCE
if(T_CHECK) "source/ui/ui-updater.hpp"
list(APPEND PROJECT_UI_SOURCE "source/ui/ui-updater.cpp"
"source/ui/ui-updater.hpp" )
"source/ui/ui-updater.cpp" list(APPEND PROJECT_UI
) "ui/updater.ui"
list(APPEND PROJECT_UI )
"ui/updater.ui"
)
endif()
endif()
################################################################################ ################################################################################
# Parts # Parts
@ -1561,23 +1434,21 @@ set_source_files_properties(${PROJECT_DATA} ${PROJECT_TEMPLATES} ${PROJECT_UI} $
) )
# Enable Qt if needed # Enable Qt if needed
if(Qt5_Found OR Qt6_FOUND) set_target_properties(StreamFX_Core PROPERTIES
set_target_properties(StreamFX_Core PROPERTIES AUTOUIC ON
AUTOUIC ON AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/ui"
AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/ui" AUTOMOC ON
AUTOMOC ON AUTORCC ON
AUTORCC ON AUTOGEN_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated"
AUTOGEN_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated" )
)
# Prevent non-UI files from being Qt'd # Prevent non-UI files from being Qt'd
set_source_files_properties(${PROJECT_DATA} ${PROJECT_TEMPLATES} ${PROJECT_MEDIA} ${PROJECT_PRIVATE_GENERATED} ${PROJECT_PRIVATE_SOURCE} PROPERTIES set_source_files_properties(${PROJECT_DATA} ${PROJECT_TEMPLATES} ${PROJECT_MEDIA} ${PROJECT_PRIVATE_GENERATED} ${PROJECT_PRIVATE_SOURCE} PROPERTIES
SKIP_AUTOGEN ON SKIP_AUTOGEN ON
SKIP_AUTOMOC ON SKIP_AUTOMOC ON
SKIP_AUTORCC ON SKIP_AUTORCC ON
SKIP_AUTOUIC ON SKIP_AUTOUIC ON
) )
endif()
target_sources(StreamFX_Core PRIVATE ${PROJECT_FILES}) target_sources(StreamFX_Core PRIVATE ${PROJECT_FILES})