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) 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 # Preemptively define an identity panic macro so that TCL doens't fuck us over
# by renaming a commonly used symbol. # by renaming a commonly used symbol.
target_compile_definitions(cruft PUBLIC "-Dpanic=panic") target_compile_definitions(cruft PUBLIC "-Dpanic=panic")
@ -344,7 +355,7 @@ list (
polynomial.hpp polynomial.hpp
pool.cpp pool.cpp
pool.hpp pool.hpp
"${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.hpp" "${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}/preprocessor.hpp"
quaternion.cpp quaternion.cpp
quaternion.hpp quaternion.hpp
rand/lcg.cpp rand/lcg.cpp
@ -440,13 +451,13 @@ endif ()
## to coax CMake into behaving here any longer. Feel free to fix it. ## to coax CMake into behaving here any longer. Feel free to fix it.
add_custom_command ( add_custom_command (
OUTPUT OUTPUT
"${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.hpp" "${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}/preprocessor.hpp"
COMMENT COMMENT
"[preprocessor.py] preprocessor.hpp" "[preprocessor.py] preprocessor.hpp"
COMMAND COMMAND
"${PYTHON_EXECUTABLE}" "${PYTHON_EXECUTABLE}"
"${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.py" "${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.py"
"${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.hpp" "${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}/preprocessor.hpp"
320 320
DEPENDS DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.py" "${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.py"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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