diff dep/animia/CMakeLists.txt @ 221:53211cb1e7f5

library: add initial library stuff nice
author Paper <paper@paper.us.eu.org>
date Mon, 08 Jan 2024 13:21:08 -0500
parents 8a482049b968
children 8ccf0302afb1
line wrap: on
line diff
--- a/dep/animia/CMakeLists.txt	Mon Jan 08 11:56:09 2024 -0500
+++ b/dep/animia/CMakeLists.txt	Mon Jan 08 13:21:08 2024 -0500
@@ -86,65 +86,68 @@
 			list(APPEND DEFINES HAVE_KVM_GETFILES)
 		endif() # LIBKVM_HAS_GETFILES
 	endif() # LINUX
-
-	# X11
-	find_package(X11 COMPONENTS X11 XRes)
+endif() # WIN32 AND APPLE
 
-	if(X11_FOUND)
-		# Getting PIDs from windows...
-		if (X11_XRes_FOUND)
-			list(APPEND DEFINES HAVE_XRES)
-		else() # NOT X11_XRes_FOUND
-			message(WARNING "libXRes could not be found! Finding PIDs in X11 windows may not work correctly!")
-		endif() # X11_XRes_FOUND
+# It's technically possible to have an X server on macOS, so we
+# should compile X11 support.
+# X11
+find_package(X11 COMPONENTS X11 XRes)
 
-		list(APPEND DEFINES X11)
-		list(APPEND SRC_FILES src/win/x11.cc)
-		list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS})
-		list(APPEND LIBRARIES ${X11_LIBRARIES}) # This will include Xres, I think..
-	else() # NOT X11_FOUND
-		# For some systems, i.e. Debian, FindX11 fails to find X11, so we have
-		# to use pkg_config as a fallback
-		find_package(PkgConfig)
-		if(PKG_CONFIG_FOUND)
-			pkg_check_modules(X11 x11)
-			if(X11_FOUND)
-				# Check for XRes the hard way
-				find_path(X11_XRes_HEADER "X11/extensions/XRes.h" PATHS ${X11_INCLUDE_DIRS})
-				find_library(X11_XRes_LIB XRes PATHS ${X11_LIBRARY_DIRS})
+if(X11_FOUND)
+	# Getting PIDs from windows...
+	if (X11_XRes_FOUND)
+		list(APPEND DEFINES HAVE_XRES)
+	else() # NOT X11_XRes_FOUND
+		message(WARNING "libXRes could not be found! Finding PIDs in X11 windows may not work correctly!")
+	endif() # X11_XRes_FOUND
 
-				if(X11_XRes_HEADER AND X11_XRes_LIB)
-					# TODO: We should REALLY check for XResQueryClientIds here...
-					list(APPEND DEFINES HAVE_XRES)
-					list(APPEND LIBRARIES ${X11_XRes_LIB})
-				else()
-					message(WARNING "libXRes could not be found! Finding PIDs in X11 windows may not work correctly!")
-				endif()
-
-				list(APPEND DEFINES X11)
-				list(APPEND SRC_FILES src/win/x11.cc)
-				list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS})
-				list(APPEND LIBRARIES ${X11_LINK_LIBRARIES})
-			endif() # X11_FOUND
-		endif() # PKG_CONFIG_FOUND
-	endif() # X11_FOUND
-
+	list(APPEND DEFINES X11)
+	list(APPEND SRC_FILES src/win/x11.cc)
+	list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS})
+	list(APPEND LIBRARIES ${X11_LIBRARIES}) # This will include Xres, I think..
+else() # NOT X11_FOUND
+	# For some systems, i.e. Debian, FindX11 fails to find X11, so we have
+	# to use pkg_config as a fallback
 	find_package(PkgConfig)
 	if(PKG_CONFIG_FOUND)
-		pkg_check_modules(WAYLAND wayland-client)
-		if(WAYLAND_FOUND)
-			enable_language(C)
-			list(APPEND DEFINES WAYLAND)
-			list(APPEND SRC_FILES
-				src/win/wayland.cc
-				src/win/wayland/ext-foreign-toplevel-list-v1.c
-				src/win/wayland/wlr-foreign-toplevel-management-unstable-v1.c
-			)
-			list(APPEND INCLUDE_DIRS ${WAYLAND_INCLUDE_DIRS})
-			list(APPEND LIBRARIES ${WAYLAND_LINK_LIBRARIES})
-		endif() # WAYLAND_FOUND
+		pkg_check_modules(X11 x11)
+		if(X11_FOUND)
+			# Check for XRes the hard way
+			find_path(X11_XRes_HEADER "X11/extensions/XRes.h" PATHS ${X11_INCLUDE_DIRS})
+			find_library(X11_XRes_LIB XRes PATHS ${X11_LIBRARY_DIRS})
+
+			if(X11_XRes_HEADER AND X11_XRes_LIB)
+				# TODO: We should REALLY check for XResQueryClientIds here...
+				list(APPEND DEFINES HAVE_XRES)
+				list(APPEND LIBRARIES ${X11_XRes_LIB})
+			else()
+				message(WARNING "libXRes could not be found! Finding PIDs in X11 windows may not work correctly!")
+			endif()
+
+			list(APPEND DEFINES X11)
+			list(APPEND SRC_FILES src/win/x11.cc)
+			list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS})
+			list(APPEND LIBRARIES ${X11_LINK_LIBRARIES})
+		endif() # X11_FOUND
 	endif() # PKG_CONFIG_FOUND
-endif() # WIN32 AND APPLE
+endif() # X11_FOUND
+
+# Wayland.
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+	pkg_check_modules(WAYLAND wayland-client)
+	if(WAYLAND_FOUND)
+		enable_language(C)
+		list(APPEND DEFINES WAYLAND)
+		list(APPEND SRC_FILES
+			src/win/wayland.cc
+			src/win/wayland/ext-foreign-toplevel-list-v1.c
+			src/win/wayland/wlr-foreign-toplevel-management-unstable-v1.c
+		)
+		list(APPEND INCLUDE_DIRS ${WAYLAND_INCLUDE_DIRS})
+		list(APPEND LIBRARIES ${WAYLAND_LINK_LIBRARIES})
+	endif() # WAYLAND_FOUND
+endif() # PKG_CONFIG_FOUND
 
 add_library(animia SHARED ${SRC_FILES})
 set_target_properties(animia PROPERTIES