diff --git a/CMakeLists.txt b/CMakeLists.txt index bd0b80a..ac7514d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,69 @@ -cmake_minimum_required(VERSION 3.10.0) -project(hyprland-toggle-tiling VERSION 1.4.1 LANGUAGES C CXX) +cmake_minimum_required(VERSION 3.16) +project(hyprland-toggle-tiling + VERSION 1.4.2 + LANGUAGES CXX +) + +include(GNUInstallDirs) include(FetchContent) -FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.12.0/json.tar.xz) -FetchContent_MakeAvailable(json) + +# -------------------------------------------------- +# Dependency handling +# -------------------------------------------------- + +option(USE_SYSTEM_JSON + "Use system-installed nlohmann_json instead of fetching" + OFF +) + +if(USE_SYSTEM_JSON) + find_package(nlohmann_json CONFIG REQUIRED) +else() + # Try system package first silently + find_package(nlohmann_json CONFIG QUIET) + + if(NOT nlohmann_json_FOUND) + message(STATUS "nlohmann_json not found, fetching from GitHub") + + FetchContent_Declare( + nlohmann_json + URL https://github.com/nlohmann/json/releases/download/v3.12.0/json.tar.xz + ) + + FetchContent_MakeAvailable(nlohmann_json) + else() + message(STATUS "Using system nlohmann_json") + endif() +endif() + +# -------------------------------------------------- +# Executable +# -------------------------------------------------- add_executable(htt - src/main.cpp - src/HyprlandService.cpp - src/Workspace.cpp - src/ShellService.cpp - src/FileService.cpp - src/WindowRule.cpp - src/Client.cpp) -target_link_libraries(htt PRIVATE nlohmann_json::nlohmann_json) -target_include_directories(htt PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + src/main.cpp + src/HyprlandService.cpp + src/Workspace.cpp + src/ShellService.cpp + src/FileService.cpp + src/WindowRule.cpp + src/Client.cpp +) + +target_compile_features(htt PRIVATE cxx_std_17) + +target_link_libraries(htt + PRIVATE + nlohmann_json::nlohmann_json +) + +target_include_directories(htt PRIVATE ${PROJECT_SOURCE_DIR}/src) + +# -------------------------------------------------- +# Install +# -------------------------------------------------- + +install(TARGETS htt + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/include/Macros.hpp b/include/Macros.hpp index 37cf050..9ba8305 100644 --- a/include/Macros.hpp +++ b/include/Macros.hpp @@ -1,9 +1,9 @@ #ifndef MACROS_H #define MACROS_H -#define HYPRCTL_BINARY "/usr/bin/hyprctl" +#define HYPRCTL_BINARY "hyprctl" #define NULL_PATH "/dev/null" -#define ECHO_PATH "/usr/bin/echo" -#define CAT_PATH "/usr/bin/cat" +#define ECHO_PATH "echo" +#define CAT_PATH "cat" -#endif \ No newline at end of file +#endif