2024-06-18 11:38:26 +02:00
|
|
|
cmake_minimum_required(VERSION 3.19)
|
|
|
|
|
2024-07-18 20:03:42 +02:00
|
|
|
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
|
|
|
|
string(STRIP ${VER_RAW} AQUAMARINE_VERSION)
|
|
|
|
|
2024-06-18 11:38:26 +02:00
|
|
|
add_compile_definitions(AQUAMARINE_VERSION="${AQUAMARINE_VERSION}")
|
|
|
|
|
2024-07-18 20:03:58 +02:00
|
|
|
project(
|
|
|
|
aquamarine
|
|
|
|
VERSION ${AQUAMARINE_VERSION}
|
|
|
|
DESCRIPTION "A very light linux rendering backend library")
|
2024-06-18 11:38:26 +02:00
|
|
|
|
|
|
|
include(CTest)
|
2024-07-07 05:44:09 +02:00
|
|
|
include(CheckIncludeFile)
|
2024-06-18 11:38:26 +02:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set(INCLUDE ${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
|
|
|
set(LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR})
|
|
|
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
2024-07-11 20:41:53 +02:00
|
|
|
find_package(OpenGL REQUIRED COMPONENTS "GLES2")
|
2024-07-08 17:06:10 +02:00
|
|
|
find_package(hyprwayland-scanner 0.4.0 REQUIRED)
|
2024-07-18 20:03:58 +02:00
|
|
|
pkg_check_modules(
|
|
|
|
deps
|
|
|
|
REQUIRED
|
|
|
|
IMPORTED_TARGET
|
|
|
|
libseat>=0.8.0
|
|
|
|
libinput>=1.26.0
|
|
|
|
wayland-client
|
|
|
|
wayland-protocols
|
|
|
|
hyprutils>=0.1.5
|
|
|
|
pixman-1
|
|
|
|
libdrm
|
|
|
|
gbm
|
|
|
|
libudev
|
|
|
|
libdisplay-info
|
|
|
|
hwdata)
|
2024-06-18 11:38:26 +02:00
|
|
|
|
|
|
|
configure_file(aquamarine.pc.in aquamarine.pc @ONLY)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
2024-07-14 11:06:13 +02:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
2024-06-18 11:38:26 +02:00
|
|
|
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
2024-07-18 20:03:58 +02:00
|
|
|
message(STATUS "Configuring aquamarine in Debug")
|
|
|
|
add_compile_definitions(AQUAMARINE_DEBUG)
|
2024-06-18 11:38:26 +02:00
|
|
|
else()
|
2024-07-18 20:03:58 +02:00
|
|
|
add_compile_options(-O3)
|
|
|
|
message(STATUS "Configuring aquamarine in Release")
|
2024-06-18 11:38:26 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "include/*.hpp")
|
|
|
|
file(GLOB_RECURSE PUBLIC_HEADERS CONFIGURE_DEPENDS "include/*.hpp")
|
|
|
|
|
|
|
|
add_library(aquamarine SHARED ${SRCFILES})
|
2024-07-18 20:03:58 +02:00
|
|
|
target_include_directories(
|
|
|
|
aquamarine
|
|
|
|
PUBLIC "./include"
|
|
|
|
PRIVATE "./src" "./src/include" "./protocols" "${CMAKE_BINARY_DIR}")
|
|
|
|
set_target_properties(aquamarine PROPERTIES VERSION ${AQUAMARINE_VERSION}
|
2024-09-02 11:16:44 +02:00
|
|
|
SOVERSION 3)
|
cmake: link libOpenGL instead of legacy libGL (#44)
From cmake documentation, Linux-specific chapter:
Projects may use the ``OpenGL::GL`` target (or ``OPENGL_LIBRARIES``
variable) to use legacy GL interfaces. These will use the legacy GL
library located by ``OPENGL_gl_LIBRARY``, if available. If
``OPENGL_gl_LIBRARY`` is empty or not found and GLVND is available,
the ``OpenGL::GL`` target will use GLVND ``OpenGL::OpenGL`` and
``OpenGL::GLX`` (and the ``OPENGL_LIBRARIES`` variable will use the
corresponding libraries). Thus, for non-EGL-based Linux targets, the
``OpenGL::GL`` target is most portable.
which means linking with OpenGL::GL makes cmake find legacy libGL.so or
GLX libraries, and as for now, the former contains GLX symbols and cannot
be built without X libraries. Since we are working with EGL, it wouldn't
provide extra portability, either.
This patch switches to link aquamarine with modern OpenGL::OpenGL, which
contains core OpenGL API only, makes it possible to build on a
wayland-only system. Tested on eweOS, which is a distro without X
libraries.
Link: https://os.ewe.moe/
Signed-off-by: Yao Zi <ziyao@disroot.org>
2024-08-10 18:22:37 +02:00
|
|
|
target_link_libraries(aquamarine OpenGL::EGL OpenGL::OpenGL PkgConfig::deps)
|
2024-06-18 11:38:26 +02:00
|
|
|
|
2024-07-07 05:44:09 +02:00
|
|
|
check_include_file("sys/timerfd.h" HAS_TIMERFD)
|
|
|
|
pkg_check_modules(epoll IMPORTED_TARGET epoll-shim)
|
|
|
|
if(NOT HAS_TIMERFD AND epoll_FOUND)
|
2024-07-18 20:03:58 +02:00
|
|
|
target_link_libraries(aquamarine PkgConfig::epoll)
|
2024-07-07 05:44:09 +02:00
|
|
|
endif()
|
|
|
|
|
2024-06-18 18:45:05 +02:00
|
|
|
# Protocols
|
|
|
|
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
|
|
|
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
2024-08-19 15:02:14 +02:00
|
|
|
pkg_get_variable(WAYLAND_SCANNER_PKGDATA_DIR wayland-scanner pkgdatadir)
|
|
|
|
message(STATUS "Found wayland-scanner pkgdatadir at ${WAYLAND_SCANNER_PKGDATA_DIR}")
|
2024-06-18 18:45:05 +02:00
|
|
|
|
|
|
|
function(protocolNew protoPath protoName external)
|
2024-07-18 20:03:58 +02:00
|
|
|
if(external)
|
|
|
|
set(path ${CMAKE_SOURCE_DIR}/${protoPath})
|
|
|
|
else()
|
|
|
|
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
|
|
|
|
endif()
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp
|
|
|
|
COMMAND hyprwayland-scanner --client ${path}/${protoName}.xml
|
|
|
|
${CMAKE_SOURCE_DIR}/protocols/
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
|
|
target_sources(aquamarine PRIVATE protocols/${protoName}.cpp
|
|
|
|
protocols/${protoName}.hpp)
|
2024-06-18 18:45:05 +02:00
|
|
|
endfunction()
|
|
|
|
function(protocolWayland)
|
2024-07-18 20:03:58 +02:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/wayland.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/protocols/wayland.hpp
|
|
|
|
COMMAND hyprwayland-scanner --wayland-enums --client
|
2024-08-19 15:02:14 +02:00
|
|
|
${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
|
2024-07-18 20:03:58 +02:00
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
|
|
|
target_sources(aquamarine PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
|
2024-06-18 18:45:05 +02:00
|
|
|
endfunction()
|
|
|
|
|
2024-07-18 20:03:58 +02:00
|
|
|
protocolwayland()
|
2024-06-18 18:45:05 +02:00
|
|
|
|
2024-07-18 20:03:58 +02:00
|
|
|
protocolnew("stable/xdg-shell" "xdg-shell" false)
|
|
|
|
protocolnew("stable/linux-dmabuf" "linux-dmabuf-v1" false)
|
2024-06-18 18:45:05 +02:00
|
|
|
|
2024-07-02 13:12:47 +02:00
|
|
|
# Generate hwdata info
|
|
|
|
pkg_get_variable(HWDATA_DIR hwdata pkgdatadir)
|
2024-07-18 20:03:58 +02:00
|
|
|
message(
|
|
|
|
STATUS "Running ${CMAKE_SOURCE_DIR}/data/hwdata.sh < ${HWDATA_DIR}/pnp.ids")
|
2024-07-02 13:12:47 +02:00
|
|
|
execute_process(
|
2024-07-18 20:03:58 +02:00
|
|
|
COMMAND /bin/sh -c
|
|
|
|
"${CMAKE_SOURCE_DIR}/data/hwdata.sh < ${HWDATA_DIR}/pnp.ids"
|
|
|
|
RESULT_VARIABLE HWDATA_PNP_RESULT
|
|
|
|
OUTPUT_VARIABLE HWDATA_PNP_IDS ENCODING UTF8)
|
|
|
|
|
|
|
|
if(NOT HWDATA_PNP_RESULT MATCHES 0)
|
|
|
|
message(WARNING "hwdata gathering pnps failed")
|
2024-07-02 13:12:47 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
configure_file(data/hwdata.hpp.in hwdata.hpp @ONLY)
|
|
|
|
|
2024-06-18 18:45:05 +02:00
|
|
|
# tests
|
|
|
|
add_custom_target(tests)
|
|
|
|
|
|
|
|
add_executable(simpleWindow "tests/SimpleWindow.cpp")
|
2024-06-23 19:40:40 +02:00
|
|
|
target_link_libraries(simpleWindow PRIVATE PkgConfig::deps aquamarine)
|
2024-07-18 20:03:58 +02:00
|
|
|
add_test(
|
|
|
|
NAME "simpleWindow"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/tests
|
|
|
|
COMMAND simpleWindow "simpleWindow")
|
2024-06-18 18:45:05 +02:00
|
|
|
add_dependencies(tests simpleWindow)
|
|
|
|
|
2024-06-18 11:38:26 +02:00
|
|
|
# Installation
|
|
|
|
install(TARGETS aquamarine)
|
|
|
|
install(DIRECTORY "include/aquamarine" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2024-07-18 20:03:58 +02:00
|
|
|
install(FILES ${CMAKE_BINARY_DIR}/aquamarine.pc
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|