comparison dep/animia/CMakeLists.txt @ 202:71832ffe425a

animia: re-add kvm fd source this is all being merged from my wildly out-of-date laptop. SORRY! in other news, I edited the CI file to install the wayland client as well, so the linux CI build might finally get wayland stuff.
author Paper <paper@paper.us.eu.org>
date Tue, 02 Jan 2024 06:05:06 -0500
parents 8f6f8dd2eb23 9f3534f6b8c4
children 8a482049b968
comparison
equal deleted inserted replaced
201:8f6f8dd2eb23 202:71832ffe425a
26 26
27 include(CheckIncludeFile) 27 include(CheckIncludeFile)
28 check_include_file("CoreFoundation/CoreFoundation.h" HAVE_COREFOUNDATION) 28 check_include_file("CoreFoundation/CoreFoundation.h" HAVE_COREFOUNDATION)
29 # If you're building on OS X, you most likely do have this file, but we 29 # If you're building on OS X, you most likely do have this file, but we
30 # check anyway. 30 # check anyway.
31 if (HAVE_COREFOUNDATION) 31 if(HAVE_COREFOUNDATION)
32 list(APPEND DEFINES HAVE_COREFOUNDATION) 32 list(APPEND DEFINES HAVE_COREFOUNDATION)
33 endif() 33 find_library(OBJC_LIBRARY objc)
34 34
35 check_language(OBJCXX) 35 if(NOT OBJC_LIBRARY)
36 if(CMAKE_OBJCXX_COMPILER) 36 message(STATUS "Found CoreFoundation/CoreFoundation.h, but not the Objective-C runtime. How?")
37 enable_language(OBJCXX) 37 endif()
38 list(APPEND SRC_FILES 38
39 src/win/quartz.mm 39 list(APPEND SRC_FILES src/win/quartz.cc)
40 ) 40
41 find_library(FOUNDATION_LIBRARY Foundation) 41 find_library(FOUNDATION_LIBRARY Foundation)
42 find_library(COREGRAPHICS_LIBRARY CoreGraphics) 42 find_library(COREGRAPHICS_LIBRARY CoreGraphics)
43 find_library(APPKIT_LIBRARY AppKit) 43 find_library(APPKIT_LIBRARY AppKit)
44 list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY}) 44 list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY} ${OBJC_LIBRARY})
45 else() # NOT CMAKE_OBJCXX_COMPILER 45 else() # NOT HAVE_COREFOUNDATION
46 message(WARNING "An Objective-C++ compiler couldn't be found! Window enumeration support will not be compiled.") 46 message(STATUS "You don't have Core Foundation. How? What kind of voodoo magic did you do to cause this?")
47 endif() # CMAKE_OBJCXX_COMPILER 47 message(WARNING "LaunchServices support will not be compiled.")
48 endif() # HAVE_COREFOUNDATION
48 elseif(WIN32) 49 elseif(WIN32)
49 list(APPEND DEFINES WIN32) 50 list(APPEND DEFINES WIN32)
50 list(APPEND SRC_FILES 51 list(APPEND SRC_FILES
51 # win32 52 # win32
52 src/fd/win32.cc 53 src/fd/win32.cc
57 find_library(LIBUTIL_LIBRARY util) 58 find_library(LIBUTIL_LIBRARY util)
58 find_library(LIBKVM_LIBRARY kvm) 59 find_library(LIBKVM_LIBRARY kvm)
59 60
60 if(LINUX) 61 if(LINUX)
61 list(APPEND DEFINES LINUX) 62 list(APPEND DEFINES LINUX)
62 list(APPEND SRC_FILES 63 list(APPEND SRC_FILES src/fd/proc.cc)
63 src/fd/proc.cc
64 )
65 elseif(LIBUTIL_LIBRARY) # FreeBSD's libutil 64 elseif(LIBUTIL_LIBRARY) # FreeBSD's libutil
66 get_filename_component(LIBUTIL_DIR ${LIBUTIL_LIBRARY} DIRECTORY) 65 get_filename_component(LIBUTIL_DIR ${LIBUTIL_LIBRARY} DIRECTORY)
67 66
68 include(CheckLibraryExists) 67 include(CheckLibraryExists)
69 check_library_exists(util kinfo_getfile ${LIBUTIL_DIR} LIBUTIL_GOOD) 68 check_library_exists(util kinfo_getfile ${LIBUTIL_DIR} LIBUTIL_GOOD)
72 list(APPEND LIBRARIES ${LIBUTIL_LIBRARY}) 71 list(APPEND LIBRARIES ${LIBUTIL_LIBRARY})
73 list(APPEND DEFINES LIBUTIL) 72 list(APPEND DEFINES LIBUTIL)
74 list(APPEND SRC_FILES src/fd/libutil.cc) 73 list(APPEND SRC_FILES src/fd/libutil.cc)
75 endif() # LIBUTIL_GOOD 74 endif() # LIBUTIL_GOOD
76 elseif(LIBKVM_LIBRARY) # OpenBSD kvm 75 elseif(LIBKVM_LIBRARY) # OpenBSD kvm
77 include(CheckSymbolExists) 76 list(APPEND LIBRARIES ${LIBKVM_LIBRARY})
78 # Check if we can get open files by PID 77 list(APPEND DEFINES LIBKVM)
79 check_symbol_exists(KERN_FILE_BYPID "kvm.h" HAVE_BYPID) 78 list(APPEND SRC_FILES src/fd/kvm.cc)
80 79
81 if(HAVE_BYPID) 80 get_filename_component(LIBKVM_DIR ${LIBKVM_LIBRARY} DIRECTORY)
82 list(APPEND LIBRARIES ${LIBKVM_LIBRARY}) 81
83 list(APPEND DEFINES LIBKVM) 82 include(CheckLibraryExists)
84 list(APPEND SRC_FILES src/fd/kvm.cc) 83 check_library_exists(kvm kvm_getfiles ${LIBKVM_DIR} LIBKVM_HAS_GETFILES)
85 endif() # LIBUTIL_GOOD 84
85 if(LIBKVM_HAS_GETFILES)
86 list(APPEND DEFINES HAVE_KVM_GETFILES)
87 endif() # LIBKVM_HAS_GETFILES
86 endif() # LINUX 88 endif() # LINUX
87 89
88 # X11 90 # X11
89 find_package(X11 COMPONENTS X11) 91 find_package(X11 COMPONENTS X11 XRes)
92
90 if(X11_FOUND) 93 if(X11_FOUND)
94 # Getting PIDs from windows...
95 if (X11_XRes_FOUND)
96 list(APPEND DEFINES HAVE_XRES)
97 else() # NOT X11_XRes_FOUND
98 message(WARNING "libXRes could not be found! Finding PIDs in X11 windows may not work correctly!")
99 endif() # X11_XRes_FOUND
100
91 list(APPEND DEFINES X11) 101 list(APPEND DEFINES X11)
92 list(APPEND SRC_FILES 102 list(APPEND SRC_FILES src/win/x11.cc)
93 src/win/x11.cc 103 list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS})
94 ) 104 list(APPEND LIBRARIES ${X11_LIBRARIES}) # This will include Xres, I think..
95 list(APPEND INCLUDE_DIRS
96 ${X11_INCLUDE_DIRS}
97 )
98 list(APPEND LIBRARIES
99 ${X11_LIBRARIES}
100 )
101 else() # NOT X11_FOUND 105 else() # NOT X11_FOUND
102 # For some systems, i.e. Debian, FindX11 fails to find X11, so we have 106 # For some systems, i.e. Debian, FindX11 fails to find X11, so we have
103 # to use pkg_config as a fallback 107 # to use pkg_config as a fallback
104 find_package(PkgConfig) 108 find_package(PkgConfig)
105 if(PKG_CONFIG_FOUND) 109 if(PKG_CONFIG_FOUND)
106 pkg_check_modules(X11 x11) 110 pkg_check_modules(X11 x11)
107 if(X11_FOUND) 111 if(X11_FOUND)
112 # Check for XRes the hard way
113 find_path(X11_XRes_HEADER "X11/extensions/XRes.h" PATHS ${X11_INCLUDE_DIRS})
114 find_library(X11_XRes_LIB XRes PATHS ${X11_LIBRARY_DIRS})
115
116 if(X11_XRes_HEADER AND X11_XRes_LIB)
117 # TODO: We should REALLY check for XResQueryClientIds here...
118 list(APPEND DEFINES HAVE_XRES)
119 list(APPEND LIBRARIES ${X11_XRes_LIB})
120 else()
121 message(WARNING "libXRes could not be found! Finding PIDs in X11 windows may not work correctly!")
122 endif()
123
108 list(APPEND DEFINES X11) 124 list(APPEND DEFINES X11)
109 list(APPEND SRC_FILES 125 list(APPEND SRC_FILES src/win/x11.cc)
110 src/win/x11.cc 126 list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS})
111 ) 127 list(APPEND LIBRARIES ${X11_LINK_LIBRARIES})
112 list(APPEND INCLUDE_DIRS
113 ${X11_INCLUDE_DIRS}
114 )
115 list(APPEND LIBRARIES
116 ${X11_LINK_LIBRARIES}
117 )
118 endif() # X11_FOUND 128 endif() # X11_FOUND
119 endif() # PKG_CONFIG_FOUND 129 endif() # PKG_CONFIG_FOUND
120 endif() # X11_FOUND 130 endif() # X11_FOUND
131
132 find_package(PkgConfig)
133 if(PKG_CONFIG_FOUND)
134 pkg_check_modules(WAYLAND wayland-client)
135 if(WAYLAND_FOUND)
136 enable_language(C)
137 list(APPEND DEFINES WAYLAND)
138 list(APPEND SRC_FILES
139 src/win/wayland.cc
140 src/win/wayland/ext-foreign-toplevel-list-v1.c
141 )
142 list(APPEND INCLUDE_DIRS ${WAYLAND_INCLUDE_DIRS})
143 list(APPEND LIBRARIES ${WAYLAND_LINK_LIBRARIES})
144 endif() # WAYLAND_FOUND
145 endif() # PKG_CONFIG_FOUND
121 endif() # WIN32 AND APPLE 146 endif() # WIN32 AND APPLE
122 147
123 add_library(animia SHARED ${SRC_FILES}) 148 add_library(animia SHARED ${SRC_FILES})
124 set_target_properties(animia PROPERTIES 149 set_target_properties(animia PROPERTIES
125 PUBLIC_HEADER include/animia.h 150 PUBLIC_HEADER include/animia.h
126 CXX_STANDARD 17 151 CXX_STANDARD 17
127 ) 152 )
128 153
129 target_compile_definitions(animia PUBLIC ${DEFINES}) 154 target_compile_definitions(animia PRIVATE ${DEFINES})
130 target_include_directories(animia PUBLIC include PRIVATE ${INCLUDE_DIRS}) 155 target_include_directories(animia PUBLIC include PRIVATE ${INCLUDE_DIRS})
131 target_link_libraries(animia PUBLIC ${LIBRARIES}) 156 target_link_libraries(animia PUBLIC ${LIBRARIES})