Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix: revert to using CMake, drop ninja #7784

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,13 @@ set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

message(STATUS "Setting precompiled headers")

target_precompile_headers(Hyprland PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:src/pch/pch.hpp>)
if(CMAKE_DISABLE_PRECOMPILE_HEADERS)
message(STATUS "Not using precompiled headers")
else()
message(STATUS "Setting precompiled headers")
target_precompile_headers(Hyprland PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:src/pch/pch.hpp>)
endif()

message(STATUS "Setting link libraries")

Expand Down
10 changes: 10 additions & 0 deletions nix/cmake-version.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6fdf98db..d8424d91 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.30)
+cmake_minimum_required(VERSION 3.27)

# Get version
file(READ "${CMAKE_SOURCE_DIR}/VERSION" VER_RAW)
34 changes: 18 additions & 16 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
pkg-config,
pkgconf,
makeWrapper,
meson,
cmake,
ninja,
aquamarine,
binutils,
cairo,
Expand Down Expand Up @@ -53,7 +51,7 @@
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.lists) flatten concatLists optional optionals;
inherit (lib.sources) cleanSourceWith cleanSource;
inherit (lib.strings) hasSuffix makeBinPath optionalString mesonBool mesonEnable;
inherit (lib.strings) cmakeBool hasSuffix makeBinPath optionalString;

adapters = flatten [
stdenvAdapters.useMoldLinker
Expand All @@ -76,6 +74,14 @@ in
src = cleanSource ../.;
};

patches = [
# forces GCC to use -std=c++26
./stdcxx.patch

# Nix does not have CMake 3.30 yet, so override the minimum version
./cmake-version.patch
];

postPatch = ''
# Fix hardcoded paths to /usr installation
sed -i "s#/usr#$out#" src/render/OpenGL.cpp
Expand All @@ -97,9 +103,7 @@ in
hyprwayland-scanner
jq
makeWrapper
meson
cmake
ninja
pkg-config
python3 # for udis86
wayland-scanner
Expand Down Expand Up @@ -144,22 +148,20 @@ in
(optional withSystemd systemd)
];

mesonBuildType =
cmakeBuildType =
if debug
then "debug"
else "release";
then "Debug"
else "RelWithDebInfo";

# we want as much debug info as possible
dontStrip = debug;

mesonFlags = flatten [
(mapAttrsToList mesonEnable {
"xwayland" = enableXWayland;
"legacy_renderer" = legacyRenderer;
"systemd" = withSystemd;
})
(mesonBool "b_pch" false)
];
cmakeFlags = mapAttrsToList cmakeBool {
"NO_XWAYLAND" = !enableXWayland;
"LEGACY_RENDERER" = legacyRenderer;
"NO_SYSTEMD" = !withSystemd;
"CMAKE_DISABLE_PRECOMPILE_HEADERS" = true;
};

postInstall = ''
${optionalString wrapRuntimeDeps ''
Expand Down
12 changes: 12 additions & 0 deletions nix/stdcxx.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cfbd431f..73e8e0c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,6 +64,7 @@ endif()
include_directories(. "src/" "subprojects/udis86/" "protocols/")
set(CMAKE_CXX_STANDARD 26)
add_compile_options(
+ -std=c++26
-Wall
-Wextra
-Wno-unused-parameter
Loading