build: default to system tomlplusplus and CLI11

This commit is contained in:
Nick Bolton
2024-09-20 20:06:06 +01:00
committed by Chris Rizzitello
parent 60967bbc8d
commit 265ab87997
8 changed files with 91 additions and 22 deletions

View File

@ -3,3 +3,5 @@ brew 'cmake'
brew 'openssl'
brew 'ninja'
brew 'googletest'
brew 'tomlplusplus'
brew 'cli11'

View File

@ -12,6 +12,7 @@ Enhancements:
- #7519 Rename project to Deskflow (was Synergy Community Edition)
- #7533 Always upgrade packages on Arch Linux in deps script
- #7539 Lint and add comment to PR on lint failure
- #7544 Use system deps for `tomlplusplus` and `CLI11`
# 1.16.1

View File

@ -532,7 +532,7 @@ macro(configure_gtest)
# If there are any problems like this in future, please do feel free send us a patch! :)
option(SYSTEM_GTEST "Use system GoogleTest" ${DEFAULT_SYSTEM_GTEST})
if(SYSTEM_GTEST)
message(STATUS "Using system GoogleTest")
message(VERBOSE "Using system GoogleTest")
find_package(GTest)
if(GTEST_FOUND)
# Ordinarily, we'd use GTEST_LIBRARIES, but it seems that these do not always export
@ -637,23 +637,62 @@ macro(configure_wintoast)
endmacro()
macro(configure_tomlplusplus)
file(GLOB TOMLPLUSPLUS_DIR ${CMAKE_SOURCE_DIR}/subprojects/tomlplusplus-*)
if(TOMLPLUSPLUS_DIR)
set(HAVE_TOMLPLUSPLUS true)
add_definitions(-DHAVE_TOMLPLUSPLUS=1)
include_directories(${TOMLPLUSPLUS_DIR}/include)
file(GLOB tomlplusplus_dir ${CMAKE_SOURCE_DIR}/subprojects/tomlplusplus-*)
if(tomlplusplus_dir)
set(DEFAULT_SYSTEM_TOMLPLUSPLUS OFF)
else()
message(WARNING "Subproject 'tomlplusplus' not found")
set(DEFAULT_SYSTEM_TOMLPLUSPLUS ON)
endif()
option(DEFAULT_SYSTEM_TOMLPLUSPLUS "Use system tomlplusplus"
${DEFAULT_SYSTEM_TOMLPLUSPLUS})
if(DEFAULT_SYSTEM_TOMLPLUSPLUS)
message(VERBOSE "Using system tomlplusplus")
find_package(tomlplusplus)
if(tomlplusplus_FOUND)
message(STATUS "tomlplusplus version: ${tomlplusplus_VERSION}")
else()
message(WARNING "System tomlplusplus not found")
endif()
else()
if(EXISTS ${tomlplusplus_dir})
set(HAVE_TOMLPLUSPLUS true)
add_definitions(-DHAVE_TOMLPLUSPLUS=1)
include_directories(${tomlplusplus_dir}/include)
else()
message(WARNING "Local tomlplusplus subproject not found")
endif()
endif()
endmacro()
macro(configure_cli11)
file(GLOB CLI11_DIR ${CMAKE_SOURCE_DIR}/subprojects/CLI11-*)
if(CLI11_DIR)
set(HAVE_CLI11 true)
add_definitions(-DHAVE_CLI11=1)
include_directories(${CLI11_DIR}/include)
file(GLOB cli11_dir ${CMAKE_SOURCE_DIR}/subprojects/CLI11-*)
if(cli11_dir)
set(DEFAULT_SYSTEM_CLI11 OFF)
else()
message(WARNING "Subproject 'CLI11' not found")
set(DEFAULT_SYSTEM_CLI11 ON)
endif()
option(SYSTEM_CLI11 "Use system CLI11" ${DEFAULT_SYSTEM_CLI11})
if(SYSTEM_CLI11)
message(VERBOSE "Using system CLI11")
find_package(CLI11)
if(CLI11_FOUND)
message(STATUS "CLI11 version: ${CLI11_VERSION}")
else()
message(WARNING "System CLI11 not found")
endif()
else()
if(EXISTS ${CLI11_dir})
set(HAVE_CLI11 true)
add_definitions(-DHAVE_CLI11=1)
include_directories(${cli11_dir}/include)
else()
message(WARNING "Local CLI11 subproject not found")
endif()
endif()
endmacro()

View File

@ -50,8 +50,10 @@ config:
libgmock-dev \
libpugixml-dev \
libei-dev \
libportal-dev
optional: [libei-dev, libportal-dev]
libportal-dev \
libtomlplusplus-dev \
libcli11-dev
optional: [libei-dev, libportal-dev, libtomlplusplus-dev]
linuxmint:
<<: *debian
@ -82,7 +84,9 @@ config:
gmock-devel \
pugixml-devel \
libei-devel \
libportal-devel
libportal-devel \
tomlplusplus-devel \
cli11-devel
optional: [libei-devel, libportal-devel]
# RHEL is not actually supported yet, since it doesn't have Qt6 libs.
@ -128,7 +132,9 @@ config:
googlemock-devel \
pugixml-devel \
libei-devel \
libportal-devel
libportal-devel \
tomlplusplus-devel \
cli11-devel
arch: &arch
dependencies:
@ -149,7 +155,9 @@ config:
libportal \
qt6-base \
qt6-tools \
gtk3
gtk3 \
tomlplusplus \
cli11
manjaro:
<<: *arch

View File

@ -5,13 +5,24 @@
project('deskflow', 'cpp')
subproject('tomlplusplus')
subproject('cli11')
if host_machine.system() == 'windows'
subproject('wintoast')
endif
system_tomlplusplus = get_option('system-tomlplusplus')
if system_tomlplusplus
dependency('tomlplusplus', required: false)
else
subproject('tomlplusplus')
endif
system_cli11 = get_option('system-cli11')
if system_cli11
dependency('cli11', required: false)
else
subproject('cli11')
endif
system_gtest = get_option('system-gtest')
if system_gtest
dependency('gtest', required: false)

View File

@ -1,3 +1,5 @@
option('system-gtest', type: 'boolean', value: true, description: 'Use system gtest')
option('system-libportal', type: 'boolean', value: true, description: 'Use system libportal')
option('system-libei', type: 'boolean', value: true, description: 'Use system libei')
option('system-tomlplusplus', type: 'boolean', value: true, description: 'Use system tomlplusplus')
option('system-cli11', type: 'boolean', value: true, description: 'Use system cli11')

View File

@ -31,7 +31,9 @@ install_freebsd() {
qt6-tools \
gtk3 \
googletest \
pugixml
pugixml \
tomlplusplus \
cli11
}
install_openbsd() {

View File

@ -24,8 +24,12 @@ meson_bin = env.get_python_executable("meson")
def setup(no_system_list, static_list):
cmd = [meson_bin, "setup", build_dir]
# TODO: These special Windows exceptions should probably be in Meson
# or somewhere other than this script, as it's a bit hacky.
if env.is_windows():
cmd.append("-Dsystem-gtest=false")
cmd.append("-Dsystem-tomlplusplus=false")
cmd.append("-Dsystem-cli11=false")
for subproject in no_system_list or []:
cmd.append(f"-Dsystem-{subproject}=false")