preprocessor: build the header out of tree

This avoids unnecessary rebuilds when we have parallel configurations
being built.
This commit is contained in:
Danny Robson 2018-10-30 21:41:15 +11:00
parent 888d88a74d
commit bfe0a92eec
7 changed files with 26 additions and 10 deletions

View File

@ -32,6 +32,17 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
###############################################################################
add_library(cruft)
# Setup a directory to hold built sources we may need to export to clients.
set (PREFIX "cruft/util")
file (MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}")
target_include_directories(
cruft
PUBLIC
"${CMAKE_CURRENT_BINARY_DIR}/prefix/"
)
# Preemptively define an identity panic macro so that TCL doens't fuck us over
# by renaming a commonly used symbol.
target_compile_definitions(cruft PUBLIC "-Dpanic=panic")
@ -344,7 +355,7 @@ list (
polynomial.hpp
pool.cpp
pool.hpp
"${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.hpp"
"${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}/preprocessor.hpp"
quaternion.cpp
quaternion.hpp
rand/lcg.cpp
@ -440,13 +451,13 @@ endif ()
## to coax CMake into behaving here any longer. Feel free to fix it.
add_custom_command (
OUTPUT
"${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.hpp"
"${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}/preprocessor.hpp"
COMMENT
"[preprocessor.py] preprocessor.hpp"
COMMAND
"${PYTHON_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.py"
"${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.hpp"
"${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}/preprocessor.hpp"
320
DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.py"

View File

@ -17,9 +17,10 @@
#include "../tuple/value.hpp"
#include "../debug.hpp"
#include "../maths.hpp"
#include "../preprocessor.hpp"
#include "../types/bits.hpp"
#include <cruft/util/preprocessor.hpp>
#include <algorithm>
#include <cmath>
#include <cstdlib>

View File

@ -11,9 +11,10 @@
#include "fwd.hpp"
#include "../preprocessor.hpp"
#include "../platform.hpp"
#include <cruft/util/preprocessor.hpp>
#include <cstddef>
#include <type_traits>

View File

@ -9,7 +9,8 @@
#include "backtrace.hpp"
#include "debug.hpp"
#include "log.hpp"
#include "preprocessor.hpp"
#include <cruft/util/preprocessor.hpp>
#include <cstdlib>
#include <iostream>

View File

@ -9,9 +9,10 @@
#ifndef __UTIL_INTROSPECTION_HPP
#define __UTIL_INTROSPECTION_HPP
#include "preprocessor.hpp"
#include "variadic.hpp"
#include <cruft/util/preprocessor.hpp>
#include <array>
#include <cstddef>
#include <cstdint>

View File

@ -11,9 +11,10 @@
#include "nocopy.hpp"
#include "preprocessor.hpp"
#include "format.hpp"
#include <cruft/util/preprocessor.hpp>
#include <iosfwd>
#include <string>

View File

@ -1,5 +1,5 @@
#include "tap.hpp"
#include "preprocessor.hpp"
#include <cruft/util/tap.hpp>
#include <cruft/util/preprocessor.hpp>
#define PLUS(X,Y) ((X)+(Y))