Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/setup_base/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ runs:
glm \
glslang \
go \
gtest \
hyprlang \
hyprcursor \
jq \
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/nix-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@ jobs:

test:
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork)
needs: hyprland
uses: ./.github/workflows/nix-test.yml
secrets: inherit
101 changes: 75 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ message(
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Configuring Hyprland in Debug with CMake")
add_compile_definitions(HYPRLAND_DEBUG)
set(BUILD_TESTING ON)
else()
add_compile_options(-O3)
message(STATUS "Configuring Hyprland in Release with CMake")
set(BUILD_TESTING OFF)
endif()

add_compile_definitions(HYPRLAND_VERSION="${HYPRLAND_VERSION}")
Expand Down Expand Up @@ -231,7 +233,7 @@ set_source_files_properties(${CMAKE_SOURCE_DIR}/src/version.h PROPERTIES GENERAT
pkg_check_modules(
deps
REQUIRED
IMPORTED_TARGET
IMPORTED_TARGET GLOBAL
xkbcommon>=1.11.0
uuid
wayland-server>=1.22.90
Expand All @@ -251,14 +253,21 @@ pkg_check_modules(
find_package(hyprwayland-scanner 0.3.10 REQUIRED)

file(GLOB_RECURSE SRCFILES "src/*.cpp")
get_filename_component(FULL_MAIN_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ABSOLUTE)
list(REMOVE_ITEM SRCFILES "${FULL_MAIN_PATH}")

set(TRACY_CPP_FILES "")
if(USE_TRACY)
set(TRACY_CPP_FILES "subprojects/tracy/public/TracyClient.cpp")
message(STATUS "Tracy enabled, TRACY_CPP_FILES: " ${TRACY_CPP_FILES})
endif()

add_executable(Hyprland ${SRCFILES} ${TRACY_CPP_FILES})
add_library(hyprland_lib STATIC ${SRCFILES})
add_executable(Hyprland src/main.cpp ${TRACY_CPP_FILES})
target_link_libraries(Hyprland hyprland_lib)

target_include_directories(hyprland_lib PUBLIC ${deps_INCLUDE_DIRS})
target_include_directories(Hyprland PUBLIC ${deps_INCLUDE_DIRS})

set(USE_GPROF OFF)

Expand All @@ -268,8 +277,8 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
if(WITH_ASAN)
message(STATUS "Enabling ASan")

target_link_libraries(Hyprland asan)
target_compile_options(Hyprland PUBLIC -fsanitize=address)
target_link_libraries(hyprland_lib PUBLIC asan)
target_compile_options(hyprland_lib PUBLIC -fsanitize=address)
endif()

if(USE_TRACY)
Expand All @@ -279,7 +288,7 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
option(TRACY_ON_DEMAND "" ON)
add_subdirectory(subprojects/tracy)

target_link_libraries(Hyprland Tracy::TracyClient)
target_link_libraries(hyprland_lib PUBLIC Tracy::TracyClient)

if(USE_TRACY_GPU)
message(STATUS "Tracy GPU Profiling is turned on")
Expand All @@ -304,19 +313,19 @@ endif()
include(CheckLibraryExists)
check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO)
if(HAVE_LIBEXECINFO)
target_link_libraries(Hyprland execinfo)
target_link_libraries(hyprland_lib PUBLIC execinfo)
endif()

check_include_file("sys/timerfd.h" HAS_TIMERFD)
pkg_check_modules(epoll IMPORTED_TARGET epoll-shim)
if(NOT HAS_TIMERFD AND epoll_FOUND)
target_link_libraries(Hyprland PkgConfig::epoll)
target_link_libraries(hyprland_lib PUBLIC PkgConfig::epoll)
endif()

check_include_file("sys/inotify.h" HAS_INOTIFY)
pkg_check_modules(inotify IMPORTED_TARGET libinotify)
if(NOT HAS_INOTIFY AND inotify_FOUND)
target_link_libraries(Hyprland PkgConfig::inotify)
target_link_libraries(hyprland_lib PUBLIC PkgConfig::inotify)
endif()

if(NO_XWAYLAND)
Expand All @@ -335,7 +344,7 @@ else()
xcb-composite
xcb-res
xcb-errors)
target_link_libraries(Hyprland PkgConfig::xdeps)
target_link_libraries(hyprland_lib PUBLIC PkgConfig::xdeps)
endif()

if(NO_SYSTEMD)
Expand All @@ -362,31 +371,38 @@ if(CMAKE_DISABLE_PRECOMPILE_HEADERS)
message(STATUS "Not using precompiled headers")
else()
message(STATUS "Setting precompiled headers")
target_precompile_headers(Hyprland PRIVATE
target_precompile_headers(hyprland_lib PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:src/pch/pch.hpp>)
endif()

message(STATUS "Setting link libraries")

target_link_libraries(
Hyprland
${LIBRT}
hyprland_lib
PUBLIC
PkgConfig::aquamarine_dep
PkgConfig::hyprlang_dep
PkgConfig::hyprutils_dep
PkgConfig::hyprcursor_dep
PkgConfig::hyprgraphics_dep
PkgConfig::deps)
PkgConfig::deps
)

target_link_libraries(
Hyprland
${LIBRT}
hyprland_lib)
if(udis_dep_FOUND)
target_link_libraries(Hyprland PkgConfig::udis_dep)
target_link_libraries(hyprland_lib PUBLIC PkgConfig::udis_dep)
elseif(NOT("${udis_nopc}" MATCHES "udis_nopc-NOTFOUND"))
target_link_libraries(Hyprland ${udis_nopc})
target_link_libraries(hyprland_lib PUBLIC ${udis_nopc})
else()
target_link_libraries(Hyprland libudis86)
target_link_libraries(hyprland_lib PUBLIC libudis86)
endif()

# used by `make installheaders`, to ensure the headers are generated
add_custom_target(generate-protocol-headers)
set(PROTOCOL_SOURCES "")

function(protocolnew protoPath protoName external)
if(external)
Expand All @@ -400,10 +416,15 @@ function(protocolnew protoPath protoName external)
COMMAND hyprwayland-scanner ${path}/${protoName}.xml
${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(Hyprland PRIVATE protocols/${protoName}.cpp
target_sources(hyprland_lib PRIVATE protocols/${protoName}.cpp
protocols/${protoName}.hpp)
target_sources(generate-protocol-headers
PRIVATE ${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp)

list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp")
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp")
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
endfunction()
function(protocolWayland)
add_custom_command(
Expand All @@ -413,12 +434,17 @@ function(protocolWayland)
hyprwayland-scanner --wayland-enums
${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(Hyprland PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
target_sources(hyprland_lib PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
target_sources(generate-protocol-headers
PRIVATE ${CMAKE_SOURCE_DIR}/protocols/wayland.hpp)

list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/wayland.hpp")
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
list(APPEND PROTOCOL_SOURCES "${CMAKE_SOURCE_DIR}/protocols/wayland.cpp")
set(PROTOCOL_SOURCES "${PROTOCOL_SOURCES}" PARENT_SCOPE)
endfunction()

target_link_libraries(Hyprland OpenGL::EGL OpenGL::GL Threads::Threads)
target_link_libraries(hyprland_lib PUBLIC OpenGL::EGL OpenGL::GL Threads::Threads)

pkg_check_modules(hyprland_protocols_dep hyprland-protocols>=0.6.4)
if(hyprland_protocols_dep_FOUND)
Expand Down Expand Up @@ -563,10 +589,37 @@ install(
PATTERN "*.hpp"
PATTERN "*.inc")

if(BUILD_TESTING OR BUILD_HYPRTESTER)
message(STATUS "Building hyprtester")
if(BUILD_TESTING OR WITH_TESTS)
message(STATUS "Building tests")

# hyprtester
add_subdirectory(hyprtester)

# GTest
find_package(GTest CONFIG REQUIRED)
include(GoogleTest)
file(GLOB_RECURSE TESTFILES "tests/*.cpp")
add_executable(hyprland_gtests ${TESTFILES})
target_compile_options(hyprland_gtests PRIVATE --coverage)
target_link_options(hyprland_gtests PRIVATE --coverage)
target_include_directories(
hyprland_gtests
PUBLIC "./include"
PRIVATE "./src" "./src/include" "./protocols" "${CMAKE_BINARY_DIR}")

target_link_libraries(hyprland_gtests hyprland_lib GTest::gtest_main)

gtest_discover_tests(hyprland_gtests)

# Enable coverage in main hyprland lib
target_compile_options(hyprland_lib PRIVATE --coverage)
target_link_options(hyprland_lib PRIVATE --coverage)
target_link_libraries(hyprland_lib PUBLIC gcov)

# Enable coverage in hyprland exe
target_compile_options(Hyprland PRIVATE --coverage)
target_link_options(Hyprland PRIVATE --coverage)
target_link_libraries(Hyprland gcov)
endif()

if(BUILD_TESTING)
Expand All @@ -575,12 +628,8 @@ if(BUILD_TESTING)
enable_testing()
add_custom_target(tests)

add_test(
NAME "Main Test"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/hyprtester
COMMAND hyprtester)
add_dependencies(tests hyprland_gtests)

add_dependencies(tests hyprtester)
else()
message(STATUS "Testing is disabled")
endif()
36 changes: 18 additions & 18 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
# hyprland-packages
hyprland
hyprland-unwrapped
hyprland-with-tests
# hyprland-extras
xdg-desktop-portal-hyprland
;
Expand Down
Loading
Loading