1
0
Fork 0

Updated cmake sources to TDesktop version 3.1

This commit is contained in:
Eric Kotato 2021-09-19 22:45:57 +03:00
commit 841c2d5cc1
31 changed files with 748 additions and 159 deletions

View file

@ -10,9 +10,10 @@ if (LINUX
AND Qt5WaylandClient_FOUND)
add_subdirectory(linux_wayland_helper)
endif()
if (LINUX
AND NOT DESKTOP_APP_USE_PACKAGED
AND NOT DESKTOP_APP_DISABLE_GTK_INTEGRATION)
if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED)
add_subdirectory(linux_glib_helper)
endif()
if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED)
add_subdirectory(linux_gtk_helper)
endif()
if (DESKTOP_APP_USE_ALLOCATION_TRACER)

View file

@ -25,12 +25,12 @@ if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
endif()
endif()
add_checked_subdirectory(ffmpeg)
if (LINUX)
if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
add_checked_subdirectory(glib)
add_checked_subdirectory(glibmm)
endif()
add_checked_subdirectory(gsl)
if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
if (LINUX AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION)
add_checked_subdirectory(hime_qt)
endif()
if (add_hunspell_library)

View file

@ -7,16 +7,18 @@
add_library(external_auto_updates INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_auto_updates ALIAS external_auto_updates)
if (WIN32 AND NOT DESKTOP_APP_USE_PACKAGED)
add_subdirectory(lzma)
target_link_libraries(external_auto_updates
INTERFACE
desktop-app::external_lzma
)
else()
add_subdirectory(xz)
target_link_libraries(external_auto_updates
INTERFACE
desktop-app::external_xz
)
if (NOT DESKTOP_APP_DISABLE_AUTOUPDATE)
if (WIN32 AND NOT DESKTOP_APP_USE_PACKAGED)
add_subdirectory(lzma)
target_link_libraries(external_auto_updates
INTERFACE
desktop-app::external_lzma
)
else()
add_subdirectory(xz)
target_link_libraries(external_auto_updates
INTERFACE
desktop-app::external_xz
)
endif()
endif()

View file

@ -13,11 +13,11 @@ if (DESKTOP_APP_USE_PACKAGED)
elseif (APPLE)
target_include_directories(external_xz SYSTEM
INTERFACE
/usr/local/macos/include
${libs_loc}/local/include
)
target_link_libraries(external_xz
INTERFACE
/usr/local/macos/lib/liblzma.a
${libs_loc}/local/lib/liblzma.a
)
else()
target_link_static_libraries(external_xz

View file

@ -64,6 +64,7 @@ else()
if (LINUX)
target_link_static_libraries(external_ffmpeg
INTERFACE
lzma
va-x11
va-drm
va
@ -71,11 +72,11 @@ else()
Xv
Xext
Xfixes
drm
)
target_link_libraries(external_ffmpeg
INTERFACE
X11
drm
pthread
)
endif()

View file

@ -13,85 +13,28 @@ else()
init_target(external_hime_im_client "(external)")
set(hime_loc ${third_party_loc}/hime)
set(hime_src ${hime_loc}/src)
set(hime_im_client_src ${hime_src}/im-client)
set(hime_im_client_src ${hime_loc}/src/im-client)
nice_target_sources(external_hime_im_client ${hime_im_client_src}
nice_target_sources(external_hime_im_client ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
hime-im-client-attr.h
hime-im-client.c
hime-im-client.h
hime-protocol.h
hime-send.c
hime_im_client_helper.cpp
)
nice_target_sources(external_hime_im_client ${hime_src}
PRIVATE
hime-conf.c
util.c
im-addr.c
hime-crypt.c
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED gtk+-3.0)
target_include_directories(external_hime_im_client
PUBLIC
${hime_im_client_src}
PRIVATE
${hime_src}
${hime_src}/IMdkit/include
${GTK_INCLUDE_DIRS}
)
target_compile_definitions(external_hime_im_client
find_package(PkgConfig REQUIRED)
pkg_check_modules(X11 REQUIRED x11)
target_include_directories(external_hime_im_client SYSTEM
PRIVATE
HIME_BIN_DIR="/usr/bin"
HIME_TABLE_DIR="/usr/share/hime/table"
UNIX=1
FREEBSD=0
CLIENT_LIB=1
GTK_DISABLE_DEPRECATED
${X11_INCLUDE_DIRS}
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_library(external_hime_im_client_options INTERFACE)
target_compile_options(external_hime_im_client_options
INTERFACE
-Wno-sometimes-uninitialized
)
target_link_libraries(external_hime_im_client
PRIVATE
external_hime_im_client_options
)
endif()
target_link_libraries(external_hime_im_client
PRIVATE
desktop-app::external_glib
${CMAKE_DL_LIBS}
)
if (DESKTOP_APP_USE_PACKAGED)
pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11)
target_link_libraries(external_hime_im_client
PRIVATE
PkgConfig::X11
)
else()
pkg_check_modules(X11 REQUIRED x11)
target_include_directories(external_hime_im_client SYSTEM
PRIVATE
${X11_INCLUDE_DIRS}
)
target_link_libraries(external_hime_im_client
PRIVATE
X11
)
endif()
endif()

View file

@ -0,0 +1,208 @@
// This file is part of Desktop App Toolkit,
// a set of libraries for developing nice desktop applications.
//
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
#include <dlfcn.h>
#include <X11/Xlib.h>
#include <hime-im-client.h>
#include <memory>
#include <iostream>
#define LOAD_SYMBOL(handle, func) LoadSymbol(handle, #func, func)
namespace HimeHelper {
namespace {
void (*hime_im_client_close)(HIME_client_handle *handle);
void (*hime_im_client_focus_in)(HIME_client_handle *handle);
void (*hime_im_client_focus_out)(HIME_client_handle *handle);
void (*hime_im_client_focus_out2)(HIME_client_handle *handle, char **rstr);
int (*hime_im_client_forward_key_press)(
HIME_client_handle *handle,
const KeySym key,
const uint32_t state,
char **rstr);
int (*hime_im_client_forward_key_release)(
HIME_client_handle *handle,
const KeySym key,
const uint32_t state,
char **rstr);
int (*hime_im_client_get_preedit)(
HIME_client_handle *handle,
char **str,
HIME_PREEDIT_ATTR att[],
int *cursor,
int *sub_comp_len);
HIME_client_handle *(*hime_im_client_open)(Display *display);
void (*hime_im_client_reset)(HIME_client_handle *handle);
void (*hime_im_client_set_cursor_location)(
HIME_client_handle *handle,
const int x,
const int y);
void (*hime_im_client_set_flags)(
HIME_client_handle *handle,
const int flags,
int *ret_flags);
void (*hime_im_client_set_client_window)(
HIME_client_handle *handle,
const Window win);
void (*hime_im_client_set_window)(HIME_client_handle *handle, Window win);
struct HandleDeleter {
void operator()(void *handle) {
dlclose(handle);
}
};
using Handle = std::unique_ptr<void, HandleDeleter>;
bool LoadLibrary(Handle &handle, const char *name) {
handle = Handle(dlopen(name, RTLD_LAZY | RTLD_NODELETE));
if (handle) {
return true;
}
std::cerr << dlerror() << std::endl;
return false;
}
template <typename Function>
inline bool LoadSymbol(const Handle &handle, const char *name, Function &func) {
func = handle
? reinterpret_cast<Function>(dlsym(handle.get(), name))
: nullptr;
if (const auto error = dlerror()) {
std::cerr << error << std::endl;
}
return (func != nullptr);
}
bool Resolve() {
static const auto loaded = [&] {
auto lib = Handle();
return LoadLibrary(lib, "libhime-im-client.so.1")
&& LOAD_SYMBOL(lib, hime_im_client_close)
&& LOAD_SYMBOL(lib, hime_im_client_focus_in)
&& LOAD_SYMBOL(lib, hime_im_client_focus_out)
&& LOAD_SYMBOL(lib, hime_im_client_focus_out2)
&& LOAD_SYMBOL(lib, hime_im_client_forward_key_press)
&& LOAD_SYMBOL(lib, hime_im_client_forward_key_release)
&& LOAD_SYMBOL(lib, hime_im_client_get_preedit)
&& LOAD_SYMBOL(lib, hime_im_client_open)
&& LOAD_SYMBOL(lib, hime_im_client_reset)
&& LOAD_SYMBOL(lib, hime_im_client_set_cursor_location)
&& LOAD_SYMBOL(lib, hime_im_client_set_flags)
&& (LOAD_SYMBOL(lib, hime_im_client_set_client_window)
|| LOAD_SYMBOL(lib, hime_im_client_set_window));
}();
return loaded;
}
} // namespace
} // namespace HimeHelper
void hime_im_client_close(HIME_client_handle *handle) {
HimeHelper::Resolve();
HimeHelper::hime_im_client_close(handle);
}
void hime_im_client_focus_in(HIME_client_handle *handle) {
HimeHelper::Resolve();
HimeHelper::hime_im_client_focus_in(handle);
}
void hime_im_client_focus_out(HIME_client_handle *handle) {
HimeHelper::Resolve();
HimeHelper::hime_im_client_focus_out(handle);
}
void hime_im_client_focus_out2(HIME_client_handle *handle, char **rstr) {
HimeHelper::Resolve();
HimeHelper::hime_im_client_focus_out2(handle, rstr);
}
int hime_im_client_forward_key_press(
HIME_client_handle *handle,
const KeySym key,
const uint32_t state,
char **rstr) {
HimeHelper::Resolve();
return HimeHelper::hime_im_client_forward_key_press(
handle,
key,
state,
rstr);
}
int hime_im_client_forward_key_release(
HIME_client_handle *handle,
const KeySym key,
const uint32_t state,
char **rstr) {
HimeHelper::Resolve();
return HimeHelper::hime_im_client_forward_key_release(
handle,
key,
state,
rstr);
}
int hime_im_client_get_preedit(
HIME_client_handle *handle,
char **str,
HIME_PREEDIT_ATTR att[],
int *cursor,
int *sub_comp_len) {
HimeHelper::Resolve();
return HimeHelper::hime_im_client_get_preedit(
handle,
str,
att,
cursor,
sub_comp_len);
}
HIME_client_handle *hime_im_client_open(Display *display) {
HimeHelper::Resolve();
return HimeHelper::hime_im_client_open(display);
}
void hime_im_client_reset(HIME_client_handle *handle) {
HimeHelper::Resolve();
HimeHelper::hime_im_client_reset(handle);
}
void hime_im_client_set_cursor_location(
HIME_client_handle *handle,
const int x,
const int y) {
HimeHelper::Resolve();
HimeHelper::hime_im_client_set_cursor_location(
handle,
x,
y);
}
void hime_im_client_set_flags(
HIME_client_handle *handle,
const int flags,
int *ret_flags) {
HimeHelper::Resolve();
HimeHelper::hime_im_client_set_flags(
handle,
flags,
ret_flags);
}
void hime_im_client_set_client_window(
HIME_client_handle *handle,
const Window win) {
HimeHelper::Resolve();
HimeHelper::hime_im_client_set_client_window(handle, win);
}
void hime_im_client_set_window(HIME_client_handle *handle, Window win) {
HimeHelper::Resolve();
HimeHelper::hime_im_client_set_window(handle, win);
}

View file

@ -13,6 +13,6 @@ if (APPLE AND DESKTOP_APP_USE_PACKAGED)
elseif (APPLE)
target_link_libraries(external_iconv
INTERFACE
/usr/local/macos/lib/libiconv.a
${libs_loc}/local/lib/libiconv.a
)
endif()

View file

@ -7,12 +7,22 @@
add_library(external_jemalloc INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_jemalloc ALIAS external_jemalloc)
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
return()
endif()
if (DESKTOP_APP_USE_PACKAGED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(JEMALLOC IMPORTED_TARGET jemalloc)
if (JEMALLOC_FOUND)
target_link_libraries(external_jemalloc INTERFACE PkgConfig::JEMALLOC)
target_link_libraries(external_jemalloc
INTERFACE
-Wl,--no-as-needed
PkgConfig::JEMALLOC
${JEMALLOC_LINK_LIBRARIES}
-Wl,--as-needed
)
endif()
endif()
@ -23,7 +33,7 @@ if (NOT JEMALLOC_FOUND)
include(ExternalProject)
ExternalProject_Add(jemalloc
SOURCE_DIR ${jemalloc_loc}
CONFIGURE_COMMAND cd "${jemalloc_loc}" && ./autogen.sh
CONFIGURE_COMMAND cd "${jemalloc_loc}" && CC=clang CXX=clang++ EXTRA_CFLAGS=-fPIE EXTRA_CXXFLAGS=-fPIE ./autogen.sh
INSTALL_COMMAND :
BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS ${jemalloc_loc}/lib/libjemalloc.a
@ -42,7 +52,7 @@ if (NOT JEMALLOC_FOUND)
target_link_libraries(external_jemalloc_bundled
INTERFACE
dl
${CMAKE_DL_LIBS}
pthread
)

View file

@ -14,7 +14,7 @@ elseif (WIN32)
target_include_directories(external_jpeg SYSTEM INTERFACE ${libs_loc}/mozjpeg)
target_link_libraries(external_jpeg INTERFACE ${libs_loc}/mozjpeg/$<IF:$<CONFIG:Debug>,Debug,Release>/jpeg-static.lib)
elseif (APPLE)
target_link_libraries(external_jpeg INTERFACE /usr/local/macos/lib/libjpeg.a)
target_link_libraries(external_jpeg INTERFACE ${libs_loc}/local/lib/libjpeg.a)
else()
target_link_static_libraries(external_jpeg INTERFACE jpeg)
endif()

View file

@ -23,10 +23,14 @@ else()
im-nimf-qt5.cpp
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GIO REQUIRED gio-2.0)
target_include_directories(external_nimf_qt5
PRIVATE
${nimf_qt5_src}
${libnimf_src}
${GIO_INCLUDE_DIRS}
)
target_compile_definitions(external_nimf_qt5
@ -41,7 +45,6 @@ else()
target_link_libraries(external_nimf_qt5
PRIVATE
desktop-app::external_qt
desktop-app::external_glib
${CMAKE_DL_LIBS}
)
endif()

View file

@ -27,15 +27,15 @@ elseif (WIN32)
INTERFACE
${libs_loc}/openal-soft/build/$<IF:$<CONFIG:Debug>,Debug,RelWithDebInfo>/OpenAL32.lib
)
elseif(APPLE)
elseif (APPLE)
target_include_directories(external_openal SYSTEM
INTERFACE
/usr/local/macos/include
/usr/local/macos/include/AL
${libs_loc}/local/include
${libs_loc}/local/include/AL
)
target_link_libraries(external_openal
INTERFACE
/usr/local/macos/lib/libopenal.a
${libs_loc}/local/lib/libopenal.a
)
else()
target_include_directories(external_openal SYSTEM

View file

@ -9,15 +9,11 @@ add_library(desktop-app::external_openssl ALIAS external_openssl)
if (WIN32)
set(openssl_lib_ext lib)
if (build_win64)
set(openssl_lib_loc ${libs_loc}/openssl_1_1_1/out64)
else()
set(openssl_lib_loc ${libs_loc}/openssl_1_1_1/out32)
endif()
set(openssl_lib_loc ${libs_loc}/openssl/out)
else()
set(openssl_lib_ext a)
if (APPLE)
set(openssl_lib_loc ${libs_loc}/openssl_1_1_1)
set(openssl_lib_loc ${libs_loc}/openssl)
else()
set(openssl_lib_loc /usr/local/desktop-app/openssl-1.1.1/lib)
endif()

View file

@ -16,7 +16,7 @@ if (NOT DESKTOP_APP_USE_PACKAGED)
else()
target_include_directories(external_openssl_common SYSTEM
INTERFACE
${libs_loc}/openssl_1_1_1/include
${libs_loc}/openssl/include
)
endif()

View file

@ -34,10 +34,10 @@ else()
elseif (APPLE)
target_include_directories(external_opus SYSTEM
INTERFACE
/usr/local/macos/include/opus
${libs_loc}/local/include/opus
)
set_target_properties(external_opus PROPERTIES
IMPORTED_LOCATION /usr/local/macos/lib/libopus.a
IMPORTED_LOCATION ${libs_loc}/local/lib/libopus.a
)
else()
target_include_directories(external_opus SYSTEM

View file

@ -212,17 +212,11 @@ else()
plugins/wayland-decoration-client/${qt_lib_prefix}bradient
)
endif()
set(qt_libs_gtk_plugins)
if (NOT DESKTOP_APP_DISABLE_GTK_INTEGRATION)
set(qt_libs_gtk_plugins
plugins/platformthemes/${qt_lib_prefix}qgtk3
)
endif()
set(qt_libs
plugins/platforminputcontexts/${qt_lib_prefix}composeplatforminputcontextplugin
${qt_libs_dbus_plugins}
${qt_libs_waylandclient_plugins}
${qt_libs_gtk_plugins}
plugins/platformthemes/${qt_lib_prefix}qgtk3
plugins/platforms/${qt_lib_prefix}qxcb
plugins/xcbglintegrations/${qt_lib_prefix}qxcb-egl-integration
plugins/xcbglintegrations/${qt_lib_prefix}qxcb-glx-integration
@ -265,6 +259,7 @@ else()
target_link_static_libraries(external_qt
INTERFACE
proxy
epoxy
xkbcommon
xkbcommon-x11
xcb-glx
@ -282,6 +277,7 @@ else()
xcb-util
xcb-render-util
xcb-keysyms
z
)
if (Qt5WaylandClient_FOUND)
target_link_libraries(external_qt
@ -290,23 +286,17 @@ else()
$<TARGET_FILE:desktop-app::linux_wayland_helper>
)
endif()
if (NOT DESKTOP_APP_DISABLE_GTK_INTEGRATION)
target_link_libraries(external_qt
INTERFACE
desktop-app::linux_gtk_helper
$<TARGET_FILE:desktop-app::linux_gtk_helper>
)
endif()
target_link_libraries(external_qt
INTERFACE
desktop-app::linux_gtk_helper
$<TARGET_FILE:desktop-app::linux_gtk_helper>
desktop-app::linux_glib_helper
$<TARGET_FILE:desktop-app::linux_glib_helper>
fontconfig
freetype
EGL
GL
xcb
X11
X11-xcb
glib-2.0
${CMAKE_DL_LIBS}
pthread
)

View file

@ -9,6 +9,8 @@ if (NOT DESKTOP_APP_USE_PACKAGED)
if (WIN32)
set(qt_loc ${libs_loc}/Qt-${qt_version})
elseif (APPLE)
set(qt_loc ${libs_loc}/local/Qt-${qt_version})
else()
set(qt_loc /usr/local/desktop-app/Qt-${qt_version})
endif()

View file

@ -28,7 +28,6 @@ if (LINUX)
target_link_libraries(external_qt_static_plugins
PUBLIC
desktop-app::external_fcitx_qt5
desktop-app::external_hime_qt
)
if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION)
@ -38,4 +37,11 @@ if (LINUX)
)
endif()
endif()
if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION)
target_link_libraries(external_qt_static_plugins
PUBLIC
desktop-app::external_hime_qt
)
endif()
endif()

View file

@ -39,9 +39,7 @@ Q_IMPORT_PLUGIN(QWaylandEglClientBufferPlugin)
Q_IMPORT_PLUGIN(QWaylandWlShellIntegrationPlugin)
Q_IMPORT_PLUGIN(QWaylandBradientDecorationPlugin)
#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
#ifndef DESKTOP_APP_DISABLE_GTK_INTEGRATION
Q_IMPORT_PLUGIN(QGtk3ThemePlugin)
#endif // !DESKTOP_APP_DISABLE_GTK_INTEGRATION
#endif // Q_OS_WIN | Q_OS_MAC | Q_OS_UNIX
#endif // !DESKTOP_APP_USE_PACKAGED
@ -53,7 +51,9 @@ Q_IMPORT_PLUGIN(QFcitxPlatformInputContextPlugin)
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin)
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin)
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin)
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
#endif // !DESKTOP_APP_USE_PACKAGED || DESKTOP_APP_USE_PACKAGED_LAZY
#endif // Q_OS_UNIX && !Q_OS_MAC

View file

@ -93,10 +93,6 @@ else()
target_link_libraries(external_webrtc
INTERFACE
Secur32.lib # Required for rtc_base/http_common.cc
dmoguids.lib # Required for the built-in WASAPI AEC, see modules/audio_device/BUILD.gn
wmcodecdspuuid.lib
amstrmid.lib
msdmo.lib
)
elseif (APPLE)
target_link_libraries(external_webrtc
@ -115,5 +111,12 @@ else()
Xrender
Xtst
)
target_link_libraries(external_webrtc
INTERFACE
X11
gio-2.0
gobject-2.0
glib-2.0
)
endif()
endif()

View file

@ -21,7 +21,7 @@ elseif (WIN32)
set(zlib_lib_loc ${libs_loc}/zlib/contrib/vstudio/vc14/${zlib_config_folder}/ZlibStat$<IF:$<CONFIG:Debug>,Debug,ReleaseWithoutAsm>)
target_link_libraries(external_zlib INTERFACE ${zlib_lib_loc}/zlibstat.lib)
elseif (APPLE)
target_link_libraries(external_zlib INTERFACE /usr/local/macos/lib/libz.a)
target_link_libraries(external_zlib INTERFACE ${libs_loc}/local/lib/libz.a)
else()
target_link_libraries(external_zlib INTERFACE z)
target_link_static_libraries(external_zlib INTERFACE z)
endif()

View file

@ -0,0 +1,28 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(linux_glib_helper STATIC)
add_library(desktop-app::linux_glib_helper ALIAS linux_glib_helper)
nice_target_sources(linux_glib_helper ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
linux_glib_helper.cpp
)
target_link_libraries(linux_glib_helper
PUBLIC
${CMAKE_DL_LIBS}
)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
pkg_check_modules(GOBJECT REQUIRED gobject-2.0)
target_include_directories(linux_glib_helper SYSTEM
PRIVATE
${GLIB2_INCLUDE_DIRS}
${GOBJECT_INCLUDE_DIRS}
)

View file

@ -0,0 +1,405 @@
// This file is part of Desktop App Toolkit,
// a set of libraries for developing nice desktop applications.
//
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
#include <dlfcn.h>
#include <glib.h>
#include <glib-object.h>
#include <memory>
#include <iostream>
#define LOAD_SYMBOL(handle, func) LoadSymbol(handle, #func, func)
namespace GlibHelper {
namespace {
void (*g_free)(gpointer mem);
void (*g_log_default_handler)(
const gchar* log_domain,
GLogLevelFlags log_level,
const gchar* message,
gpointer unused_data);
guint (*g_log_set_handler)(
const gchar* log_domain,
GLogLevelFlags log_levels,
GLogFunc log_func,
gpointer user_data);
GMainContext* (*g_main_context_default)(void);
gboolean (*g_main_context_iteration)(GMainContext* context, gboolean may_block);
GMainContext* (*g_main_context_new)(void);
gboolean (*g_main_context_pending)(GMainContext* context);
void (*g_main_context_pop_thread_default)(GMainContext* context);
void (*g_main_context_push_thread_default)(GMainContext* context);
GMainContext* (*g_main_context_ref)(GMainContext* context);
void (*g_main_context_unref)(GMainContext* context);
void (*g_main_context_wakeup)(GMainContext* context);
void (*g_return_if_fail_warning)(
const char* log_domain,
const char* pretty_function,
const char* expression);
void (*g_slist_free)(GSList* list);
void (*g_source_add_poll)(GSource* source, GPollFD* fd);
guint (*g_source_attach)(GSource* source, GMainContext* context);
void (*g_source_destroy)(GSource* source);
GSource* (*g_source_new)(GSourceFuncs* source_funcs, guint struct_size);
void (*g_source_remove_poll)(GSource* source, GPollFD* fd);
void (*g_source_set_can_recurse)(GSource* source, gboolean can_recurse);
void (*g_source_unref)(GSource* source);
int (*g_strcmp0)(const char* str1, const char* str2);
GParamSpec* (*g_object_class_find_property)(
GObjectClass* oclass,
const gchar* property_name);
void (*g_object_get_valist)(
GObject* object,
const gchar* first_property_name,
va_list var_args);
GObject* (*g_object_new_with_properties)(
GType object_type,
guint n_properties,
const char** names,
const GValue* values);
GObject* (*g_object_new_valist)(
GType object_type,
const gchar* first_property_name,
va_list var_args);
void (*g_object_set_valist)(
GObject* object,
const gchar* first_property_name,
va_list var_args);
void (*g_object_unref)(gpointer object);
gulong (*g_signal_connect_data)(
gpointer instance,
const gchar* detailed_signal,
GCallback c_handler,
gpointer data,
GClosureNotify destroy_data,
GConnectFlags connect_flags);
GTypeInstance* (*g_type_check_instance_cast)(
GTypeInstance* instance,
GType iface_type);
gboolean (*g_type_check_instance_is_a)(
GTypeInstance* instance,
GType iface_type);
gboolean (*g_type_check_instance_is_fundamentally_a)(
GTypeInstance* instance,
GType fundamental_type);
void (*g_type_ensure)(GType type);
struct HandleDeleter {
void operator()(void *handle) {
dlclose(handle);
}
};
using Handle = std::unique_ptr<void, HandleDeleter>;
bool LoadLibrary(Handle &handle, const char *name) {
handle = Handle(dlopen(name, RTLD_LAZY | RTLD_NODELETE));
if (handle) {
return true;
}
std::cerr << dlerror() << std::endl;
return false;
}
template <typename Function>
inline bool LoadSymbol(const Handle &handle, const char *name, Function &func) {
func = handle
? reinterpret_cast<Function>(dlsym(handle.get(), name))
: nullptr;
if (const auto error = dlerror()) {
std::cerr << error << std::endl;
}
return (func != nullptr);
}
bool Resolve() {
static const auto loaded = [&] {
auto lib = Handle();
return LoadLibrary(lib, "libglib-2.0.so.0")
&& LOAD_SYMBOL(lib, g_free)
&& LOAD_SYMBOL(lib, g_log_default_handler)
&& LOAD_SYMBOL(lib, g_log_set_handler)
&& LOAD_SYMBOL(lib, g_main_context_default)
&& LOAD_SYMBOL(lib, g_main_context_iteration)
&& LOAD_SYMBOL(lib, g_main_context_new)
&& LOAD_SYMBOL(lib, g_main_context_pending)
&& LOAD_SYMBOL(lib, g_main_context_pop_thread_default)
&& LOAD_SYMBOL(lib, g_main_context_push_thread_default)
&& LOAD_SYMBOL(lib, g_main_context_ref)
&& LOAD_SYMBOL(lib, g_main_context_unref)
&& LOAD_SYMBOL(lib, g_main_context_wakeup)
&& LOAD_SYMBOL(lib, g_return_if_fail_warning)
&& LOAD_SYMBOL(lib, g_slist_free)
&& LOAD_SYMBOL(lib, g_source_add_poll)
&& LOAD_SYMBOL(lib, g_source_attach)
&& LOAD_SYMBOL(lib, g_source_destroy)
&& LOAD_SYMBOL(lib, g_source_new)
&& LOAD_SYMBOL(lib, g_source_remove_poll)
&& LOAD_SYMBOL(lib, g_source_set_can_recurse)
&& LOAD_SYMBOL(lib, g_source_unref)
&& LOAD_SYMBOL(lib, g_strcmp0)
&& LoadLibrary(lib, "libgobject-2.0.so.0")
&& LOAD_SYMBOL(lib, g_object_class_find_property)
&& LOAD_SYMBOL(lib, g_object_get_valist)
&& LOAD_SYMBOL(lib, g_object_new_valist)
&& LOAD_SYMBOL(lib, g_object_new_with_properties)
&& LOAD_SYMBOL(lib, g_object_set_valist)
&& LOAD_SYMBOL(lib, g_object_unref)
&& LOAD_SYMBOL(lib, g_signal_connect_data)
&& LOAD_SYMBOL(lib, g_type_check_instance_cast)
&& LOAD_SYMBOL(lib, g_type_check_instance_is_a)
&& LOAD_SYMBOL(lib, g_type_check_instance_is_fundamentally_a)
&& LOAD_SYMBOL(lib, g_type_ensure);
}();
return loaded;
}
} // namespace
} // namespace GlibHelper
void g_free(gpointer mem) {
GlibHelper::Resolve();
GlibHelper::g_free(mem);
}
void g_log_default_handler(
const gchar* log_domain,
GLogLevelFlags log_level,
const gchar* message,
gpointer unused_data) {
GlibHelper::Resolve();
GlibHelper::g_log_default_handler(
log_domain,
log_level,
message,
unused_data);
}
guint g_log_set_handler(
const gchar* log_domain,
GLogLevelFlags log_levels,
GLogFunc log_func,
gpointer user_data) {
GlibHelper::Resolve();
return GlibHelper::g_log_set_handler(
log_domain,
log_levels,
log_func,
user_data);
}
GMainContext* g_main_context_default(void) {
GlibHelper::Resolve();
return GlibHelper::g_main_context_default();
}
gboolean g_main_context_iteration(GMainContext* context, gboolean may_block) {
GlibHelper::Resolve();
return GlibHelper::g_main_context_iteration(context, may_block);
}
GMainContext* g_main_context_new(void) {
GlibHelper::Resolve();
return GlibHelper::g_main_context_new();
}
gboolean g_main_context_pending(GMainContext* context) {
GlibHelper::Resolve();
return GlibHelper::g_main_context_pending(context);
}
void g_main_context_pop_thread_default(GMainContext* context) {
GlibHelper::Resolve();
GlibHelper::g_main_context_pop_thread_default(context);
}
void g_main_context_push_thread_default(GMainContext* context) {
GlibHelper::Resolve();
GlibHelper::g_main_context_push_thread_default(context);
}
GMainContext* g_main_context_ref(GMainContext* context) {
GlibHelper::Resolve();
return GlibHelper::g_main_context_ref(context);
}
void g_main_context_unref(GMainContext* context) {
GlibHelper::Resolve();
GlibHelper::g_main_context_unref(context);
}
void g_main_context_wakeup(GMainContext* context) {
GlibHelper::Resolve();
GlibHelper::g_main_context_wakeup(context);
}
void g_return_if_fail_warning(
const char* log_domain,
const char* pretty_function,
const char* expression) {
GlibHelper::Resolve();
GlibHelper::g_return_if_fail_warning(
log_domain,
pretty_function,
expression);
}
void g_slist_free(GSList* list) {
GlibHelper::Resolve();
GlibHelper::g_slist_free(list);
}
void g_source_add_poll(GSource* source, GPollFD* fd) {
GlibHelper::Resolve();
GlibHelper::g_source_add_poll(source, fd);
}
guint g_source_attach(GSource* source, GMainContext* context) {
GlibHelper::Resolve();
return GlibHelper::g_source_attach(source, context);
}
void g_source_destroy(GSource* source) {
GlibHelper::Resolve();
GlibHelper::g_source_destroy(source);
}
GSource* g_source_new(GSourceFuncs* source_funcs, guint struct_size) {
GlibHelper::Resolve();
return GlibHelper::g_source_new(source_funcs, struct_size);
}
void g_source_remove_poll(GSource* source, GPollFD* fd) {
GlibHelper::Resolve();
GlibHelper::g_source_remove_poll(source, fd);
}
void g_source_set_can_recurse(GSource* source, gboolean can_recurse) {
GlibHelper::Resolve();
GlibHelper::g_source_set_can_recurse(source, can_recurse);
}
void g_source_unref(GSource* source) {
GlibHelper::Resolve();
GlibHelper::g_source_unref(source);
}
int g_strcmp0(const char* str1, const char* str2) {
GlibHelper::Resolve();
return GlibHelper::g_strcmp0(str1, str2);
}
GParamSpec* g_object_class_find_property(
GObjectClass* oclass,
const gchar* property_name) {
GlibHelper::Resolve();
return GlibHelper::g_object_class_find_property(
oclass,
property_name);
}
void g_object_get(
gpointer _object,
const gchar *first_property_name,
...) {
GlibHelper::Resolve();
GObject *object = (GObject*) _object;
va_list var_args;
g_return_if_fail(G_IS_OBJECT(object));
va_start(var_args, first_property_name);
GlibHelper::g_object_get_valist(object, first_property_name, var_args);
va_end(var_args);
}
gpointer g_object_new(
GType object_type,
const gchar *first_property_name,
...) {
GlibHelper::Resolve();
GObject *object;
va_list var_args;
/* short circuit for calls supplying no properties */
if (!first_property_name)
return GlibHelper::g_object_new_with_properties(object_type, 0, NULL, NULL);
va_start(var_args, first_property_name);
object = GlibHelper::g_object_new_valist(object_type, first_property_name, var_args);
va_end(var_args);
return object;
}
void g_object_set(
gpointer _object,
const gchar *first_property_name,
...) {
GlibHelper::Resolve();
GObject *object = (GObject*) _object;
va_list var_args;
g_return_if_fail(G_IS_OBJECT(object));
va_start(var_args, first_property_name);
GlibHelper::g_object_set_valist(object, first_property_name, var_args);
va_end(var_args);
}
void g_object_unref(gpointer object) {
GlibHelper::Resolve();
GlibHelper::g_object_unref(object);
}
gulong g_signal_connect_data(
gpointer instance,
const gchar* detailed_signal,
GCallback c_handler,
gpointer data,
GClosureNotify destroy_data,
GConnectFlags connect_flags) {
GlibHelper::Resolve();
return GlibHelper::g_signal_connect_data(
instance,
detailed_signal,
c_handler,
data,
destroy_data,
connect_flags);
}
GTypeInstance* g_type_check_instance_cast(
GTypeInstance* instance,
GType iface_type) {
GlibHelper::Resolve();
return GlibHelper::g_type_check_instance_cast(instance, iface_type);
}
gboolean g_type_check_instance_is_a(
GTypeInstance* instance,
GType iface_type) {
GlibHelper::Resolve();
return GlibHelper::g_type_check_instance_is_a(instance, iface_type);
}
gboolean g_type_check_instance_is_fundamentally_a(
GTypeInstance* instance,
GType fundamental_type) {
GlibHelper::Resolve();
return GlibHelper::g_type_check_instance_is_fundamentally_a(
instance,
fundamental_type);
}
void g_type_ensure(GType type) {
GlibHelper::Resolve();
GlibHelper::g_type_ensure(type);
}

View file

@ -12,11 +12,9 @@ PRIVATE
linux_gtk_helper.cpp
)
target_compile_definitions(linux_gtk_helper PRIVATE G_LOG_DOMAIN="GtkHelper")
target_link_libraries(linux_gtk_helper
PUBLIC
desktop-app::external_glib
${CMAKE_DL_LIBS}
)
find_package(PkgConfig REQUIRED)

View file

@ -5,11 +5,10 @@
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
#include <dlfcn.h>
#include <errno.h>
#include <glib.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <memory>
#include <iostream>
#define LOAD_SYMBOL(handle, func) LoadSymbol(handle, #func, func)
@ -218,7 +217,7 @@ bool LoadLibrary(Handle &handle, const char *name) {
if (handle) {
return true;
}
g_warning("Could not load library '%s': %s", name, dlerror());
std::cerr << dlerror() << std::endl;
return false;
}
@ -228,7 +227,7 @@ inline bool LoadSymbol(const Handle &handle, const char *name, Function &func) {
? reinterpret_cast<Function>(dlsym(handle.get(), name))
: nullptr;
if (const auto error = dlerror()) {
g_warning("Failed to load function '%s': %s", name, error);
std::cerr << error << std::endl;
}
return (func != nullptr);
}

View file

@ -12,10 +12,8 @@ PRIVATE
linux_wayland_helper.cpp
)
target_compile_definitions(linux_wayland_helper PRIVATE G_LOG_DOMAIN="WaylandHelper")
target_link_libraries(linux_wayland_helper
PUBLIC
desktop-app::external_glib
desktop-app::external_gsl
${CMAKE_DL_LIBS}
)

View file

@ -7,9 +7,9 @@
#include <dlfcn.h>
#include <errno.h>
#include <gsl/gsl>
#include <glib.h>
#include <wayland-egl.h>
#include <wayland-cursor.h>
#include <iostream>
#define LOAD_SYMBOL(handle, func) LoadSymbol(handle, #func, func)
@ -184,7 +184,7 @@ bool LoadLibrary(Handle &handle, const char *name) {
if (handle) {
return true;
}
g_warning("Could not load library '%s': %s", name, dlerror());
std::cerr << dlerror() << std::endl;
return false;
}
@ -194,7 +194,7 @@ inline bool LoadSymbol(const Handle &handle, const char *name, Function &func) {
? reinterpret_cast<Function>(dlsym(handle.get(), name))
: nullptr;
if (const auto error = dlerror()) {
g_warning("Failed to load function '%s': %s", name, error);
std::cerr << error << std::endl;
}
return (func != nullptr);
}

View file

@ -42,13 +42,6 @@ if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
)
endif()
if (DESKTOP_APP_DISABLE_GTK_INTEGRATION)
target_compile_definitions(common_options
INTERFACE
DESKTOP_APP_DISABLE_GTK_INTEGRATION
)
endif()
if (DESKTOP_APP_USE_PACKAGED)
target_compile_definitions(common_options
INTERFACE

View file

@ -17,6 +17,11 @@ INTERFACE
-Wno-sign-compare
)
target_link_options(common_options
INTERFACE
-Wl,--as-needed
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(common_options
INTERFACE
@ -59,7 +64,7 @@ if (DESKTOP_APP_USE_ALLOCATION_TRACER)
-Wl,-wrap,aligned_alloc
-Wl,-wrap,posix_memalign
-Wl,-wrap,free
-Wl,--no-as-needed,-lrt
-Wl,--no-as-needed,-lrt,--as-needed
)
target_link_libraries(common_options
INTERFACE
@ -73,6 +78,7 @@ if (NOT DESKTOP_APP_USE_PACKAGED)
target_link_options(common_options
INTERFACE
-static-libstdc++
-static-libgcc
)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_link_static_libraries(common_options
@ -89,6 +95,7 @@ if (NOT DESKTOP_APP_USE_PACKAGED)
INTERFACE
-pthread
-rdynamic
-fwhole-program
)
endif()

View file

@ -14,7 +14,7 @@ endif()
if (NOT DESKTOP_APP_USE_PACKAGED)
target_include_directories(common_options SYSTEM
INTERFACE
/usr/local/macos/include
${libs_loc}/local/include
)
endif()
@ -35,7 +35,6 @@ INTERFACE
-Wno-sign-compare
-Wno-unknown-attributes
-Wno-pragma-system-header-outside-header
-Wno-range-loop-analysis
)
if (DESKTOP_APP_SPECIAL_TARGET)

View file

@ -21,7 +21,6 @@ option(DESKTOP_APP_LOTTIE_USE_CACHE "Use caching in lottie animations." ON)
option(DESKTOP_APP_DISABLE_DBUS_INTEGRATION "Disable all code for D-Bus integration (Linux only)." OFF)
option(DESKTOP_APP_DISABLE_X11_INTEGRATION "Disable all code for X11 integration (Linux only)." OFF)
option(DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION "Disable all code for Wayland integration (Linux only)." OFF)
option(DESKTOP_APP_DISABLE_GTK_INTEGRATION "Disable all code for GTK integration (Linux only)." OFF)
option(DESKTOP_APP_USE_ALLOCATION_TRACER "Use simple allocation tracer (Linux only)." OFF)
option(DESKTOP_APP_USE_PACKAGED "Find libraries using CMake instead of exact paths." ${no_special_target})
option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt plugins for self-contained packages. (Linux only)" OFF)
@ -85,8 +84,6 @@ endif()
if (build_win64)
get_filename_component(libs_loc "../Libraries64" REALPATH)
elseif (NOT APPLE)
get_filename_component(libs_loc "../Libraries" REALPATH)
else()
get_filename_component(libs_loc "../Libraries/macos" REALPATH)
get_filename_component(libs_loc "../Libraries" REALPATH)
endif()