Mercurial > minori
diff 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 |
line wrap: on
line diff
--- a/dep/animia/CMakeLists.txt Thu Nov 16 16:51:34 2023 -0500 +++ b/dep/animia/CMakeLists.txt Fri Nov 17 02:07:33 2023 -0500 @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.16) project(animia LANGUAGES CXX) set(SRC_FILES # any non-platform-specific files go here @@ -11,64 +11,79 @@ ) set(LIBRARIES) - -set(INCLUDE_DIRS - include -) - +set(INCLUDE_DIRS) set(DEFINES) -# FD -if(LINUX) - list(APPEND DEFINES LINUX) - list(APPEND SRC_FILES - # linux - src/fd/linux.cc - ) -elseif(APPLE) # this won't run on Linux +if(APPLE) list(APPEND DEFINES MACOSX) list(APPEND SRC_FILES # xnu stuff src/fd/xnu.cc ) + check_language(OBJCXX) + if(CMAKE_OBJCXX_COMPILER) + enable_language(OBJCXX) + list(APPEND SRC_FILES + src/win/quartz.mm + ) + find_library(FOUNDATION_LIBRARY Foundation) + find_library(COREGRAPHICS_LIBRARY CoreGraphics) + find_library(APPKIT_LIBRARY AppKit) + list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY}) + else() # NOT CMAKE_OBJCXX_COMPILER + message(WARNING "An Objective-C++ compiler couldn't be found! Window enumeration support will not be compiled.") + endif() # CMAKE_OBJCXX_COMPILER elseif(WIN32) list(APPEND DEFINES WIN32) list(APPEND SRC_FILES # win32 src/fd/win32.cc - ) -endif() - -# Windows -if(WIN32) - list(APPEND SRC_FILES src/win/win32.cc src/util/win32.cc ) -elseif(APPLE) - enable_language(OBJCXX) - list(APPEND SRC_FILES - src/win/quartz.mm - ) - find_library(FOUNDATION_LIBRARY Foundation) - find_library(COREGRAPHICS_LIBRARY CoreGraphics) - find_library(APPKIT_LIBRARY AppKit) - list(APPEND LIBRARIES ${FOUNDATION_LIBRARY} ${COREGRAPHICS_LIBRARY} ${APPKIT_LIBRARY}) -else() - find_package(X11::X11) - if (X11_FOUND) +else() # NOT WIN32 AND NOT APPLE + if(LINUX) + list(APPEND DEFINES LINUX) + list(APPEND SRC_FILES + # linux + src/fd/linux.cc + ) + endif() # LINUX + + # X11 + find_package(X11 COMPONENTS X11) + if(X11_FOUND) list(APPEND DEFINES X11) list(APPEND SRC_FILES src/win/x11.cc ) list(APPEND INCLUDE_DIRS - ${X11_INCLUDE_DIR} + ${X11_INCLUDE_DIRS} ) list(APPEND LIBRARIES ${X11_LIBRARIES} ) - endif() -endif() + 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) + list(APPEND DEFINES X11) + list(APPEND SRC_FILES + src/win/x11.cc + ) + list(APPEND INCLUDE_DIRS + ${X11_INCLUDE_DIRS} + ) + list(APPEND LIBRARIES + ${X11_LIBRARIES} + ) + endif() # X11_FOUND + endif() # PKG_CONFIG_FOUND + endif() # X11_FOUND +endif() # WIN32 AND APPLE add_library(animia SHARED ${SRC_FILES}) set_target_properties(animia PROPERTIES @@ -76,16 +91,6 @@ CXX_STANDARD 17 ) -if(WIN32) - target_compile_definitions(animia PUBLIC WIN32) -elseif(LINUX) - target_compile_definitions(animia PUBLIC LINUX) -elseif(UNIX) - if(APPLE) - target_compile_definitions(animia PUBLIC MACOSX) - endif() - target_compile_definitions(animia PUBLIC UNIX) -endif() - -target_include_directories(animia PRIVATE include) +target_compile_definitions(animia PUBLIC ${DEFINES}) +target_include_directories(animia PRIVATE include PUBLIC ${INCLUDE_DIRS}) target_link_libraries(animia PUBLIC ${LIBRARIES})