about summary refs log tree commit diff
path: root/third_party/nix/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/CMakeLists.txt')
-rw-r--r--third_party/nix/CMakeLists.txt13
1 files changed, 13 insertions, 0 deletions
diff --git a/third_party/nix/CMakeLists.txt b/third_party/nix/CMakeLists.txt
index 71651a9b1168..7591debb133e 100644
--- a/third_party/nix/CMakeLists.txt
+++ b/third_party/nix/CMakeLists.txt
@@ -7,6 +7,9 @@ set(CMAKE_CXX_STANDARD 17)
 # clangd and clang-tidy.
 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 
+# Enable warnings
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
+
 # Provide an output path for pkgconfig.
 include(GNUInstallDirs)
 set(PKGCONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
@@ -25,6 +28,16 @@ find_package(absl REQUIRED)
 find_package(gRPC REQUIRED)
 find_package(glog REQUIRED)
 
+find_program(CLANG_TIDY_PATH clang-tidy)
+if (CLANG_TIDY_PATH)
+  set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
+
+  # nix's toolchain has a problem with system header includes, so clang-tidy requires a manual -isystem
+  if (DEFINED ENV{LIBCXX_INCLUDE})
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem $ENV{LIBCXX_INCLUDE}")
+  endif()
+endif()
+
 # generate a configuration file (autoheader-style) to configure
 # certain symbols that Nix depends on.
 configure_file(config.h.in nix_config.h @ONLY)