tvl-depot/third_party/nix/CMakeLists.txt
Vincent Ambo 25393d8080 refactor(3p/nix): Introduce CMake as the build system for Nix
Completes the switch from Meson to CMake for the core build system in
Nix.

Meson was added originally because someone else had already done the
work for integrating it in Nix and it was an upgrade from the previous
setup.

However over time it became clear that Meson is not quite mature
enough for projects like Nix that have occasionally peculiar
configuration constraints.

Some issues encountered with Meson (some of these are due to the Meson
setup in Nix):

* Difficulty with generating correct compile_commands.json for
  external tools like clangd
* Difficulty linking to libc++ when using clang
* Ugly shell invocations for certain parts of the build system (I want
  these to be gone!!!)

This CMake setup mimics the Meson configuration, but there are some
differences (some temporary):

* headers are now included separately for each library (see a previous
  commit that changes includes appropriately)
* autoheaders-style configuration is currently hardcoded. Before
  blindly copying this I want to evaluate how much of it actually exists
  for portability concerns that I don't have (such as support for OS
  X).
* Nix is built with libc++ by default.
* [libstore] SQL schema is now inlined via a generated header, not an
  included string literal

Abseil is still built as part of this build, rather than an external
dependency, because it chokes on differently configured compiler
invocations.

Note that because of the move to libc++ an unwanted behaviour is
introduced: glog log messages no longer have a body. I have yet to
debug what is going on there.
2020-05-28 00:11:25 +01:00

31 lines
1.1 KiB
CMake

# -*- mode: cmake; -*-
cmake_minimum_required(VERSION 3.16)
project(nix CXX)
set(CMAKE_CXX_STANDARD 17)
# 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) # probably coroutine + ::headers, lets find out
find_package(CURL)
find_package(SQLite3)
find_package(Threads)
find_package(glog)
find_package(LibLZMA)
# Abseil really doesn't like being precompiled. It is included here as
# an imported CMake project (i.e. it will be built /with/ this
# project).
#
# In development mode, the 'abseil_cpp' folder is symlinked to
# ../abseil_cpp (the relative location in the depot). In derivation
# builds this symlink is automatically replaced with an appropriate
# link to the Abseil sources in the Nix store.
add_subdirectory(abseil_cpp)
# generate a configuration file (autoheader-style) to configure
# certain symbols that Nix depends on.
configure_file(config.h.in nix_config.h @ONLY)
add_subdirectory(src)