Skip to content

Commit

Permalink
Misc: Build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
univrsal committed Sep 15, 2024
1 parent d4d807c commit b61dbfe
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 25 deletions.
39 changes: 38 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,37 @@ include(helpers)

add_library(${CMAKE_PROJECT_NAME} MODULE)

string(TIMESTAMP TODAY "%Y.%m.%d %H:%M")

# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)

# Get the latest commit hash
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE)

target_compile_definitions(${PROJECT_NAME} PUBLIC
GIT_BRANCH="${GIT_BRANCH}"
GIT_COMMIT_HASH="${GIT_COMMIT_HASH}"
PLUGIN_VERSION="${_version}"
BUILD_TIME="${TODAY}"
)

if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB")
endif()

find_package(libobs REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs)
find_package(jansson REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs jansson::jansson)

if(ENABLE_FRONTEND_API)
find_package(obs-frontend-api REQUIRED)
Expand All @@ -34,6 +63,13 @@ if(ENABLE_QT)
AUTORCC ON)
endif()

if (MSVC)
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
./src/util/windows_helper.cpp
./src/util/windows_helper.hpp
)
endif()

target_sources(${CMAKE_PROJECT_NAME} PRIVATE
./src/durchblick_plugin.cpp
./src/layout.hpp
Expand Down Expand Up @@ -73,4 +109,5 @@ target_sources(${CMAKE_PROJECT_NAME} PRIVATE
./src/items/audio_mixer.hpp
)


set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name})
4 changes: 2 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"generator": "Visual Studio 17 2022",
"architecture": "x64",
"warnings": {"dev": true, "deprecated": true},
"warnings": {"dev": false, "deprecated": false},
"cacheVariables": {
"CMAKE_SYSTEM_VERSION": "10.0.18363.657"
}
Expand All @@ -82,7 +82,7 @@
"rhs": "Linux"
},
"generator": "Ninja",
"warnings": {"dev": true, "deprecated": true},
"warnings": {"dev": false, "deprecated": false},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
Expand Down
8 changes: 4 additions & 4 deletions buildspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
},
"platformConfig": {
"macos": {
"bundleId": "com.example.obs-plugintemplate"
"bundleId": "cc.vrsal.durchblick"
}
},
"name": "obs-plugintemplate",
"displayName": "OBS Plugin Template",
"version": "1.0.0",
"name": "durchblick",
"displayName": "Durchblick",
"version": "0.5.0",
"author": "Alex",
"website": "https://vrsal.cc",
"email": "contact@vrsal.xyz",
Expand Down
2 changes: 1 addition & 1 deletion cmake/common/compiler_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ set(_obs_clang_cxx_options
-Wrange-loop-analysis)

if(NOT DEFINED CMAKE_COMPILE_WARNING_AS_ERROR)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
endif()
2 changes: 1 addition & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void Load()
const auto main_window = static_cast<QMainWindow*>(obs_frontend_get_main_window());
obs_frontend_push_ui_translation(obs_module_get_string);
dbdock = new DurchblickDock((QWidget*)main_window);
obs_frontend_add_dock(Config::dbdock);
obs_frontend_add_dock_by_id("durchblick", "Durchblick", Config::dbdock);
obs_frontend_pop_ui_translation();
}

Expand Down
6 changes: 2 additions & 4 deletions src/durchblick_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include "config.hpp"
#include "items/registry.hpp"
#include "plugin-macros.generated.h"
#include "ui/durchblick.hpp"
#include "util/util.h"
#include <QAction>
Expand All @@ -32,9 +31,8 @@ OBS_MODULE_USE_DEFAULT_LOCALE("durchblick", "en-US")

bool obs_module_load()
{

binfo("Loading v%s build time %s", PLUGIN_VERSION, BUILD_TIME);

binfo("Loading v%s-%s (%s) build time %s", PLUGIN_VERSION, GIT_BRANCH, GIT_COMMIT_HASH, BUILD_TIME);

Registry::RegisterCustomWidgetProcedure();

QAction::connect(static_cast<QAction*>(obs_frontend_add_tools_menu_qaction(T_MENU_OPTION)),
Expand Down
4 changes: 2 additions & 2 deletions src/items/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ LayoutItem* MakeItem(Layout* l, QJsonObject const& obj)
if (id == "CustomItem")
id = obj["custom_id"].toString();

for (auto const& Entry : qAsConst(ItemRegistry::Entries)) {
for (auto const& Entry : std::as_const(ItemRegistry::Entries)) {
if (Entry.id == id) {
auto* item = Entry.construct(l, 0, 0, 0, 0);
item->ReadFromJson(obj);
Expand Down Expand Up @@ -148,7 +148,7 @@ void RegisterCustomWidgetProcedure()

const ItemRegistry::Entry* GetEntryById(const QString& id)
{
for (auto const& Entry : qAsConst(ItemRegistry::Entries)) {
for (auto const& Entry : std::as_const(ItemRegistry::Entries)) {
if (Entry.id == id)
return &Entry;
}
Expand Down
7 changes: 5 additions & 2 deletions src/items/registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ class ItemRegistry {

struct Entry {
Constructor construct {};
QString name, id;
DurchblickCallbacks cbs;
QString name {}, id {};
DurchblickCallbacks cbs {};

Entry(Constructor const& c, const char* _id, const char* _name)
: construct(c)
, name(utf8_to_qt(_name))
, id(utf8_to_qt(_id))
, cbs({})
{
}

Entry(const char* _id, const char* _name)
: name(utf8_to_qt(_name))
, id(utf8_to_qt(_id))
, cbs({})
{
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ void Layout::Load(QJsonObject const& obj)
m_locked = obj["locked"].toBool(false);
auto items = obj["items"].toArray();

for (auto const& item : qAsConst(items)) {
for (auto const& item : std::as_const(items)) {
auto* new_item = Registry::MakeItem(this, item.toObject());
if (new_item) {
new_item->Update(m_cfg);
Expand Down
9 changes: 3 additions & 6 deletions src/ui/durchblick_dock.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "durchblick_dock.hpp"
#include "config.hpp"
#include "../config.hpp"
#include "durchblick.hpp"
#include <QShowEvent>
#include <QVBoxLayout>
Expand Down Expand Up @@ -33,20 +33,17 @@ void DurchblickDock::showEvent(QShowEvent* e)
}

DurchblickDock::DurchblickDock(QWidget* parent)
: QDockWidget(parent)
: QWidget(parent)
, db(new Durchblick(this, Qt::Widget))
{
setFeatures(DockWidgetMovable | DockWidgetFloatable);
setWindowTitle("Durchblick");
setObjectName("DurchblickDock");
setFloating(true);


auto* mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(db);

auto* dockWidgetContents = new QWidget(this);
dockWidgetContents->setLayout(mainLayout);
setWidget(dockWidgetContents);
}

DurchblickDock::~DurchblickDock()
Expand Down
2 changes: 1 addition & 1 deletion src/ui/durchblick_dock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Durchblick;

class DurchblickDock : public QDockWidget {
class DurchblickDock : public QWidget {
Q_OBJECT

private:
Expand Down

0 comments on commit b61dbfe

Please sign in to comment.