diff dep/animia/CMakeLists.txt @ 169:e44b7c428d7c

dep/animia: add libkvm method (UNTESTED)
author Paper <mrpapersonic@gmail.com>
date Sun, 19 Nov 2023 17:30:38 -0500
parents 54c5d80a737e
children c413e475f496 8f6f8dd2eb23
line wrap: on
line diff
--- a/dep/animia/CMakeLists.txt	Sun Nov 19 05:36:41 2023 -0500
+++ b/dep/animia/CMakeLists.txt	Sun Nov 19 17:30:38 2023 -0500
@@ -54,16 +54,15 @@
 		src/util/win32.cc
 	)
 else() # NOT WIN32 AND NOT APPLE
+	find_library(LIBUTIL_LIBRARY util)
+	find_library(LIBKVM_LIBRARY kvm)
+
 	if(LINUX)
 		list(APPEND DEFINES LINUX)
 		list(APPEND SRC_FILES
 			src/fd/proc.cc
 		)
-	endif() # LINUX
-
-	# FreeBSD
-	find_library(LIBUTIL_LIBRARY util)
-	if(LIBUTIL_LIBRARY)
+	elseif(LIBUTIL_LIBRARY) # FreeBSD's libutil
 		get_filename_component(LIBUTIL_DIR ${LIBUTIL_LIBRARY} DIRECTORY)
 
 		include(CheckLibraryExists)
@@ -74,7 +73,18 @@
 			list(APPEND DEFINES LIBUTIL)
 			list(APPEND SRC_FILES src/fd/libutil.cc)
 		endif() # LIBUTIL_GOOD
-	endif() # LIBUTIL_LIBRARY
+	elseif(LIBKVM_LIBRARY) # BSD libkvm
+		get_filename_component(LIBKVM_DIR ${LIBKVM_LIBRARY} DIRECTORY)
+
+		include(CheckLibraryExists)
+		check_library_exists(kvm kvm_getprocs ${LIBKVM_DIR} LIBKVM_GOOD)
+
+		if(LIBKVM_GOOD)
+			list(APPEND LIBRARIES ${LIBKVM_LIBRARY})
+			list(APPEND DEFINES LIBKVM)
+			list(APPEND SRC_FILES src/fd/libkvm.cc)
+		endif() # LIBUTIL_GOOD
+	endif() # LINUX
 
 	# X11
 	find_package(X11 COMPONENTS X11)