Make Meson-provided packages optional (#7459)
* Make Google Test optional * Download googletest with brew * Set gtest and gmock lib vars in Libraries.cmake * Fixed cmake format * Add googletest-devel for openSUSE * Fixed missing Meson arg for Windows * Add gmock-devel for openSUSE * Fixed openSUSE package names * Fixed openSUSE package names (correct OS) * Add success message to disambiguate confusing messages * Restore original gtest lib var for subproject * Make WinToast optional * Fixed formatting * Fixed cmake format * Only build WinToast sources if found
This commit is contained in:
parent
1e6c603739
commit
bcdf70a298
13 changed files with 87 additions and 21 deletions
1
Brewfile
1
Brewfile
|
|
@ -2,3 +2,4 @@ brew 'make'
|
||||||
brew 'cmake'
|
brew 'cmake'
|
||||||
brew 'openssl'
|
brew 'openssl'
|
||||||
brew 'ninja'
|
brew 'ninja'
|
||||||
|
brew 'googletest'
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,12 @@ macro(configure_libs)
|
||||||
|
|
||||||
config_qt()
|
config_qt()
|
||||||
configure_openssl()
|
configure_openssl()
|
||||||
configure_gtest()
|
|
||||||
configure_coverage()
|
configure_coverage()
|
||||||
|
|
||||||
|
if(BUILD_TESTS)
|
||||||
|
configure_gtest()
|
||||||
|
endif()
|
||||||
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
@ -398,9 +401,26 @@ macro(configure_gtest)
|
||||||
option(SYSTEM_GTEST "Use system GoogleTest" ${DEFAULT_SYSTEM_GTEST})
|
option(SYSTEM_GTEST "Use system GoogleTest" ${DEFAULT_SYSTEM_GTEST})
|
||||||
if(SYSTEM_GTEST)
|
if(SYSTEM_GTEST)
|
||||||
message(STATUS "Using system GoogleTest")
|
message(STATUS "Using system GoogleTest")
|
||||||
find_package(GTest REQUIRED)
|
find_package(GTest)
|
||||||
set(GTEST_LIBS GTest::GTest GTest::Main)
|
if(GTEST_FOUND)
|
||||||
|
# Ordinarily, we'd use GTEST_LIBRARIES, but it seems that these do not always export
|
||||||
|
# the required libraries (e.g. gmock) on some OS (e.g macOS with brew).
|
||||||
|
set(GTEST_LIB GTest::gtest)
|
||||||
|
set(GMOCK_LIB GTest::gmock)
|
||||||
|
else()
|
||||||
|
message(
|
||||||
|
FATAL_ERROR
|
||||||
|
"Google Test not found, re-configure with -DBUILD_TESTS=OFF or -DSYSTEM_GTEST=OFF"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
|
if(NOT EXISTS ${gtest_base_dir})
|
||||||
|
message(
|
||||||
|
FATAL_ERROR
|
||||||
|
"Google Test subproject not found, reconfigure with -DBUILD_TESTS=OFF"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
message(STATUS "Building GoogleTest")
|
message(STATUS "Building GoogleTest")
|
||||||
set(gtest_dir ${gtest_base_dir}/googletest)
|
set(gtest_dir ${gtest_base_dir}/googletest)
|
||||||
set(gmock_dir ${gtest_base_dir}/googlemock)
|
set(gmock_dir ${gtest_base_dir}/googlemock)
|
||||||
|
|
@ -416,7 +436,8 @@ macro(configure_gtest)
|
||||||
set_target_properties(gmock PROPERTIES COMPILE_FLAGS "-w")
|
set_target_properties(gmock PROPERTIES COMPILE_FLAGS "-w")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(GTEST_LIBS gtest gmock)
|
set(GTEST_LIB gtest)
|
||||||
|
set(GMOCK_LIB gmock)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
@ -497,7 +518,14 @@ function(find_openssl_dir_win32 result)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
macro(configure_wintoast)
|
macro(configure_wintoast)
|
||||||
# WinToast is a pretty niche library, and there doesn't seem to be a package for it.
|
# WinToast is a pretty niche library, and there doesn't seem to be an installable package,
|
||||||
|
# so we rely on building from source.
|
||||||
file(GLOB WINTOAST_DIR ${CMAKE_SOURCE_DIR}/subprojects/WinToast-*)
|
file(GLOB WINTOAST_DIR ${CMAKE_SOURCE_DIR}/subprojects/WinToast-*)
|
||||||
include_directories(${WINTOAST_DIR}/include)
|
if(WINTOAST_DIR)
|
||||||
|
set(HAVE_WINTOAST true)
|
||||||
|
include_directories(${WINTOAST_DIR}/include)
|
||||||
|
else()
|
||||||
|
message(WARNING "WinToast subproject not found")
|
||||||
|
endif()
|
||||||
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,8 @@ config:
|
||||||
qt6-base-devel \
|
qt6-base-devel \
|
||||||
qt6-tools-devel \
|
qt6-tools-devel \
|
||||||
gtk3-devel \
|
gtk3-devel \
|
||||||
|
googletest-devel \
|
||||||
|
googlemock-devel \
|
||||||
pugixml-devel \
|
pugixml-devel \
|
||||||
libei-devel \
|
libei-devel \
|
||||||
libportal-devel
|
libportal-devel
|
||||||
|
|
|
||||||
13
meson.build
13
meson.build
|
|
@ -3,16 +3,17 @@
|
||||||
|
|
||||||
project('synergy', 'cpp')
|
project('synergy', 'cpp')
|
||||||
|
|
||||||
gtest = dependency('gtest', required: false)
|
system_gtest = get_option('system_gtest')
|
||||||
if not gtest.found()
|
if system_gtest
|
||||||
|
dependency('gtest', required: false)
|
||||||
|
else
|
||||||
subproject('gtest')
|
subproject('gtest')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if host_machine.system() == 'windows'
|
if host_machine.system() == 'windows'
|
||||||
wintoast = dependency('wintoast', required: false)
|
# WinToast is a niche lib which is not commonly installed,
|
||||||
if not wintoast.found()
|
# so depend only on the subproject.
|
||||||
subproject('wintoast')
|
subproject('wintoast')
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if host_machine.system() == 'linux'
|
if host_machine.system() == 'linux'
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
option('system_gtest', type: 'boolean', value: true, description: 'Use system gtest')
|
||||||
option('system_libportal', type: 'boolean', value: true, description: 'Use system libportal')
|
option('system_libportal', type: 'boolean', value: true, description: 'Use system libportal')
|
||||||
option('system_libei', type: 'boolean', value: true, description: 'Use system libei')
|
option('system_libei', type: 'boolean', value: true, description: 'Use system libei')
|
||||||
|
|
|
||||||
|
|
@ -180,3 +180,6 @@
|
||||||
|
|
||||||
/* Define if libei ei_device_start_emulating takes a sequence number */
|
/* Define if libei ei_device_start_emulating takes a sequence number */
|
||||||
#cmakedefine HAVE_LIBEI_SEQUENCE_NUMBER ${HAVE_LIBEI_SEQUENCE_NUMBER}
|
#cmakedefine HAVE_LIBEI_SEQUENCE_NUMBER ${HAVE_LIBEI_SEQUENCE_NUMBER}
|
||||||
|
|
||||||
|
/* Define if wintoast is available */
|
||||||
|
#cmakedefine HAVE_WINTOAST ${HAVE_WINTOAST}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,10 @@ def main():
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
error = True
|
error = True
|
||||||
|
|
||||||
|
colors = env.import_colors()
|
||||||
|
print()
|
||||||
|
print(f"{colors.SUCCESS_TEXT} Dependencies installed")
|
||||||
|
|
||||||
if args.pause_on_exit:
|
if args.pause_on_exit:
|
||||||
input("Press enter to continue...")
|
input("Press enter to continue...")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ from colorama import Fore # type: ignore
|
||||||
|
|
||||||
colorama.init()
|
colorama.init()
|
||||||
|
|
||||||
|
SUCCESS_TEXT = f"{Fore.GREEN}Success:{Fore.RESET}"
|
||||||
ERROR_TEXT = f"{Fore.RED}Error:{Fore.RESET}"
|
ERROR_TEXT = f"{Fore.RED}Error:{Fore.RESET}"
|
||||||
WARNING_TEXT = f"{Fore.YELLOW}Warning:{Fore.RESET}"
|
WARNING_TEXT = f"{Fore.YELLOW}Warning:{Fore.RESET}"
|
||||||
HINT_TEXT = f"{Fore.LIGHTBLUE_EX}Hint:{Fore.RESET}"
|
HINT_TEXT = f"{Fore.LIGHTBLUE_EX}Hint:{Fore.RESET}"
|
||||||
|
|
|
||||||
|
|
@ -227,3 +227,9 @@ def get_app_version():
|
||||||
|
|
||||||
with open("VERSION", "r") as f:
|
with open("VERSION", "r") as f:
|
||||||
return f.read().strip()
|
return f.read().strip()
|
||||||
|
|
||||||
|
|
||||||
|
def import_colors():
|
||||||
|
import lib.colors as colors
|
||||||
|
|
||||||
|
return colors
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,15 @@ meson_bin = env.get_python_executable("meson")
|
||||||
|
|
||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
reconfigure = "--reconfigure" if os.path.exists(build_dir) else ""
|
cmd = [meson_bin, "setup", build_dir]
|
||||||
cmd_utils.run([meson_bin, "setup", build_dir, reconfigure], print_cmd=True)
|
|
||||||
|
if env.is_windows():
|
||||||
|
cmd.append("-Dsystem_gtest=false")
|
||||||
|
|
||||||
|
if os.path.exists(build_dir):
|
||||||
|
cmd.append("--reconfigure")
|
||||||
|
|
||||||
|
cmd_utils.run(cmd, print_cmd=True)
|
||||||
|
|
||||||
|
|
||||||
def compile():
|
def compile():
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,11 @@ file(GLOB sources "*.cpp" "languages/*.cpp")
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
file(GLOB arch_headers "win32/*.h")
|
file(GLOB arch_headers "win32/*.h")
|
||||||
file(GLOB arch_sources "win32/*.cpp")
|
file(GLOB arch_sources "win32/*.cpp")
|
||||||
list(APPEND arch_sources ${WINTOAST_DIR}/src/wintoastlib.cpp)
|
|
||||||
|
if(HAVE_WINTOAST)
|
||||||
|
list(APPEND arch_sources ${WINTOAST_DIR}/src/wintoastlib.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
file(GLOB arch_headers "unix/*.h")
|
file(GLOB arch_headers "unix/*.h")
|
||||||
file(GLOB arch_sources "unix/*.cpp")
|
file(GLOB arch_sources "unix/*.cpp")
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* synergy -- mouse and keyboard sharing utility
|
* synergy -- mouse and keyboard sharing utility
|
||||||
* Copyright (C) 2012-2016 Symless Ltd.
|
* Copyright (C) 2012 Symless Ltd.
|
||||||
* Copyright (C) 2002 Chris Schoeneman
|
* Copyright (C) 2002 Chris Schoeneman
|
||||||
*
|
*
|
||||||
* This package is free software; you can redistribute it and/or
|
* This package is free software; you can redistribute it and/or
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "synergy/win32/AppUtilWindows.h"
|
#include "synergy/win32/AppUtilWindows.h"
|
||||||
|
|
||||||
#include "arch/IArchTaskBarReceiver.h"
|
#include "arch/IArchTaskBarReceiver.h"
|
||||||
#include "arch/win32/ArchMiscWindows.h"
|
#include "arch/win32/ArchMiscWindows.h"
|
||||||
#include "arch/win32/XArchWindows.h"
|
#include "arch/win32/XArchWindows.h"
|
||||||
|
|
@ -31,15 +32,17 @@
|
||||||
#include "synergy/ArgsBase.h"
|
#include "synergy/ArgsBase.h"
|
||||||
#include "synergy/Screen.h"
|
#include "synergy/Screen.h"
|
||||||
#include "synergy/XSynergy.h"
|
#include "synergy/XSynergy.h"
|
||||||
#include "wintoastlib.h"
|
|
||||||
|
|
||||||
#include <VersionHelpers.h>
|
#include <VersionHelpers.h>
|
||||||
|
#include <Windows.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <Windows.h>
|
#if HAVE_WINTOAST
|
||||||
|
#include "wintoastlib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
AppUtilWindows::AppUtilWindows(IEventQueue *events)
|
AppUtilWindows::AppUtilWindows(IEventQueue *events)
|
||||||
: m_events(events),
|
: m_events(events),
|
||||||
|
|
@ -198,6 +201,7 @@ HKL AppUtilWindows::getCurrentKeyboardLayout() const {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_WINTOAST
|
||||||
class WinToastHandler : public WinToastLib::IWinToastHandler {
|
class WinToastHandler : public WinToastLib::IWinToastHandler {
|
||||||
public:
|
public:
|
||||||
WinToastHandler() {}
|
WinToastHandler() {}
|
||||||
|
|
@ -207,9 +211,11 @@ public:
|
||||||
void toastDismissed(WinToastDismissalReason state) const override {}
|
void toastDismissed(WinToastDismissalReason state) const override {}
|
||||||
void toastFailed() const override {}
|
void toastFailed() const override {}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
void AppUtilWindows::showNotification(
|
void AppUtilWindows::showNotification(
|
||||||
const String &title, const String &text) const {
|
const String &title, const String &text) const {
|
||||||
|
#if HAVE_WINTOAST
|
||||||
LOG(
|
LOG(
|
||||||
(CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"",
|
(CLOG_INFO "showing notification, title=\"%s\", text=\"%s\"",
|
||||||
title.c_str(), text.c_str()));
|
title.c_str(), text.c_str()));
|
||||||
|
|
@ -247,4 +253,7 @@ void AppUtilWindows::showNotification(
|
||||||
CLOG_DEBUG "failed to show toast notification, error code: %d", error));
|
CLOG_DEBUG "failed to show toast notification, error code: %d", error));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
LOG((CLOG_INFO "toast notifications are not supported"));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -129,8 +129,6 @@ macro(config_test_deps)
|
||||||
include_directories(${CMAKE_BINARY_DIR}/src/lib/gui/gui_autogen/include)
|
include_directories(${CMAKE_BINARY_DIR}/src/lib/gui/gui_autogen/include)
|
||||||
|
|
||||||
set(test_libs
|
set(test_libs
|
||||||
gtest
|
|
||||||
gmock
|
|
||||||
arch
|
arch
|
||||||
base
|
base
|
||||||
client
|
client
|
||||||
|
|
@ -144,7 +142,8 @@ macro(config_test_deps)
|
||||||
ipc
|
ipc
|
||||||
license
|
license
|
||||||
gui
|
gui
|
||||||
${GTEST_LIBS}
|
${GMOCK_LIB}
|
||||||
|
${GTEST_LIB}
|
||||||
${libs})
|
${libs})
|
||||||
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue