Skip to content

Commit 4aaff11

Browse files
committed
Merge #238: cmake, ci: updates for recent nixpkgs
db7acb3 ci: Fix shell.nix compatibility with CMake 4.0 (Ryan Ofsky) 91a7759 cmake: Fix IWYU in nix by adding CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES (Ryan Ofsky) Pull request description: This PR fixes two problems that happen with recent nixpkgs. The first commit works around compilation errors that happen when IWYU is enabled with (`-DMP_ENABLE_IWYU=ON`) that were caused by NixOS/nixpkgs#445095. The second commit fixes problems building old versions of Cap'n Proto with CMake 4.0 in shell.nix. Neither problem has showed up so far running in github actions, only running locally with unstable nixpkgs. More details about the problems and fixes are in the commit messages. ACKs for top commit: sedited: ACK db7acb3 hebasto: re-ACK db7acb3. Tree-SHA512: b56e2c3cdb31de181c5b5ae1ffdb9f978c0c6268bb717e7c1eedf00a8320cf61beda43437e2e2ba37cc9ce335b387902851d3820de434882fc7d6b4a80c5c0e3
2 parents 2ac55a5 + db7acb3 commit 4aaff11

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ if(MP_ENABLE_CLANG_TIDY)
9090
message(FATAL_ERROR "MP_ENABLE_CLANG_TIDY is ON but clang-tidy is not found.")
9191
endif()
9292
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}")
93-
94-
# Workaround for nix from https://gitlab.kitware.com/cmake/cmake/-/issues/20912#note_793338
95-
# Nix injects header paths via $NIX_CFLAGS_COMPILE; CMake tags these as
96-
# CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES and omits them from the compile
97-
# database, so clang-tidy, which ignores $NIX_CFLAGS_COMPILE, can't find capnp
98-
# headers. Setting them as standard passes them to clang-tidy.
99-
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
10093
endif()
10194

10295
option(MP_ENABLE_IWYU "Run include-what-you-use with the compiler." OFF)
@@ -111,6 +104,15 @@ if(MP_ENABLE_IWYU)
111104
endif()
112105
endif()
113106

107+
if(MP_ENABLE_CLANG_TIDY OR MP_ENABLE_IWYU)
108+
# Workaround for nix from https://gitlab.kitware.com/cmake/cmake/-/issues/20912#note_793338
109+
# Nix injects header paths via $NIX_CFLAGS_COMPILE; CMake tags these as
110+
# CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES and omits them from the compile
111+
# database, so clang-tidy, which ignores $NIX_CFLAGS_COMPILE, can't find capnp
112+
# headers. Setting them as standard passes them to clang-tidy.
113+
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
114+
endif()
115+
114116
include("cmake/compat_config.cmake")
115117
include("cmake/pthread_checks.cmake")
116118
include(GNUInstallDirs)

shell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ let
3939
hash = lib.attrByPath [capnprotoVersion] "" capnprotoHashes;
4040
};
4141
patches = lib.optionals (lib.versionAtLeast capnprotoVersion "0.9.0" && lib.versionOlder capnprotoVersion "0.10.4") [ ./ci/patches/spaceship.patch ];
42+
cmakeFlags = (old.cmakeFlags or []) ++ (lib.optionals (lib.versionAtLeast "1.1.0" capnprotoVersion) ["-DCMAKE_POLICY_VERSION_MINIMUM=3.5"]);
4243
} // (lib.optionalAttrs (lib.versionOlder capnprotoVersion "0.10") {
4344
env = { }; # Drop -std=c++20 flag forced by nixpkgs
4445
}));

0 commit comments

Comments
 (0)