Fix DependentOptions splitting arguments on spaces

Fix broken x11.cc

Signed-off-by: Tin <tin.svagelj@live.com>
This commit is contained in:
Tin 2023-11-10 21:25:45 +01:00 committed by Brenden Matthews
parent f6d42c5a69
commit cbebe44707
No known key found for this signature in database
GPG Key ID: 137B7AC2BDFD8DF0
3 changed files with 664 additions and 647 deletions

View File

@ -109,8 +109,9 @@ cmake_dependent_option(BUILD_HDDTEMP "Support for hddtemp" true
cmake_dependent_option(BUILD_IPV6 "Enable if you want IPv6 support" true
"OS_LINUX" false)
# nvidia may also work on FreeBSD, not sure
cmake_dependent_option(BUILD_NVIDIA "Enable nvidia support" false
"OS_LINUX" false)
dependent_option(BUILD_NVIDIA "Enable Nvidia stat support on Linux" false
"OS_LINUX;BUILD_X11" false
"Nvidia stat supports only Linux and requires X11")
# macOS Only
cmake_dependent_option(
@ -165,6 +166,9 @@ else()
"Xfixes support requires X11")
endif(OS_DARWIN)
dependent_option(BUILD_ARGB "Build ARGB (real transparency) support" true
"OWN_WINDOW" false
"ARGB support requires OWN_WINDOW enabled")
dependent_option(BUILD_XINERAMA "Build Xinerama support" true
"BUILD_X11" false
"Xinerama support requires X11")
@ -180,6 +184,9 @@ dependent_option(BUILD_IMLIB2 "Enable Imlib2 support" true
dependent_option(BUILD_XSHAPE "Enable Xshape support" true
"BUILD_X11" false
"Xshape support requires X11")
dependent_option(BUILD_XINPUT "Build Xinput 2 support" true
"BUILD_X11;BUILD_MOUSE_EVENTS" false
"Xinput 2 support requires X11 and BUILD_MOUSE_EVENTS enabled")
# if we build with any GUI support
if(BUILD_X11)
@ -192,13 +199,6 @@ endif(BUILD_WAYLAND)
dependent_option(BUILD_MOUSE_EVENTS "Enable mouse event support" true
"BUILD_WAYLAND OR OWN_WINDOW" false
"Mouse event support requires Wayland or OWN_WINDOW enabled")
dependent_option(BUILD_XINPUT "Build Xinput 2 support" true
"BUILD_X11;BUILD_MOUSE_EVENTS" false
"Xinput 2 support requires X11 and BUILD_MOUSE_EVENTS enabled")
dependent_option(BUILD_ARGB "Build ARGB (real transparency) support" true
"OWN_WINDOW" false
"ARGB support requires OWN_WINDOW enabled")
# Lua library options
option(BUILD_LUA_CAIRO "Build cairo bindings for Lua" false)
@ -247,6 +247,8 @@ option(BUILD_PULSEAUDIO
option(BUILD_INTEL_BACKLIGHT
"Enable support for Intel backlight" false)
run_dependency_checks()
message(STATUS "CMAKE_C_FLAGS: " ${CMAKE_C_FLAGS})
message(STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS})

View File

@ -9,28 +9,52 @@ https://github.com/Kitware/CMake/blob/master/Modules/CMakeDependentOption.cmake
Modified to so it produces warnings instead of hiding an option completely and
sets a default value.
Difference is that `depends` argument is ALWAYS a semicolon separated list of
<expr> tokens.
Argument meaning and order are the same, and there's an additional (warn)
argument which is the message printed if the end-user enabled a feature which
isn't "possible".
Actual checks are deferred until RUN_DEPENDENCY_CHECKS() is called in order to
allow out of order declaration of dependencies and dependecy graph cycles.
As the checks can affect each other they're run in a loop until the graph settles.
That means CMake can end up in an infinite loop, though it shouldn't happen with
normal use... (i.e. disable A if B not present)
#]=======================================================================]
set(__DEPENDENT_OPTIONS_CHANGE_HAPPENED true)
set(__DEPENDENT_OPTIONS_LATER_INVOKED_CODE "")
macro(DEPENDENT_OPTION option doc default depends else warn)
set(${option}_POSSIBLE 1)
foreach(d ${depends})
cmake_language(EVAL CODE "
if (${d})
option(${option} "${doc}" "${default}")
string(APPEND __DEPENDENT_OPTIONS_LATER_INVOKED_CODE "
set(${option}_POSSIBLE 1)
string(REGEX MATCHALL \"[^;]+\" __${option}_TOKENS \"${depends}\")
foreach(it \${__${option}_TOKENS})
cmake_language(EVAL CODE \"
if (\${it})
else()
set(${option}_POSSIBLE 0)
endif()"
)
endforeach()
option(${option} "${doc}" "${default}")
if(NOT ${option}_POSSIBLE)
if(NOT ${option} MATCHES ${else})
message(NOTICE "${warn}; setting to '${else}'.")
endif()\")
endforeach()
unset(__${option}_TOKENS)
if(NOT ${option}_POSSIBLE)
if(NOT \"\${${option}}\" STREQUAL \"${else}\")
message(NOTICE \"${warn}; setting to '${else}'.\")
set(${option} ${else} CACHE BOOL \"${doc}\" FORCE)
set(__DEPENDENT_OPTIONS_CHANGE_HAPPENED true)
endif()
endif()
set(${option} ${else} CACHE BOOL "${doc}" FORCE)
endif()
unset(${option}_POSSIBLE)
unset(${option}_POSSIBLE)")
endmacro()
macro(RUN_DEPENDENCY_CHECKS)
while(__DEPENDENT_OPTIONS_CHANGE_HAPPENED)
set(__DEPENDENT_OPTIONS_CHANGE_HAPPENED false)
cmake_language(EVAL CODE "${__DEPENDENT_OPTIONS_LATER_INVOKED_CODE}")
endwhile()
set(__DEPENDENT_OPTIONS_CHANGE_HAPPENED true)
set(__DEPENDENT_OPTIONS_LATER_INVOKED_CODE "")
endmacro()

1239
src/x11.cc

File diff suppressed because it is too large Load Diff