Skip to content

Commit

Permalink
Set all HAVE_ macros on the top level
Browse files Browse the repository at this point in the history
This keep everything consistent.
  • Loading branch information
CendioOssman committed Jan 24, 2024
1 parent a5982bd commit fe4b014
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ endif()
# X11 stuff. It's in a if() so that we can say REQUIRED
if(UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
if(X11_Xdamage_LIB)
add_definitions(-DHAVE_XDAMAGE)
endif()
if(X11_Xfixes_LIB)
add_definitions(-DHAVE_XFIXES)
endif()
if(X11_Xrandr_LIB)
add_definitions(-DHAVE_XRANDR)
endif()
if(X11_XTest_LIB)
add_definitions(-DHAVE_XTEST)
endif()
endif()

# Check for zlib
Expand Down Expand Up @@ -306,6 +318,9 @@ if(UNIX AND NOT APPLE)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(LIBSYSTEMD libsystemd)
if (LIBSYSTEMD_FOUND)
add_definitions(-DHAVE_LIBSYSTEMD)
endif()
endif()
endif()

Expand Down
5 changes: 0 additions & 5 deletions unix/x0vncserver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,28 @@ target_link_libraries(x0vncserver tx rfb network rdr unixcommon)

# systemd support (socket activation)
if (LIBSYSTEMD_FOUND)
add_definitions(-DHAVE_SYSTEMD_H)
target_link_libraries(x0vncserver ${LIBSYSTEMD_LIBRARIES})
endif()

if(X11_XTest_LIB)
add_definitions(-DHAVE_XTEST)
target_link_libraries(x0vncserver ${X11_XTest_LIB})
else()
message(WARNING "No XTest extension. x0vncserver will be view-only.")
endif()

if(X11_Xdamage_LIB)
add_definitions(-DHAVE_XDAMAGE)
target_link_libraries(x0vncserver ${X11_Xdamage_LIB})
else()
message(WARNING "No DAMAGE extension. x0vncserver will have to use the slower polling method.")
endif()

if(X11_Xfixes_LIB)
add_definitions(-DHAVE_XFIXES)
target_link_libraries(x0vncserver ${X11_Xfixes_LIB})
else()
message(WARNING "No XFIXES extension. x0vncserver will not be able to show cursors.")
endif()

if(X11_Xrandr_LIB)
add_definitions(-DHAVE_XRANDR)
target_link_libraries(x0vncserver ${X11_Xrandr_LIB})
else()
message(WARNING "No Xrandr extension. x0vncserver will not be able to resize session.")
Expand Down
6 changes: 3 additions & 3 deletions unix/x0vncserver/x0vncserver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <rfb/Timer.h>
#include <network/TcpSocket.h>
#include <network/UnixSocket.h>
#ifdef HAVE_SYSTEMD_H
#ifdef HAVE_LIBSYSTEMD
# include <systemd/sd-daemon.h>
#endif

Expand Down Expand Up @@ -118,7 +118,7 @@ static void CleanupSignalHandler(int /*sig*/)

static bool hasSystemdListeners()
{
#ifdef HAVE_SYSTEMD_H
#ifdef HAVE_LIBSYSTEMD
// This also returns true on errors, because we then assume we were
// meant to use systemd but failed somewhere
return sd_listen_fds(0) != 0;
Expand All @@ -129,7 +129,7 @@ static bool hasSystemdListeners()

static int createSystemdListeners(std::list<SocketListener*> *listeners)
{
#ifdef HAVE_SYSTEMD_H
#ifdef HAVE_LIBSYSTEMD
int count = sd_listen_fds(0);
if (count < 0) {
vlog.error("Error getting listening sockets from systemd: %s",
Expand Down
1 change: 0 additions & 1 deletion vncviewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ else()
target_link_libraries(vncviewer ${X11_Xi_LIB})

if(X11_Xrandr_LIB)
add_definitions(-DHAVE_XRANDR)
target_link_libraries(vncviewer ${X11_Xrandr_LIB})
endif()
endif()
Expand Down

0 comments on commit fe4b014

Please sign in to comment.