comparison dep/animone/CMakeLists.txt @ 343:1faa72660932

*: transfer back to cmake from autotools autotools just made lots of things more complicated than they should have and many things broke (i.e. translations)
author Paper <paper@paper.us.eu.org>
date Thu, 20 Jun 2024 05:56:06 -0400
parents
children 886f66775f31
comparison
equal deleted inserted replaced
342:adb79bdde329 343:1faa72660932
1 cmake_minimum_required(VERSION 3.16)
2 project(animone LANGUAGES CXX)
3 set(SRC_FILES
4 # any non-platform-specific files go here
5 src/animone.cc
6 src/player.cc
7 src/util.cc
8 src/strategist.cc
9 src/fd.cc
10 src/a11y.cc
11 src/win.cc
12 )
13
14 set(LIBRARIES)
15 set(INCLUDE_DIRS)
16 set(DEFINES)
17
18 list(APPEND DEFINES DLL_EXPORT)
19
20 if(APPLE)
21 list(APPEND DEFINES USE_MACOSX)
22 list(APPEND SRC_FILES
23 # xnu stuff
24 src/fd/xnu.cc
25 src/win/quartz.cc
26 )
27
28 # ...
29 find_library(OBJC_LIBRARY objc REQUIRED)
30 find_library(FOUNDATION_LIBRARY Foundation REQUIRED)
31 find_library(COREGRAPHICS_LIBRARY CoreGraphics REQUIRED)
32 find_library(APPLICATIONSERVICES_LIBRARY ApplicationServices REQUIRED)
33 list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${APPLICATIONSERVICES_LIBRARY} ${OBJC_LIBRARY})
34 elseif(WIN32)
35 list(APPEND DEFINES USE_WIN32)
36 list(APPEND SRC_FILES
37 # win32
38 src/a11y/win32.cc
39 src/fd/win32.cc
40 src/win/win32.cc
41 src/util/win32.cc
42 )
43
44 find_library(OLE32_LIB ole32 REQUIRED)
45 find_library(OLEAUT32_LIB oleaut32 REQUIRED)
46 list(APPEND LIBRARIES ${OLE32_LIB} ${OLEAUT32_LIB})
47 else() # NOT WIN32 AND NOT APPLE
48 find_library(LIBUTIL_LIB util)
49 find_library(LIBKVM_LIB kvm)
50
51 if(LINUX)
52 list(APPEND DEFINES USE_LINUX)
53 list(APPEND SRC_FILES src/fd/proc.cc)
54 elseif(LIBUTIL_LIBRARY) # FreeBSD
55 # stupid hackarounds
56 get_filename_component(LIBUTIL_DIR ${LIBUTIL_LIBRARY} DIRECTORY)
57
58 include(CheckLibraryExists)
59 check_library_exists(util kinfo_getfile ${LIBUTIL_DIR} LIBUTIL_GOOD)
60
61 if(LIBUTIL_GOOD)
62 list(APPEND DEFINES USE_FREEBSD)
63 list(APPEND LIBRARIES ${LIBUTIL_LIBRARY})
64 list(APPEND SRC_FILES src/fd/freebsd.cc)
65 endif() # LIBUTIL_GOOD
66 elseif(LIBKVM_LIBRARY) # OpenBSD
67 get_filename_component(LIBKVM_DIR ${LIBKVM_LIBRARY} DIRECTORY)
68
69 include(CheckLibraryExists)
70 check_library_exists(kvm kvm_getfiles ${LIBKVM_DIR} LIBKVM_HAS_GETFILES)
71
72 if(LIBKVM_HAS_GETFILES)
73 list(APPEND DEFINES USE_OPENBSD)
74 list(APPEND LIBRARIES ${LIBKVM_LIBRARY})
75 list(APPEND SRC_FILES src/fd/openbsd.cc)
76 endif() # LIBKVM_HAS_GETFILES
77 endif() # LINUX
78 endif() # WIN32 AND APPLE
79
80 # X11
81 find_package(PkgConfig)
82 if(PKG_CONFIG_FOUND)
83 pkg_check_modules(XCB xcb xcb-res)
84 if (XCB_FOUND)
85 list(APPEND DEFINES USE_X11)
86 list(APPEND LIBRARIES ${XCB_LINK_LIBRARIES})
87 list(APPEND INCLUDE_DIRS ${XCB_INCLUDE_DIRS})
88 list(APPEND SRC_FILES src/win/x11.cc)
89 endif() # XCB_FOUND
90 endif() # PKG_CONFIG_FOUND
91
92 add_library(animia SHARED ${SRC_FILES})
93 set_target_properties(animia PROPERTIES
94 PUBLIC_HEADER include/animia.h
95 CXX_STANDARD 17
96 )
97
98 target_compile_definitions(animia PRIVATE ${DEFINES})
99 target_include_directories(animia PUBLIC include PRIVATE ${INCLUDE_DIRS})
100 target_link_libraries(animia PUBLIC ${LIBRARIES})