comparison dep/animia/CMakeLists.txt @ 158:80d6b28eb29f

dep/animia: fix most X11 stuff it looks like _NET_WM_PID isn't supported by MOST clients, or my code is wrong... core/filesystem: fix Linux config path handling on *nix
author Paper <mrpapersonic@gmail.com>
date Fri, 17 Nov 2023 02:07:33 -0500
parents cdf79282d647
children 61b76c7b656a
comparison
equal deleted inserted replaced
157:18c8eb5d1edc 158:80d6b28eb29f
1 cmake_minimum_required(VERSION 3.9) 1 cmake_minimum_required(VERSION 3.16)
2 project(animia LANGUAGES CXX) 2 project(animia LANGUAGES CXX)
3 set(SRC_FILES 3 set(SRC_FILES
4 # any non-platform-specific files go here 4 # any non-platform-specific files go here
5 src/animia.cc 5 src/animia.cc
6 src/player.cc 6 src/player.cc
9 src/fd.cc 9 src/fd.cc
10 src/win.cc 10 src/win.cc
11 ) 11 )
12 12
13 set(LIBRARIES) 13 set(LIBRARIES)
14 14 set(INCLUDE_DIRS)
15 set(INCLUDE_DIRS
16 include
17 )
18
19 set(DEFINES) 15 set(DEFINES)
20 16
21 # FD 17 if(APPLE)
22 if(LINUX)
23 list(APPEND DEFINES LINUX)
24 list(APPEND SRC_FILES
25 # linux
26 src/fd/linux.cc
27 )
28 elseif(APPLE) # this won't run on Linux
29 list(APPEND DEFINES MACOSX) 18 list(APPEND DEFINES MACOSX)
30 list(APPEND SRC_FILES 19 list(APPEND SRC_FILES
31 # xnu stuff 20 # xnu stuff
32 src/fd/xnu.cc 21 src/fd/xnu.cc
33 ) 22 )
23 check_language(OBJCXX)
24 if(CMAKE_OBJCXX_COMPILER)
25 enable_language(OBJCXX)
26 list(APPEND SRC_FILES
27 src/win/quartz.mm
28 )
29 find_library(FOUNDATION_LIBRARY Foundation)
30 find_library(COREGRAPHICS_LIBRARY CoreGraphics)
31 find_library(APPKIT_LIBRARY AppKit)
32 list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY})
33 else() # NOT CMAKE_OBJCXX_COMPILER
34 message(WARNING "An Objective-C++ compiler couldn't be found! Window enumeration support will not be compiled.")
35 endif() # CMAKE_OBJCXX_COMPILER
34 elseif(WIN32) 36 elseif(WIN32)
35 list(APPEND DEFINES WIN32) 37 list(APPEND DEFINES WIN32)
36 list(APPEND SRC_FILES 38 list(APPEND SRC_FILES
37 # win32 39 # win32
38 src/fd/win32.cc 40 src/fd/win32.cc
39 )
40 endif()
41
42 # Windows
43 if(WIN32)
44 list(APPEND SRC_FILES
45 src/win/win32.cc 41 src/win/win32.cc
46 src/util/win32.cc 42 src/util/win32.cc
47 ) 43 )
48 elseif(APPLE) 44 else() # NOT WIN32 AND NOT APPLE
49 enable_language(OBJCXX) 45 if(LINUX)
50 list(APPEND SRC_FILES 46 list(APPEND DEFINES LINUX)
51 src/win/quartz.mm 47 list(APPEND SRC_FILES
52 ) 48 # linux
53 find_library(FOUNDATION_LIBRARY Foundation) 49 src/fd/linux.cc
54 find_library(COREGRAPHICS_LIBRARY CoreGraphics) 50 )
55 find_library(APPKIT_LIBRARY AppKit) 51 endif() # LINUX
56 list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY}) 52
57 else() 53 # X11
58 find_package(X11::X11) 54 find_package(X11 COMPONENTS X11)
59 if (X11_FOUND) 55 if(X11_FOUND)
60 list(APPEND DEFINES X11) 56 list(APPEND DEFINES X11)
61 list(APPEND SRC_FILES 57 list(APPEND SRC_FILES
62 src/win/x11.cc 58 src/win/x11.cc
63 ) 59 )
64 list(APPEND INCLUDE_DIRS 60 list(APPEND INCLUDE_DIRS
65 ${X11_INCLUDE_DIR} 61 ${X11_INCLUDE_DIRS}
66 ) 62 )
67 list(APPEND LIBRARIES 63 list(APPEND LIBRARIES
68 ${X11_LIBRARIES} 64 ${X11_LIBRARIES}
69 ) 65 )
70 endif() 66 else() # NOT X11_FOUND
71 endif() 67 # For some systems, i.e. Debian, FindX11 fails to find X11, so we have
68 # to use pkg_config as a fallback
69 find_package(PkgConfig)
70 if(PKG_CONFIG_FOUND)
71 pkg_check_modules(X11 x11)
72 if(X11_FOUND)
73 list(APPEND DEFINES X11)
74 list(APPEND SRC_FILES
75 src/win/x11.cc
76 )
77 list(APPEND INCLUDE_DIRS
78 ${X11_INCLUDE_DIRS}
79 )
80 list(APPEND LIBRARIES
81 ${X11_LIBRARIES}
82 )
83 endif() # X11_FOUND
84 endif() # PKG_CONFIG_FOUND
85 endif() # X11_FOUND
86 endif() # WIN32 AND APPLE
72 87
73 add_library(animia SHARED ${SRC_FILES}) 88 add_library(animia SHARED ${SRC_FILES})
74 set_target_properties(animia PROPERTIES 89 set_target_properties(animia PROPERTIES
75 PUBLIC_HEADER include/animia.h 90 PUBLIC_HEADER include/animia.h
76 CXX_STANDARD 17 91 CXX_STANDARD 17
77 ) 92 )
78 93
79 if(WIN32) 94 target_compile_definitions(animia PUBLIC ${DEFINES})
80 target_compile_definitions(animia PUBLIC WIN32) 95 target_include_directories(animia PRIVATE include PUBLIC ${INCLUDE_DIRS})
81 elseif(LINUX)
82 target_compile_definitions(animia PUBLIC LINUX)
83 elseif(UNIX)
84 if(APPLE)
85 target_compile_definitions(animia PUBLIC MACOSX)
86 endif()
87 target_compile_definitions(animia PUBLIC UNIX)
88 endif()
89
90 target_include_directories(animia PRIVATE include)
91 target_link_libraries(animia PUBLIC ${LIBRARIES}) 96 target_link_libraries(animia PUBLIC ${LIBRARIES})