### Install Executable Source: https://github.com/hyprwm/hyprland/blob/main/hyprpm/CMakeLists.txt Installs the 'hyprpm' executable to the appropriate system location. ```cmake # binary install(TARGETS hyprpm) ``` -------------------------------- ### Install Executable Source: https://github.com/hyprwm/hyprland/blob/main/hyprctl/CMakeLists.txt Installs the 'hyprctl' executable to the system's default binary directory. ```cmake install(TARGETS hyprctl) ``` -------------------------------- ### Basic Project Setup Source: https://github.com/hyprwm/hyprland/blob/main/hyprpm/CMakeLists.txt Initializes the CMake project with a minimum version and project details. ```cmake cmake_minimum_required(VERSION 3.19) project( hyprpm DESCRIPTION "A Hyprland Plugin Manager" ) ``` -------------------------------- ### Install Shell Completions Source: https://github.com/hyprwm/hyprland/blob/main/hyprpm/CMakeLists.txt Installs shell completion scripts for bash, fish, and zsh. ```cmake # shell completions install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprpm.bash DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions RENAME hyprpm) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprpm.fish DESTINATION ${CMAKE_INSTALL_DATADIR}/fish/vendor_completions.d) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprpm.zsh DESTINATION ${CMAKE_INSTALL_DATADIR}/zsh/site-functions RENAME _hyprpm) ``` -------------------------------- ### Linking and Installation Source: https://github.com/hyprwm/hyprland/blob/main/hyprtester/CMakeLists.txt Links the hyprtester executable against the found dependencies and defines installation rules for the executable, test script, and plugin. ```cmake target_link_libraries(hyprtester PUBLIC PkgConfig::hyprtester_deps) install(TARGETS hyprtester) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/test.lua DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/hypr) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/plugin/hyprtestplugin.so DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/hyprwm/hyprland/blob/main/hyprctl/CMakeLists.txt Initializes the CMake build system, sets the minimum required version, and defines the project name and description. ```cmake cmake_minimum_required(VERSION 3.19) project( hyprctl DESCRIPTION "Control utility for Hyprland" ) ``` -------------------------------- ### Install Shell Completions Source: https://github.com/hyprwm/hyprland/blob/main/hyprctl/CMakeLists.txt Installs shell completion scripts for Bash, Fish, and Zsh to their respective system directories. ```cmake install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprctl.bash DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions RENAME hyprctl) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprctl.fish DESTINATION ${CMAKE_INSTALL_DATADIR}/fish/vendor_completions.d) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hyprctl.zsh DESTINATION ${CMAKE_INSTALL_DATADIR}/zsh/site-functions RENAME _hyprctl) ``` -------------------------------- ### Basic Project Setup Source: https://github.com/hyprwm/hyprland/blob/main/hyprtester/CMakeLists.txt Sets the minimum CMake version, project name, C++ standard, and enables compile command exports. It also finds PkgConfig and checks for hyprutils dependency. ```cmake cmake_minimum_required(VERSION 3.19) project(hyprtester DESCRIPTION "Hyprland test suite") include(GNUInstallDirs) set(CMAKE_CXX_STANDARD 26) set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) find_package(PkgConfig REQUIRED) pkg_check_modules(hyprtester_deps REQUIRED IMPORTED_TARGET hyprutils>=0.5.0) ``` -------------------------------- ### Configure Systemd Support Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Configures Systemd support. If NO_SYSTEMD is not defined, it adds the USES_SYSTEMD definition. It also handles UWSM support and installs the session desktop file. ```cmake if(NO_SYSTEMD) message(STATUS "SYSTEMD support is disabled...") else() message(STATUS "SYSTEMD support is requested (NO_SYSTEMD not defined)...") add_compile_definitions(USES_SYSTEMD) # session file -uwsm if(NO_UWSM) message(STATUS "UWSM support is disabled...") else() message(STATUS "UWSM support is enabled (NO_UWSM not defined)...") install(FILES ${CMAKE_SOURCE_DIR}/systemd/hyprland-uwsm.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/wayland-sessions) endif() endif() ``` -------------------------------- ### Getting Hyprland Version Information Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Retrieve detailed build information for Hyprland, including version, build flags, commit hash, and branch, using the 'version' command. ```bash hyprctl version ``` -------------------------------- ### Getting the Active Hyprland Window Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Retrieve the name of the currently active window using the 'activewindow' command. ```bash hyprctl activewindow ``` -------------------------------- ### Getting the Hyprland Splash Screen Text Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Retrieve the current random splash screen text with the 'splash' command. ```bash hyprctl splash ``` -------------------------------- ### Getting Hyprland Status Information Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Obtain internal status information about Hyprland, such as its configuration format and backend, using the 'status' command. ```bash hyprctl status ``` -------------------------------- ### Get Hyprland Log (TTY) Source: https://github.com/hyprwm/hyprland/blob/main/docs/ISSUE_GUIDELINES.md Retrieves the Hyprland log from the last session when running in a TTY. The log is essential for non-crashing bugs. ```bash cat $XDG_RUNTIME_DIR/hypr/$(ls -t $XDG_RUNTIME_DIR/hypr | head -n 1)/hyprland.log ``` -------------------------------- ### Get Hyprland Log (Hyprland Session) Source: https://github.com/hyprwm/hyprland/blob/main/docs/ISSUE_GUIDELINES.md Retrieves the Hyprland log from the previous session when already running within a Hyprland session. This is useful for diagnosing issues without a full crash. ```bash cat $XDG_RUNTIME_DIR/hypr/$(ls -t $XDG_RUNTIME_DIR/hypr | head -n 2 | tail -n 1)/hyprland.log ``` -------------------------------- ### Get coredump info Source: https://github.com/hyprwm/hyprland/blob/main/docs/ISSUE_GUIDELINES.md Retrieves detailed information about a specific coredump using its Process ID (PID). This is crucial for analyzing crashes in older Hyprland versions. ```bash coredumpctl info [PID] ``` -------------------------------- ### Execute Git Commands to Get Repository Info Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Executes Git commands to retrieve repository details like the top-level directory, commit hash, branch, message, date, dirty status, tags, and commit count. This is done only if Git is found and a repository is detected. ```cmake if(Git_FOUND) execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE GIT_TOPLEVEL OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET RESULT_VARIABLE GIT_TOPLEVEL_RESULT ) if(GIT_TOPLEVEL_RESULT EQUAL 0) message(STATUS "Detected git repository root: ${GIT_TOPLEVEL}") execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD WORKING_DIRECTORY ${GIT_TOPLEVEL} OUTPUT_VARIABLE GIT_COMMIT_HASH OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${GIT_EXECUTABLE} branch --show-current WORKING_DIRECTORY ${GIT_TOPLEVEL} OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND sh "-c" "${GIT_EXECUTABLE} show -s --format=%s --no-show-signature | sed \"s/\\\"/\'/g\"" WORKING_DIRECTORY ${GIT_TOPLEVEL} OUTPUT_VARIABLE GIT_COMMIT_MESSAGE OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${GIT_EXECUTABLE} show -s --format=%cd --date=local --no-show-signature WORKING_DIRECTORY ${GIT_TOPLEVEL} OUTPUT_VARIABLE GIT_COMMIT_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --quiet HEAD -- WORKING_DIRECTORY ${GIT_TOPLEVEL} RESULT_VARIABLE GIT_DIRTY_RESULT) if(NOT GIT_DIRTY_RESULT EQUAL 0) set(GIT_DIRTY "dirty") else() set(GIT_DIRTY "clean") endif() execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags WORKING_DIRECTORY ${GIT_TOPLEVEL} OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD WORKING_DIRECTORY ${GIT_TOPLEVEL} OUTPUT_VARIABLE GIT_COMMITS OUTPUT_STRIP_TRAILING_WHITESPACE) else() message(WARNING "No Git repository detected in ${CMAKE_SOURCE_DIR}") endif() endif() ``` -------------------------------- ### Listing Hyprland Clients (Windows) Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Obtain a list of all currently open windows (clients) and their properties using the 'clients' command. ```bash hyprctl clients ``` -------------------------------- ### Protocol and Client Instantiation Source: https://github.com/hyprwm/hyprland/blob/main/hyprtester/CMakeLists.txt Instantiates the protocol generation and client creation functions for various Wayland protocols and client applications. ```cmake protocolnew("staging/pointer-warp" "pointer-warp-v1" false) protocolnew("stable/xdg-shell" "xdg-shell" false) protocolnew("unstable/keyboard-shortcuts-inhibit" "keyboard-shortcuts-inhibit-unstable-v1" false) clientNew("pointer-warp" PROTOS "pointer-warp-v1" "xdg-shell") clientNew("pointer-scroll" PROTOS "xdg-shell") clientNew("child-window" PROTOS "xdg-shell") clientNew("shortcut-inhibitor" PROTOS "xdg-shell" "keyboard-shortcuts-inhibit-unstable-v1") clientNew("keyboard-modifiers" PROTOS "xdg-shell") ``` -------------------------------- ### Launch Hyprland with ASAN Debugging Source: https://github.com/hyprwm/hyprland/blob/main/docs/ISSUE_GUIDELINES.md Launches Hyprland from a TTY with AddressSanitizer (ASAN) enabled for debugging. This generates a detailed log file upon crashing. ```bash ASAN_OPTIONS="log_path=asan.log" ~/path/to/Hyprland ``` -------------------------------- ### Listing Hyprland Workspaces Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst View all available workspaces and their associated properties by executing the 'workspaces' command. ```bash hyprctl workspaces ``` -------------------------------- ### Source File Discovery Source: https://github.com/hyprwm/hyprland/blob/main/hyprpm/CMakeLists.txt Globally finds all .cpp source files in the src directory for the build. ```cmake file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") ``` -------------------------------- ### Client Executable Creation Function Source: https://github.com/hyprwm/hyprland/blob/main/hyprtester/CMakeLists.txt Defines a function to create client executables, linking them against protocol dependencies and adding generated protocol sources. ```cmake function(clientNew sourceName) cmake_parse_arguments(PARSE_ARGV 1 ARG "" "" "PROTOS") add_executable(${sourceName} clients/${sourceName}.cpp) target_include_directories(${sourceName} BEFORE PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/protocols") target_link_libraries(${sourceName} PUBLIC PkgConfig::protocols_deps) target_sources(${sourceName} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/protocols/wayland.cpp ${CMAKE_CURRENT_SOURCE_DIR}/protocols/wayland.hpp) foreach(protoName IN LISTS ARG_PROTOS) target_sources(${sourceName} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/protocols/${protoName}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/protocols/${protoName}.hpp) endforeach() endfunction() ``` -------------------------------- ### Check for execinfo.h and Link libexecinfo Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Checks if the execinfo.h header is available and adds the HAS_EXECINFO definition. If libexecinfo is found, it's linked to the hyprland_lib target. ```cmake check_include_file("execinfo.h" EXECINFOH) if(EXECINFOH) message(STATUS "Configuration supports execinfo") add_compile_definitions(HAS_EXECINFO) endif() include(CheckLibraryExists) check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO) if(HAVE_LIBEXECINFO) target_link_libraries(hyprland_lib PUBLIC execinfo) endif() ``` -------------------------------- ### Listing Hyprland Input Devices Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst The 'devices' command provides information about all connected input devices recognized by Hyprland. ```bash hyprctl devices ``` -------------------------------- ### Executable and Plugin Build Command Source: https://github.com/hyprwm/hyprland/blob/main/hyprtester/CMakeLists.txt Defines the source files for the hyprtester executable and adds a custom post-build command to execute a plugin build script. ```cmake file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") add_executable(hyprtester ${SRCFILES}) add_custom_command( TARGET hyprtester POST_BUILD COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/plugin/build.sh "${LUA_INCLUDE_DIRS}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/plugin) ``` -------------------------------- ### Linking Libraries Source: https://github.com/hyprwm/hyprland/blob/main/hyprpm/CMakeLists.txt Links the 'hyprpm' executable against its dependencies, including PkgConfig modules and Glaze. ```cmake target_link_libraries(hyprpm PUBLIC PkgConfig::hyprpm_deps glaze::glaze) ``` -------------------------------- ### Listing Hyprland Monitors Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst The 'monitors' command displays a list of all connected outputs (monitors) along with their specific properties. ```bash hyprctl monitors ``` -------------------------------- ### Check for sys/inotify.h and Link libinotify Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Checks for sys/inotify.h. If not found but libinotify is available via pkg-config, it links it to hyprland_lib. ```cmake 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_lib PUBLIC PkgConfig::inotify) endif() ``` -------------------------------- ### Link Main Executable and Libraries Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Links the main Hyprland executable with the ${LIBRT} and hyprland_lib. ```cmake target_link_libraries( Hyprland ${LIBRT} hyprland_lib) ``` -------------------------------- ### Instantiate Hyprwire Protocol Generation Source: https://github.com/hyprwm/hyprland/blob/main/hyprctl/CMakeLists.txt Calls the 'hyprprotocol' function to generate code for the 'hyprpaper_core' protocol. ```cmake hyprprotocol(hw-protocols hyprpaper_core) ``` -------------------------------- ### Entering Hyprland Kill Mode Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Activate 'kill mode' with the 'kill' command, allowing you to terminate applications by clicking on their windows. Press ESCAPE to exit kill mode. ```bash hyprctl kill ``` -------------------------------- ### Enable Tracy GPU Profiling Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Enables Tracy GPU profiling by defining USE_TRACY_GPU if the build environment supports it. ```cmake message(STATUS "Tracy GPU Profiling is turned on") add_compile_definitions(USE_TRACY_GPU) ``` -------------------------------- ### Configure Version Header File Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Configures the version.h file from a template using CMake's configure_file command. This allows build-time information to be embedded into the source code. ```cmake configure_file( ${CMAKE_SOURCE_DIR}/src/version.h.in ${CMAKE_SOURCE_DIR}/src/version.h @ONLY ) set_source_files_properties(${CMAKE_SOURCE_DIR}/src/version.h PROPERTIES GENERATED TRUE) ``` -------------------------------- ### Configure XWayland Dependencies Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Configures XWayland support. If NO_XWAYLAND is not defined, it checks for required XCB libraries and links them to hyprland_lib. ```cmake if(NO_XWAYLAND) message(STATUS "Using the NO_XWAYLAND flag, disabling XWayland!") add_compile_definitions(NO_XWAYLAND) else() message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...") set(XWAYLAND_DEPENDENCIES xcb xcb-render xcb-xfixes xcb-icccm xcb-composite xcb-res xcb-errors) pkg_check_modules( xdeps REQUIRED IMPORTED_TARGET ${XWAYLAND_DEPENDENCIES}) string(JOIN ", " PKGCONFIG_XWAYLAND_DEPENDENCIES ${XWAYLAND_DEPENDENCIES}) string(PREPEND PKGCONFIG_XWAYLAND_DEPENDENCIES ", ") target_link_libraries(hyprland_lib PUBLIC PkgConfig::xdeps) endif() ``` -------------------------------- ### Wayland Protocol Dependencies Source: https://github.com/hyprwm/hyprland/blob/main/hyprtester/CMakeLists.txt Finds the hyprwayland-scanner and checks for necessary protocol dependencies including hyprutils, wayland-client, and wayland-protocols. ```cmake find_package(hyprwayland-scanner 0.4.0 REQUIRED) pkg_check_modules( protocols_deps REQUIRED IMPORTED_TARGET hyprutils>=0.8.0 wayland-client wayland-protocols>=1.47 ) ``` -------------------------------- ### Dependency Check and Fetch Source: https://github.com/hyprwm/hyprland/blob/main/hyprpm/CMakeLists.txt Checks for required modules like tomlplusplus and hyprutils, and conditionally fetches Glaze if not found. ```cmake pkg_check_modules(hyprpm_deps REQUIRED IMPORTED_TARGET tomlplusplus hyprutils>=0.7.0) find_package(glaze 7...<8 QUIET) if (NOT glaze_FOUND) set(GLAZE_VERSION v7.2.0) message(STATUS "hyprpm: glaze dependency not found, retrieving ${GLAZE_VERSION} with FetchContent") include(FetchContent) FetchContent_Declare( glaze GIT_REPOSITORY https://github.com/stephenberry/glaze.git GIT_TAG ${GLAZE_VERSION} GIT_SHALLOW TRUE EXCLUDE_FROM_ALL ) FetchContent_MakeAvailable(glaze) endif() ``` -------------------------------- ### Dependency Check with pkg-config Source: https://github.com/hyprwm/hyprland/blob/main/hyprctl/CMakeLists.txt Checks for required modules (hyprutils, hyprwire, re2) using pkg-config, ensuring necessary libraries are available. ```cmake pkg_check_modules(hyprctl_deps REQUIRED IMPORTED_TARGET hyprutils>=0.2.4 hyprwire re2) ``` -------------------------------- ### Find Required Dependencies Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Locates and checks for the presence of essential libraries like Threads, OpenGL, and glslang. ```cmake find_package(Threads REQUIRED) set(GLES_VERSION "GLES3") find_package(OpenGL REQUIRED COMPONENTS ${GLES_VERSION}) find_package(glslang CONFIG REQUIRED) ``` -------------------------------- ### Listing Hyprland Layers Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Display a list of all active layers within the Hyprland compositor using the 'layers' command. ```bash hyprctl layers ``` -------------------------------- ### Setting Hyprland Keywords Dynamically Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst The 'keyword' command allows dynamic modification of Hyprland configuration settings. Note that this may not function with Lua-based configurations. ```bash hyprctl keyword bind SUPER,0,pseudo ``` ```bash hyprctl keyword general:border_size 10 ``` -------------------------------- ### Dispatching Hyprland Commands Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Use the 'dispatch' command to call Hyprland's internal dispatchers with arguments. This is useful for executing actions like opening applications or closing windows. ```bash hyprctl dispatch "hl.dsp.exec_cmd('kitty')" ``` ```bash hyprctl dispatch "hl.dsp.window.close()" ``` -------------------------------- ### Check for Aquamarine and Hyprland Dependencies Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Uses pkg-config to check for required versions of Aquamarine and various Hyprland libraries. ```cmake set(AQUAMARINE_MINIMUM_VERSION 0.9.3) set(HYPRLANG_MINIMUM_VERSION 0.6.7) set(HYPRCURSOR_MINIMUM_VERSION 0.1.7) set(HYPRUTILS_MINIMUM_VERSION 0.13.1) set(HYPRGRAPHICS_MINIMUM_VERSION 0.5.1) pkg_check_modules(aquamarine_dep REQUIRED IMPORTED_TARGET aquamarine>=${AQUAMARINE_MINIMUM_VERSION}) pkg_check_modules(hyprlang_dep REQUIRED IMPORTED_TARGET hyprlang>=${HYPRLANG_MINIMUM_VERSION}) pkg_check_modules(hyprcursor_dep REQUIRED IMPORTED_TARGET hyprcursor>=${HYPRCURSOR_MINIMUM_VERSION}) pkg_check_modules(hyprutils_dep REQUIRED IMPORTED_TARGET hyprutils>=${HYPRUTILS_MINIMUM_VERSION}) pkg_check_modules(hyprgraphics_dep REQUIRED IMPORTED_TARGET hyprgraphics>=${HYPRGRAPHICS_MINIMUM_VERSION}) ``` -------------------------------- ### Glob Source Files and Define Executable Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Finds all .cpp files in the src directory, excluding main.cpp, and defines the main executable 'Hyprland'. It also handles the inclusion of Tracy client source files if Tracy is enabled. ```cmake 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_library(hyprland_lib STATIC ${SRCFILES}) add_executable(Hyprland src/main.cpp ${TRACY_CPP_FILES}) target_link_libraries(Hyprland hyprland_lib) ``` -------------------------------- ### Enable Tracy Profiler Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Enables the Tracy profiler by setting options, adding the Tracy subdirectory, and linking the Tracy client library. It also sets a compile option to omit frame pointers for better profiling. ```cmake if(USE_TRACY) message(STATUS "Tracy is turned on") option(TRACY_ENABLE "" ON) option(TRACY_ON_DEMAND "" ON) add_subdirectory(subprojects/tracy) add_compile_options(-fno-omit-frame-pointer) target_link_libraries(hyprland_lib PUBLIC Tracy::TracyClient) if(USE_TRACY_GPU) ``` -------------------------------- ### Set Include Directories Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Sets the public include directories for the hyprland_lib and Hyprland targets, including dependency include paths and Lua include paths. ```cmake target_include_directories(hyprland_lib PUBLIC ${deps_INCLUDE_DIRS} ${LUA_INCLUDE_DIRS}) target_include_directories(Hyprland PUBLIC ${deps_INCLUDE_DIRS} ${LUA_INCLUDE_DIRS}) ``` -------------------------------- ### Executing Batch Commands in Hyprctl Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Use the '--batch' option to execute a sequence of hyprctl commands. Commands within the batch should be separated by semicolons. ```bash hyprctl --batch "keyword general:border_size 2 ; keyword general:gaps_out 20" ``` -------------------------------- ### Evaluating Lua Expressions in Hyprland Config Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst For Lua-based Hyprland configurations, use the 'eval' command to dynamically execute Lua expressions. This enables advanced configuration and binding management. ```bash hyprctl eval 'hl.bind("SUPER + SHIFT + Q", hl.dsp.exec_cmd("firefox"))' ``` ```bash hyprctl eval 'hl.config({ general = { border_size = 10 } })' ``` -------------------------------- ### Compile Hyprland with Debug Mode Source: https://github.com/hyprwm/hyprland/blob/main/docs/ISSUE_GUIDELINES.md Instructions for compiling Hyprland with debug mode enabled, which is necessary for obtaining debug coredumps. This process may use a different configuration file. ```bash git pull --recurse-submodules ``` -------------------------------- ### Executable Target Definition Source: https://github.com/hyprwm/hyprland/blob/main/hyprpm/CMakeLists.txt Defines the main executable target 'hyprpm' using the discovered source files. ```cmake add_executable(hyprpm ${SRCFILES}) ``` -------------------------------- ### Check for Required Modules using pkg-config Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Checks for the presence and minimum versions of several required libraries using pkg-config. This ensures all necessary dependencies are met before building. ```cmake set(XKBCOMMON_MINIMUM_VERSION 1.11.0) set(WAYLAND_SERVER_MINIMUM_VERSION 1.22.91) set(WAYLAND_SERVER_PROTOCOLS_MINIMUM_VERSION 1.47) set(LIBINPUT_MINIMUM_VERSION 1.29) pkg_check_modules( deps REQUIRED IMPORTED_TARGET GLOBAL xkbcommon>=${XKBCOMMON_MINIMUM_VERSION} uuid wayland-server>=${WAYLAND_SERVER_MINIMUM_VERSION} wayland-protocols>=${WAYLAND_SERVER_PROTOCOLS_MINIMUM_VERSION} cairo pango pangocairo pixman-1 xcursor libdrm libinput>=${LIBINPUT_MINIMUM_VERSION} gbm gio-2.0 re2 muparser lcms2 ) pkg_search_module(LUA REQUIRED IMPORTED_TARGET GLOBAL lua55 lua5.5 lua-55 lua-5.5 lua>=5.5 lua<5.6) find_package(hyprwayland-scanner 0.3.10 REQUIRED) ``` -------------------------------- ### Configure Debug Build Options Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Sets specific compile and link options for Debug builds, including enabling AddressSanitizer (ASan) if WITH_ASAN is set, and disabling PIE and built-in optimizations. ```cmake set(USE_GPROF OFF) if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) message(STATUS "Setting debug flags") if(WITH_ASAN) message(STATUS "Enabling ASan") target_link_libraries(hyprland_lib PUBLIC asan) target_compile_options(hyprland_lib PUBLIC -fsanitize=address) endif() add_compile_options(-fno-pie -fno-builtin -fno-omit-frame-pointer) add_link_options(-no-pie -fno-builtin) if(USE_GPROF) add_compile_options(-pg) add_link_options(-pg) endif() endif() ``` -------------------------------- ### Link Udis Dependencies Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Links Udis dependencies to hyprland_lib, prioritizing pkg-config, then a direct path, and finally falling back to libudis86. ```cmake if(udis_dep_FOUND) target_link_libraries(hyprland_lib PUBLIC PkgConfig::udis_dep) elseif(NOT("${udis_nopc}" MATCHES "udis_nopc-NOTFOUND")) target_link_libraries(hyprland_lib PUBLIC ${udis_nopc}) else() target_link_libraries(hyprland_lib PUBLIC libudis86) endif() ``` -------------------------------- ### Executable Target Definition Source: https://github.com/hyprwm/hyprland/blob/main/hyprctl/CMakeLists.txt Defines the 'hyprctl' executable and links it against the discovered source files and required libraries. ```cmake add_executable(hyprctl ${HYPRCTL_SRCFILES}) target_link_libraries(hyprctl PUBLIC PkgConfig::hyprctl_deps) target_include_directories(hyprctl PRIVATE "hw-protocols") ``` -------------------------------- ### Find Git Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Optionally finds the Git executable, useful for retrieving version information during the build. ```cmake find_package(Git QUIET) ``` -------------------------------- ### Writing Build Directory to Header Source: https://github.com/hyprwm/hyprland/blob/main/hyprtester/CMakeLists.txt Writes the current binary directory path to a C++ header file, making it accessible within the compiled code. ```cmake file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/src/tests/clients/build.hpp "#include \n" "static const std::string binaryDir = \"${CMAKE_CURRENT_BINARY_DIR}\";" ) ``` -------------------------------- ### Check for sys/timerfd.h and Link epoll-shim Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Checks for sys/timerfd.h. If not found but epoll is available via pkg-config, it links the epoll shim to hyprland_lib. ```cmake 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_lib PUBLIC PkgConfig::epoll) endif() ``` -------------------------------- ### Enable Executable Exports and Compile Commands Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Sets CMake variables to enable exporting executables and generating compile_commands.json. ```cmake set(CMAKE_EXECUTABLE_ENABLE_EXPORTS TRUE) set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) ``` -------------------------------- ### Access coredumpctl (Systemd) Source: https://github.com/hyprwm/hyprland/blob/main/docs/ISSUE_GUIDELINES.md Used on systemd systems to list all coredumps. This helps identify the PID of a crashed Hyprland process for further analysis. ```bash coredumpctl ``` -------------------------------- ### Define Wayland Protocol (Wayland) Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Calls the Wayland protocol definition function. This is a general call for Wayland protocol integration. ```cmake protocolwayland() ``` -------------------------------- ### Wayland Protocol Generation Source: https://github.com/hyprwm/hyprland/blob/main/hyprtester/CMakeLists.txt Generates core Wayland protocol C++ and header files using hyprwayland-scanner. ```cmake # gen core wayland stuff add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/protocols/wayland.cpp ${CMAKE_CURRENT_SOURCE_DIR}/protocols/wayland.hpp COMMAND hyprwayland-scanner --wayland-enums --client ${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_CURRENT_SOURCE_DIR}/protocols/ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) ``` -------------------------------- ### Define BUILT_WITH_NIX Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Adds the BUILT_WITH_NIX compile definition if the project is built with Nix. ```cmake if(BUILT_WITH_NIX) add_compile_definitions(BUILT_WITH_NIX) endif() ``` -------------------------------- ### C++ Standard Setting Source: https://github.com/hyprwm/hyprland/blob/main/hyprpm/CMakeLists.txt Sets the C++ standard to C++23 for the project. ```cmake set(CMAKE_CXX_STANDARD 23) ``` -------------------------------- ### Source File Discovery Source: https://github.com/hyprwm/hyprland/blob/main/hyprctl/CMakeLists.txt Uses file(GLOB_RECURSE) to find all C++ source files and header files within the 'src', 'hw-protocols', and 'include' directories. ```cmake file(GLOB_RECURSE HYPRCTL_SRCFILES CONFIGURE_DEPENDS "src/*.cpp" "hw-protocols/*.cpp" "include/*.hpp") ``` -------------------------------- ### Link Core Libraries to hyprland_lib Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Links essential libraries including aquamarine, hyprlang, hyprutils, hyprcursor, hyprgraphics, deps, and LUA to the hyprland_lib target. ```cmake message(STATUS "Setting link libraries") target_link_libraries( hyprland_lib PUBLIC PkgConfig::aquamarine_dep PkgConfig::hyprlang_dep PkgConfig::hyprutils_dep PkgConfig::hyprcursor_dep PkgConfig::hyprgraphics_dep PkgConfig::deps PkgConfig::LUA ) ``` -------------------------------- ### Reloading Hyprland Configuration Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Force Hyprland to reload its configuration file using the 'reload' command. This applies any changes made to the configuration files. ```bash hyprctl reload ``` -------------------------------- ### Configure Precompiled Headers Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Configures the use of precompiled headers for the hyprland_lib target, unless CMAKE_DISABLE_PRECOMPILE_HEADERS is set. ```cmake if(CMAKE_DISABLE_PRECOMPILE_HEADERS) message(STATUS "Not using precompiled headers") else() message(STATUS "Setting precompiled headers") target_precompile_headers(hyprland_lib PRIVATE $<$:src/pch/pch.hpp>) endif() ``` -------------------------------- ### Extract and Set Version Variables Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Parses version strings from dependency checks and sets them as CMake variables for use in the build. ```cmake string(REPLACE "." ";" AQ_VERSION_LIST ${aquamarine_dep_VERSION}) list(GET AQ_VERSION_LIST 0 AQ_VERSION_MAJOR) list(GET AQ_VERSION_LIST 1 AQ_VERSION_MINOR) list(GET AQ_VERSION_LIST 2 AQ_VERSION_PATCH) set(AQUAMARINE_VERSION "${aquamarine_dep_VERSION}") set(AQUAMARINE_VERSION_MAJOR "${AQ_VERSION_MAJOR}") set(AQUAMARINE_VERSION_MINOR "${AQ_VERSION_MINOR}") set(AQUAMARINE_VERSION_PATCH "${AQ_VERSION_PATCH}") set(HYPRLANG_VERSION "${hyprlang_dep_VERSION}") set(HYPRUTILS_VERSION "${hyprutils_dep_VERSION}") set(HYPRCURSOR_VERSION "${hyprcursor_dep_VERSION}") set(HYPRGRAPHICS_VERSION "${hyprgraphics_dep_VERSION}") ``` -------------------------------- ### Outputting Hyprctl Information in JSON Source: https://github.com/hyprwm/hyprland/blob/main/docs/hyprctl.1.rst Append the '-j' flag to hyprctl commands to receive their output formatted as JSON, which is useful for scripting and programmatic parsing. ```bash hyprctl -j version ``` -------------------------------- ### Populate Git Variables from Environment Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Sets Git-related variables using environment variables if they are present. If an environment variable is not found, a default value is assigned. ```cmake set(GIT_COMMIT_HASH "$ENV{GIT_COMMIT_HASH}") if(NOT GIT_COMMIT_HASH) set(GIT_COMMIT_HASH "unknown") endif() set(GIT_BRANCH "$ENV{GIT_BRANCH}") if(NOT GIT_BRANCH) set(GIT_BRANCH "unknown") endif() set(GIT_COMMIT_MESSAGE "$ENV{GIT_COMMIT_MESSAGE}") if(NOT GIT_COMMIT_MESSAGE) set(GIT_COMMIT_MESSAGE "unknown") endif() set(GIT_COMMIT_DATE "$ENV{GIT_COMMIT_DATE}") if(NOT GIT_COMMIT_DATE) set(GIT_COMMIT_DATE "unknown") endif() set(GIT_DIRTY "$ENV{GIT_DIRTY}") if(NOT GIT_DIRTY) set(GIT_DIRTY "unknown") endif() set(GIT_TAG "$ENV{GIT_TAG}") if(NOT GIT_TAG) set(GIT_TAG "unknown") endif() set(GIT_COMMITS "$ENV{GIT_COMMITS}") if(NOT GIT_COMMITS) set(GIT_COMMITS "0") endif() ``` -------------------------------- ### Hyprwire Protocol Generation Function Source: https://github.com/hyprwm/hyprland/blob/main/hyprctl/CMakeLists.txt Defines a CMake function to generate client-side code for Hyprwire protocols using the 'hyprwire-scanner'. ```cmake function(hyprprotocol protoPath protoName) set(path ${CMAKE_CURRENT_SOURCE_DIR}/${protoPath}) add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-client.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-client.hpp ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/${protoName}-spec.hpp COMMAND hyprwire-scanner --client ${path}/${protoName}.xml ${CMAKE_CURRENT_SOURCE_DIR}/hw-protocols/ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) target_sources(hyprctl PRIVATE hw-protocols/${protoName}-client.cpp hw-protocols/${protoName}-client.hpp hw-protocols/${protoName}-spec.hpp) endfunction() ``` -------------------------------- ### Custom Protocol Generation Function Source: https://github.com/hyprwm/hyprland/blob/main/hyprtester/CMakeLists.txt Defines a function to generate C++ and header files for custom Wayland protocols using hyprwayland-scanner. ```cmake function(protocolNew protoPath protoName external) if(external) set(path ${CMAKE_CURRENT_SOURCE_DIR}/${protoPath}) else() set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath}) endif() add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/protocols/${protoName}.cpp ${CMAKE_CURRENT_SOURCE_DIR}/protocols/${protoName}.hpp COMMAND hyprwayland-scanner --client ${path}/${protoName}.xml ${CMAKE_CURRENT_SOURCE_DIR}/protocols/ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) endfunction() ``` -------------------------------- ### Define Wayland Protocol Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Defines a new Wayland protocol, specifying its name, interface, and whether it's a stable version. Used for integrating various Wayland extensions. ```cmake protocolnew("unstable/xdg-output" "xdg-output-unstable-v1" false) protocolnew("staging/cursor-shape" "cursor-shape-v1" false) protocolnew("unstable/idle-inhibit" "idle-inhibit-unstable-v1" false) protocolnew("unstable/relative-pointer" "relative-pointer-unstable-v1" false) protocolnew("unstable/xdg-decoration" "xdg-decoration-unstable-v1" false) protocolnew("staging/alpha-modifier" "alpha-modifier-v1" false) protocolnew("staging/ext-foreign-toplevel-list" "ext-foreign-toplevel-list-v1" false) protocolnew("unstable/pointer-gestures" "pointer-gestures-unstable-v1" false) protocolnew("unstable/keyboard-shortcuts-inhibit" "keyboard-shortcuts-inhibit-unstable-v1" false) protocolnew("unstable/text-input" "text-input-unstable-v3" false) protocolnew("unstable/pointer-constraints" "pointer-constraints-unstable-v1" false) protocolnew("unstable/xdg-foreign" "xdg-foreign-unstable-v2" false) protocolnew("staging/xdg-activation" "xdg-activation-v1" false) protocolnew("staging/ext-idle-notify" "ext-idle-notify-v1" false) protocolnew("staging/ext-session-lock" "ext-session-lock-v1" false) protocolnew("stable/tablet" "tablet-v2" false) protocolnew("stable/presentation-time" "presentation-time" false) protocolnew("stable/xdg-shell" "xdg-shell" false) protocolnew("unstable/primary-selection" "primary-selection-unstable-v1" false) protocolnew("staging/xwayland-shell" "xwayland-shell-v1" false) protocolnew("stable/viewporter" "viewporter" false) protocolnew("stable/linux-dmabuf" "linux-dmabuf-v1" false) protocolnew("staging/drm-lease" "drm-lease-v1" false) protocolnew("staging/linux-drm-syncobj" "linux-drm-syncobj-v1" false) protocolnew("staging/xdg-dialog" "xdg-dialog-v1" false) protocolnew("staging/single-pixel-buffer" "single-pixel-buffer-v1" false) protocolnew("staging/security-context" "security-context-v1" false) protocolnew("staging/content-type" "content-type-v1" false) protocolnew("staging/color-management" "color-management-v1" false) protocolnew("staging/xdg-toplevel-tag" "xdg-toplevel-tag-v1" false) protocolnew("staging/xdg-system-bell" "xdg-system-bell-v1" false) protocolnew("staging/ext-workspace" "ext-workspace-v1" false) protocolnew("staging/ext-data-control" "ext-data-control-v1" false) protocolnew("staging/pointer-warp" "pointer-warp-v1" false) protocolnew("staging/fifo" "fifo-v1" false) protocolnew("staging/commit-timing" "commit-timing-v1" false) protocolnew("staging/ext-image-capture-source" "ext-image-capture-source-v1" false) protocolnew("staging/ext-image-copy-capture" "ext-image-copy-capture-v1" false) protocolnew("staging/ext-background-effect" "ext-background-effect-v1" false) ``` -------------------------------- ### Build Type Specific Configuration Source: https://github.com/hyprwm/hyprland/blob/main/hyprtester/CMakeLists.txt Enables executable exports specifically for Debug or DEBUG build types. ```cmake if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) set(CMAKE_EXECUTABLE_ENABLE_EXPORTS TRUE) endif() ``` -------------------------------- ### Disable LTO for Plugins Source: https://github.com/hyprwm/hyprland/blob/main/CMakeLists.txt Disables Link-Time Optimization (LTO) to prevent potential issues with plugins. ```cmake add_compile_options(-fno-lto) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.