cmake_minimum_required(VERSION 3.16) project(waylight LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) find_program(cppcheck_exe NAMES cppcheck) if (cppcheck_exe) set(cppcheck_opts --enable=all --inline-suppr --quiet --suppressions-list=${PROJECT_SOURCE_DIR}/cppcheck.supp) add_custom_target(run_cppcheck COMMAND ${cppcheck_exe} --std=c++20 --enable=all --inline-suppr --quiet --suppressions-list=${PROJECT_SOURCE_DIR}/cppcheck.supp --project=${CMAKE_BINARY_DIR}/compile_commands.json --check-level=exhaustive -i ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) endif() find_package(PkgConfig REQUIRED) pkg_check_modules(WAYLAND_CLIENT REQUIRED IMPORTED_TARGET wayland-client) pkg_check_modules(WAYLAND_EGL REQUIRED IMPORTED_TARGET wayland-egl) pkg_check_modules(EGL REQUIRED IMPORTED_TARGET egl) pkg_check_modules(GLES2 REQUIRED IMPORTED_TARGET glesv2) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(LIBPORTAL REQUIRED IMPORTED_TARGET libportal) pkg_check_modules(XKBCOMMON REQUIRED IMPORTED_TARGET xkbcommon) pkg_check_modules(FONTCONFIG REQUIRED IMPORTED_TARGET fontconfig) pkg_check_modules(HARFBUZZ REQUIRED IMPORTED_TARGET harfbuzz) pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols) pkg_check_modules(WLR_PROTOCOLS REQUIRED wlr-protocols) include(FetchContent) FetchContent_Declare( raylib GIT_REPOSITORY https://github.com/slendidev/raylib.git GIT_TAG "lunar" GIT_SHALLOW 1 ) set(OPENGL_VERSION "ES 2.0") set(PLATFORM DRM) set(BUILD_EXAMPLES OFF) FetchContent_MakeAvailable(raylib) FetchContent_Declare( msdfgen GIT_REPOSITORY https://github.com/Chlumsky/msdfgen.git GIT_TAG "v1.12.1" GIT_SHALLOW 1 ) set(MSDFGEN_BUILD_STANDALONE OFF) set(MSDFGEN_USE_VCPKG OFF) set(MSDFGEN_USE_SKIA OFF) set(MSDFGEN_DISABLE_SVG ON) set(MSDFGEN_DISABLE_PNG ON) FetchContent_MakeAvailable(msdfgen) FetchContent_Declare( mINI GIT_REPOSITORY https://github.com/metayeti/mINI.git GIT_TAG "0.9.18" GIT_SHALLOW 1 ) FetchContent_MakeAvailable(mINI) FetchContent_Declare( lunasvg GIT_REPOSITORY https://github.com/sammycage/lunasvg.git GIT_TAG "v3.5.0" GIT_SHALLOW 1 ) FetchContent_MakeAvailable(lunasvg) FetchContent_Declare( SQLiteCpp GIT_REPOSITORY https://github.com/SRombauts/SQLiteCpp.git GIT_TAG "3.3.3" GIT_SHALLOW 1 ) FetchContent_MakeAvailable(SQLiteCpp) FetchContent_Declare( cpptrace GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git GIT_TAG "v1.0.1" GIT_SHALLOW 1 ) FetchContent_MakeAvailable(cpptrace) FetchContent_Declare( tomlplusplus GIT_REPOSITORY https://github.com/marzer/tomlplusplus GIT_TAG "v3.4.0" GIT_SHALLOW 1 ) FetchContent_MakeAvailable(tomlplusplus) add_subdirectory(vendor) find_program(WAYLAND_SCANNER wayland-scanner REQUIRED) pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) if(NOT WAYLAND_PROTOCOLS_DIR OR NOT EXISTS "${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml") pkg_get_variable(_WP_DATAROOT wayland-protocols datarootdir) if(_WP_DATAROOT AND EXISTS "${_WP_DATAROOT}/wayland-protocols") set(WAYLAND_PROTOCOLS_DIR "${_WP_DATAROOT}/wayland-protocols") endif() endif() if(NOT WAYLAND_PROTOCOLS_DIR OR NOT EXISTS "${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml") find_path(WAYLAND_PROTOCOLS_DIR NAMES stable/xdg-shell/xdg-shell.xml HINTS ${CMAKE_SYSTEM_PREFIX_PATH} PATH_SUFFIXES wayland-protocols share/wayland-protocols ) endif() if(NOT WAYLAND_PROTOCOLS_DIR) message(FATAL_ERROR "Could not locate wayland-protocols datadir (install wayland-protocols?)") endif() set(XDG_SHELL_XML "${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml" ) set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") file(MAKE_DIRECTORY "${GEN_DIR}") pkg_get_variable(WLR_PROTOCOLS_DIR wlr-protocols pkgdatadir) if(NOT WLR_PROTOCOLS_DIR OR NOT EXISTS "${WLR_PROTOCOLS_DIR}/unstable/wlr-layer-shell-unstable-v1.xml") find_path(WLR_PROTOCOLS_DIR NAMES unstable/wlr-layer-shell-unstable-v1.xml HINTS ${CMAKE_SYSTEM_PREFIX_PATH} PATH_SUFFIXES wlr-protocols share/wlr-protocols ) endif() if(NOT WLR_PROTOCOLS_DIR) message(FATAL_ERROR "Could not locate wlr-protocols datadir (install wlr-protocols?)") endif() set(BACKGROUND_EFFECT_XML "${WAYLAND_PROTOCOLS_DIR}/staging/ext-background-effect/ext-background-effect-v1.xml" ) set(WLR_LAYER_SHELL_XML "${WLR_PROTOCOLS_DIR}/unstable/wlr-layer-shell-unstable-v1.xml" ) set(TEXT_INPUT_XML "${WAYLAND_PROTOCOLS_DIR}/unstable/text-input/text-input-unstable-v3.xml" ) set(GEN_C_HEADERS "${GEN_DIR}/xdg-shell-client-protocol.h" "${GEN_DIR}/wlr-layer-shell-unstable-v1-client-protocol.h" "${GEN_DIR}/ext-background-effect-v1-client-protocol.h" "${GEN_DIR}/blur-client-protocol.h" "${GEN_DIR}/text-input-unstable-v3-client-protocol.h" ) set(GEN_C_PRIVATES "${GEN_DIR}/xdg-shell-protocol.c" "${GEN_DIR}/wlr-layer-shell-unstable-v1-protocol.c" "${GEN_DIR}/ext-background-effect-v1-protocol.c" "${GEN_DIR}/blur-protocol.c" "${GEN_DIR}/text-input-unstable-v3-protocol.c" ) add_custom_command( OUTPUT ${GEN_C_HEADERS} ${GEN_C_PRIVATES} COMMAND "${WAYLAND_SCANNER}" client-header "${XDG_SHELL_XML}" "${GEN_DIR}/xdg-shell-client-protocol.h" COMMAND "${WAYLAND_SCANNER}" private-code "${XDG_SHELL_XML}" "${GEN_DIR}/xdg-shell-protocol.c" # ext-background-effect COMMAND "${WAYLAND_SCANNER}" client-header "${BACKGROUND_EFFECT_XML}" "${GEN_DIR}/ext-background-effect-v1-client-protocol.h" COMMAND "${WAYLAND_SCANNER}" private-code "${BACKGROUND_EFFECT_XML}" "${GEN_DIR}/ext-background-effect-v1-protocol.c" # wlr-layer-shell COMMAND "${WAYLAND_SCANNER}" client-header "${WLR_LAYER_SHELL_XML}" "${GEN_DIR}/wlr-layer-shell-unstable-v1-client-protocol.h" COMMAND "${WAYLAND_SCANNER}" private-code "${WLR_LAYER_SHELL_XML}" "${GEN_DIR}/wlr-layer-shell-unstable-v1-protocol.c" # text-input-unstable-v3 COMMAND "${WAYLAND_SCANNER}" client-header "${TEXT_INPUT_XML}" "${GEN_DIR}/text-input-unstable-v3-client-protocol.h" COMMAND "${WAYLAND_SCANNER}" private-code "${TEXT_INPUT_XML}" "${GEN_DIR}/text-input-unstable-v3-protocol.c" # org-kde-win-blur COMMAND "${WAYLAND_SCANNER}" client-header "${CMAKE_CURRENT_SOURCE_DIR}/blur.xml" "${GEN_DIR}/blur-client-protocol.h" COMMAND "${WAYLAND_SCANNER}" private-code "${CMAKE_CURRENT_SOURCE_DIR}/blur.xml" "${GEN_DIR}/blur-protocol.c" DEPENDS "${XDG_SHELL_XML}" "${WLR_LAYER_SHELL_XML}" "${TEXT_INPUT_XML}" COMMENT "Generating Wayland + wlr-layer-shell client headers and private code" VERBATIM ) add_custom_target(generate_protocols ALL DEPENDS ${GEN_C_HEADERS} ${GEN_C_PRIVATES} ) add_executable(waylight ${GEN_C_PRIVATES} ${CMAKE_CURRENT_SOURCE_DIR}/src/Config.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/IconRegistry.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Cache.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/InotifyWatcher.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/TextRenderer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/ImGui.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/App.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Tick.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ) add_dependencies(waylight generate_protocols) target_include_directories(waylight PRIVATE ${GEN_DIR} ) target_link_libraries(waylight PRIVATE PkgConfig::WAYLAND_CLIENT PkgConfig::WAYLAND_EGL PkgConfig::EGL PkgConfig::GLES2 PkgConfig::GLIB PkgConfig::LIBPORTAL PkgConfig::XKBCOMMON PkgConfig::FONTCONFIG PkgConfig::HARFBUZZ tomlplusplus::tomlplusplus cpptrace::cpptrace tinyfiledialogs mINI raylib msdfgen::msdfgen-core msdfgen::msdfgen-ext lunasvg::lunasvg SQLiteCpp m dl pthread ) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") target_compile_options(waylight PRIVATE -Wall -Wextra -Wno-unused-parameter) endif() install(TARGETS waylight RUNTIME DESTINATION bin)