f4f72bcf21
Configures the CMake build to load & run the GoogleTest tests. I (grfn) also updated this to get the tests running as part of the nix derivation, which required defining our own manual configurePhase and installCheckPhase, rather than depending on the one provided by stdenv. Not doing this would cause cmake to attempt to *run* the tests as part of the buildPhase, which wouldn't work because the dynamic libraries hadn't been put into a place where the test executables knew where to find them. We're not sure *why* this fixes it, and for some reason fixing this also breaks the automatic behavior of nixpkgs of passing -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES to make, but that's eaasy enough to fix manually in a preBuild Paired-With: Griffin Smith <grfn@gws.fyi> Change-Id: I79d61854a3ff47301cdce8a40c76820a97bdf901 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1240 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
49 lines
1.5 KiB
CMake
49 lines
1.5 KiB
CMake
# -*- mode: cmake; -*-
|
|
cmake_minimum_required(VERSION 3.16)
|
|
project(nix CXX)
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
# Export compile_commands.json which can be used by tools such as
|
|
# clangd and clang-tidy.
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
# Provide an output path for pkgconfig.
|
|
include(GNUInstallDirs)
|
|
set(PKGCONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
|
|
|
# The following lines import CMake-native dependencies which may
|
|
# contain useful definitions. Other dependencies are not treated
|
|
# specially by CMake and are only linked into the resulting binary.
|
|
find_package(BZip2)
|
|
find_package(Boost COMPONENTS context)
|
|
find_package(CURL)
|
|
find_package(LibLZMA)
|
|
find_package(Protobuf REQUIRED)
|
|
find_package(SQLite3)
|
|
find_package(Threads)
|
|
find_package(absl REQUIRED)
|
|
find_package(gRPC REQUIRED)
|
|
find_package(glog REQUIRED)
|
|
|
|
# generate a configuration file (autoheader-style) to configure
|
|
# certain symbols that Nix depends on.
|
|
configure_file(config.h.in nix_config.h @ONLY)
|
|
INSTALL(FILES "${PROJECT_BINARY_DIR}/nix_config.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/nix")
|
|
|
|
# install corepkgs
|
|
configure_file(corepkgs/config.nix.in config.nix @ONLY)
|
|
INSTALL(DIRECTORY corepkgs
|
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/nix
|
|
FILES_MATCHING
|
|
PATTERN "*.nix")
|
|
INSTALL(FILES "${PROJECT_BINARY_DIR}/config.nix" DESTINATION "${CMAKE_INSTALL_DATADIR}/nix/corepkgs")
|
|
|
|
# Conditionally run tests
|
|
option(PACKAGE_TESTS "Build the tests" ON)
|
|
if (PACKAGE_TESTS)
|
|
enable_testing()
|
|
find_package(GTest)
|
|
include(GoogleTest)
|
|
endif()
|
|
|
|
add_subdirectory(src)
|