build: update the meson build configuration

This commit is contained in:
Danny Robson 2019-06-19 17:28:01 +10:00
parent f86989bc67
commit f4438831a6
12 changed files with 341 additions and 286 deletions

View File

@ -38,11 +38,9 @@ target_link_libraries(cruft ${NC_CXX_STDCXXFS})
# 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/"
)
target_include_directories(cruft PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}")
target_include_directories(cruft PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/prefix/")
target_include_directories(cruft INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/prefix/")
# Preemptively define an identity panic macro so that TCL doens't fuck us over
@ -579,6 +577,7 @@ foreach (tool cpuid poisson macro scratch)
set_target_properties (util_${tool} PROPERTIES OUTPUT_NAME ${tool})
target_link_libraries (util_${tool} cruft)
target_include_directories(util_${tool} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(util_${tool} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}")
endforeach ()
@ -715,6 +714,7 @@ if (TESTS)
add_executable(util_${name} test/${t}.cpp)
target_link_libraries(util_${name} PRIVATE cruft)
target_include_directories(util_${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(util_${name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}")
add_test(NAME util_${name} COMMAND util_${name})
set_tests_properties(util_${name} PROPERTIES FAIL_REGULAR_EXPRESSION "not ok -")
add_dependencies(util_test util_${name})

View File

@ -19,7 +19,7 @@
#include "../maths.hpp"
#include "../types/bits.hpp"
#include <cruft/util/preprocessor.hpp>
#include "preprocessor.hpp"
#include <algorithm>
#include <cmath>

View File

@ -13,7 +13,7 @@
#include "../platform.hpp"
#include <cruft/util/preprocessor.hpp>
#include "preprocessor.hpp"
#include <cstddef>
#include <type_traits>

View File

@ -8,7 +8,7 @@
#include "./validate.hpp"
#include <cruft/util/preprocessor.hpp>
#include "preprocessor.hpp"
#include <cmath>

View File

@ -11,7 +11,7 @@
#include "std.hpp"
#include "variadic.hpp"
#include <cruft/util/preprocessor.hpp>
#include "preprocessor.hpp"
#include <algorithm>
#include <array>

View File

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

View File

@ -7,18 +7,3 @@
*/
#include "deleter.hpp"
using cruft::memory::owner_deleter;
///////////////////////////////////////////////////////////////////////////////
// This instantiation isn't required but it allows us to catch compilation
// errors early within this library rather than at a call site in another
// library.
class owner {
void dealloc (void*);
};
template class cruft::memory::owner_deleter<void,owner,&owner::dealloc>;

View File

@ -3,7 +3,11 @@ project('cruft', 'cpp')
pymod = import('python')
python = pymod.find_installation('python3')
ragel = generator(find_program('ragel'), output: '@BASENAME@.cpp', arguments: [ '@INPUT@', '-o@OUTPUT@', '-G2' ])
ragel = generator(
find_program('ragel'),
output: '@BASENAME@.cpp',
arguments: [ '@INPUT@', '-o@OUTPUT@', '-G2' ]
)
if host_machine.endian() == 'big'
add_project_arguments('-DWORDS_BIGENDIAN')
@ -21,24 +25,16 @@ sources = [
ragel.process('time/parse8601.cpp.rl'),
]
dependencies = []
dependencies = [
dependency('threads')
]
### 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")
##
##
add_project_arguments('-Dpanic=panic', language: 'cpp')
#################################################################################
cpp = meson.get_compiler('cpp')
execinfo = cpp.find_library('execinfo', required: false) # sym:backtrace
@ -55,30 +51,14 @@ else
endif
####-----------------------------------------------------------------------------
#### We shouldn't be building into the source directory, but I can't stand trying
#### to coax CMake into behaving here any longer. Feel free to fix it.
##add_custom_command (
##OUTPUT
## "${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}/preprocessor.hpp"
##COMMENT
## "[preprocessor.py] preprocessor.hpp"
##COMMAND
## "${PYTHON_EXECUTABLE}"
## "${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.py"
## "${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}/preprocessor.hpp"
## 320
##DEPENDS
## "${CMAKE_CURRENT_SOURCE_DIR}/preprocessor.py"
##)
preprocessor_hpp = custom_target(
sources += custom_target(
'preprocessor.hpp',
output: 'preprocessor.hpp',
input: 'preprocessor.py',
command: [python, '@INPUT@', '@OUTPUT@', '320'],
command: [python, '@INPUT@', '@OUTPUT@', '480'],
)
#################################################################################
### Platform wrappers
systems = {
@ -133,30 +113,29 @@ endif
####-----------------------------------------------------------------------------
##if (WIN32)
## list (
## APPEND UTIL_FILES
## debug_win32.cpp
## exe_win32.cpp
## io_win32.cpp
## io_win32.hpp
## thread/event_win32.cpp
## library_win32.cpp
## library_win32.hpp
## time_win32.cpp
## win32/windows.hpp
## win32/except.cpp
## win32/except.hpp
## win32/file.cpp
## win32/file.hpp
## win32/handle.cpp
## win32/handle.hpp
## win32/registry.cpp
## win32/registry.hpp
## )
##
## target_link_libraries (cruft ws2_32)
##endif ()
if host_machine.system() == 'windows'
sources += [
'debug_win32.cpp',
'exe_win32.cpp',
'io_win32.cpp',
'io_win32.hpp',
'thread/event_win32.cpp',
'library_win32.cpp',
'library_win32.hpp',
'time_win32.cpp',
'win32/windows.hpp',
'win32/except.cpp',
'win32/except.hpp',
'win32/file.cpp',
'win32/file.hpp',
'win32/handle.cpp',
'win32/handle.hpp',
'win32/registry.cpp',
'win32/registry.hpp',
]
dependencies += cpp.find_library('ws2_32')
endif
sources += [
@ -175,27 +154,50 @@ if host_machine.system() == 'linux'
'thread/flag_futex.cpp',
'thread/flag_futex.hpp',
]
elif host_name.system() == 'windows'
sources += [
'thread/event_std.cpp',
'thread/event_std.hpp',
'thread/semaphore_win32.hpp',
'thread/semaphore_win32.cpp',
'thread/flag_std.cpp',
'thread/flag_std.hpp',
]
else
error('Unknown platform for threading')
endif
##elseif (WIN32)
## list (APPEND UTIL_FILES
## thread/event_std.cpp
## thread/event_std.hpp
## thread/semaphore_win32.hpp
## thread/semaphore_win32.cpp
## thread/flag_std.cpp
## thread/flag_std.hpp
## )
##else ()
## list (APPEND UTIL_FILES
## thread/flag_std.cpp
## thread/flag_std.hpp
## )
##endif ()
##
##
if host_machine.cpu_family() == 'x86_64'
sources += [
'cpuid/x86.cpp',
'cpuid/x86.cpp',
]
else
warning('Unknown architecture @0@. Defaulting to null cpuid'.format(host_machine.cpu_family()))
sources += [
'cpuid/none.cpp',
'cpuid/none.hpp',
]
endif
if host_machine.system() == 'linux'
sources += [
'rand/system_linux.cpp',
'rand/system_linux.hpp',
]
elif host_machine.system() == 'windows'
sources += [
'rand/system_win32.cpp',
'rand/system_win32.hpp',
]
else
error('Unsupported system for rand')
endif
#################################################################################
### Common files
sources += [
@ -231,6 +233,7 @@ sources += [
'array/sarray.hpp',
'array/parray.cpp',
'array/parray.hpp',
'array/varray.hpp',
'ascii.hpp',
'backtrace.hpp',
'bezier.cpp',
@ -248,9 +251,10 @@ sources += [
'cmdopt.hpp',
'colour.cpp',
'colour.hpp',
'coord.hpp',
'coord/fwd.hpp',
'coord/base.hpp',
'coord.hpp',
'coord/comparator.hpp',
'coord/init.hpp',
'coord/iostream.hpp',
'coord/ops.hpp',
@ -260,10 +264,18 @@ sources += [
'cpp.hpp',
'cpuid.cpp',
'cpuid.hpp',
'cpuid_x86.cpp',
'cpuid_x86.hpp',
'debug.cpp',
'debug.hpp',
'debug/assert.cpp',
'debug/assert.hpp',
'debug/compiler.cpp',
'debug/compiler.hpp',
'debug/debugger.cpp',
'debug/debugger.hpp',
'debug/panic.cpp',
'debug/panic.hpp',
'debug/system.cpp',
'debug/system.hpp',
'debug/validate.cpp',
'debug/validate.hpp',
'encode/number.hpp',
'encode/base.cpp',
'encode/base.hpp',
@ -272,6 +284,7 @@ sources += [
'except.cpp',
'except.hpp',
'exe.hpp',
'expected.hpp',
'extent.cpp',
'extent.hpp',
'fixed.cpp',
@ -316,6 +329,7 @@ sources += [
'hash/fwd.hpp',
'hash/adler.cpp',
'hash/adler.hpp',
'hash/buzhash.hpp',
'hash/bsdsum.cpp',
'hash/bsdsum.hpp',
'hash/crc.cpp',
@ -337,6 +351,8 @@ sources += [
'hash/murmur/murmur3.hpp',
'hash/siphash.cpp',
'hash/siphash.hpp',
'hash/table.cpp',
'hash/table.hpp',
'hash/wang.hpp',
'hash/xxhash.cpp',
'hash/xxhash.hpp',
@ -344,7 +360,18 @@ sources += [
'introspection.hpp',
'io.cpp',
'io.hpp',
'iterator.hpp',
'iterator/constant.hpp',
'iterator/counting.hpp',
'iterator/dereference.hpp',
'iterator/discard.hpp',
'iterator/indices.hpp',
'iterator/infix.hpp',
'iterator/iota.hpp',
'iterator/numeric.hpp',
'iterator/referencing.hpp',
'iterator/transform.hpp',
'iterator/unequal.hpp',
'iterator/zip.hpp',
'job/fwd.hpp',
'job/dispatch.hpp',
'job/queue.cpp',
@ -353,6 +380,8 @@ sources += [
'library.hpp',
'log.cpp',
'log.hpp',
'map/fixed.cpp',
'map/fixed.hpp',
'maths.cpp',
'maths.hpp',
'maths/fast.hpp',
@ -363,11 +392,19 @@ sources += [
'matrix.hpp',
'memory/deleter.cpp',
'memory/deleter.hpp',
'nocopy.hpp',
'parallel/queue.cpp',
'parallel/queue.hpp',
'parse.cpp',
'parse.hpp',
'parallel/stack.cpp',
'parallel/stack.hpp',
'parse/fwd.hpp',
'parse/enum.cpp',
'parse/enum.hpp',
'parse/time.cpp',
'parse/time.hpp',
'parse/value.cpp',
'parse/value.hpp',
'parse/si.cpp',
'parse/si.hpp',
'platform.hpp',
'point.cpp',
'point.hpp',
@ -376,8 +413,6 @@ sources += [
'polynomial.hpp',
'pool.cpp',
'pool.hpp',
#'"${CMAKE_CURRENT_BINARY_DIR}/prefix/${PREFIX}/preprocessor.hpp"',
preprocessor_hpp,
'quaternion.cpp',
'quaternion.hpp',
'rand/lcg.cpp',
@ -386,6 +421,11 @@ sources += [
'rand/xorshift.hpp',
'rand/mwc64x.cpp',
'rand/mwc64x.hpp',
'rand/pcg.cpp',
'rand/pcg.hpp',
'rand/rdrand.cpp',
'rand/rdrand.hpp',
'rand/system.hpp',
'random.cpp',
'random.hpp',
'range.cpp',
@ -394,12 +434,12 @@ sources += [
'rational.hpp',
'region.cpp',
'region.hpp',
'registrar.cpp',
'registrar.hpp',
'roots/bisection.hpp',
'scoped.hpp',
'si.cpp',
'signal.cpp',
'signal.hpp',
'si.hpp',
'singleton.hpp',
'stats.cpp',
'stats.hpp',
@ -437,6 +477,7 @@ sources += [
'types/comparator.hpp',
'types/description.cpp',
'types/description.hpp',
'types/dispatch.hpp',
'types/string.cpp',
'types/string.hpp',
'types/tagged.hpp',
@ -454,179 +495,185 @@ sources += [
]
libcruft = library('cruft', sources)
if get_option('simd')
sources += [
'coord/simd.cpp',
'coord/simd.hpp',
'coord/simd_sse.hpp',
'coord/simd_neon.hpp',
]
endif
##
##option (SIMD "enable simd support" OFF)
##
##if (SIM)
## list (APPEND UTIL_FILES
## "coord/simd.cpp"
## "coord/simd.hpp"
## "coord/simd_sse.hpp"
## "coord/simd_neon.hpp"
## )
##endif ()
##
##
##
#################################################################################
##target_sources(cruft PRIVATE ${UTIL_FILES})
##add_library(cruft-util ALIAS cruft)
##target_include_directories(cruft PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
##
##
##search_libs (SHM_LIBS shm_open rt)
##search_libs (DL_LIBS dlopen dl)
##search_libs (CLOCK_LIBS clock_gettime rt c)
##search_libs (MATH_LIBS cos m)
##
##target_link_libraries(cruft ${SHM_LIBS})
##target_link_libraries(cruft ${DL_LIBS})
##target_link_libraries(cruft ${CLOCK_LIBS})
##target_link_libraries(cruft ${MATH_LIBS})
##
### HACK: -ldl isn't getting discovered correctly so we add it unconditionally
### for the time being.
##if (NOT WIN32)
## target_link_libraries(cruft dl)
##endif ()
##
##
rt = cpp.find_library('rt', required: false)
if not cpp.has_function('shm_open', dependencies: [rt])
error('Cannot find shm library')
endif
dependencies += rt
dl = cpp.find_library('dl', required: false)
if not cpp.has_function('dlopen', dependencies: dl)
error ('Cannot find dl library')
endif
dependencies += dl
if not cpp.has_function('clock_gettime', dependencies: rt)
error('Cannot find clock_gettime library')
endif
m = cpp.find_library('m', required: false)
if not cpp.has_function('cos', dependencies: m)
error('Cannot find maths library')
endif
dependencies += m
libcruft = library('cruft', sources, dependencies: dependencies)
#################################################################################
##foreach (tool cpuid poisson macro scratch)
## add_executable (util_${tool} tools/${tool}.cpp)
## set_target_properties (util_${tool} PROPERTIES OUTPUT_NAME ${tool})
## target_link_libraries (util_${tool} cruft)
## target_include_directories(util_${tool} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
##endforeach ()
##
##
foreach tool: ['cpuid', 'poisson', 'macro', 'scratch']
executable(tool, 'tools/@0@.cpp'.format(tool), link_with: libcruft)
endforeach
#################################################################################
##option (TESTS "enable unit testing" ON)
##
##if (TESTS)
## include(CTest)
## enable_testing()
##
## list (
## APPEND TEST_BIN
## ascii
## algo/search
## algo/sort
## alloc/aligned/foreign
## alloc/aligned/direct
## alloc/easy
## alloc/linear
## alloc/stack
## affine
## array/darray
## array/sarray
## array/parray
## backtrace
## bezier
## bitwise
## buffer/simple
## cmdopt
## colour
## comparator
## coord
## encode/number
## encode/base
## endian
## exe
## extent
## fixed
## float
## format
## geom/aabb
## geom/ellipse
## geom/frustum
## geom/line
## geom/plane
## geom/ray
## geom/segment
## geom/sphere
## hash/checksum
## hash/crc
## hash/fasthash
## hash/fnv1a
## hash/murmur
## hash/siphash
## hash/xxhash
## hton
## io
## introspection
## iterator
## job/queue
## kmeans
## maths
## maths/fast
## matrix
## memory/deleter
## parallel/queue
## parse
## point
## polynomial
## pool
## preprocessor
## quaternion
## rand/buckets
## random
## range
## rational
## region
## roots/bisection
## signal
## singleton
## stream
## string
## stringid
## strongdef
## thread/event
## thread/flag
## thread/monitor
## thread/semaphore
## thread/spinlock
## thread/ticketlock
## time/8601
## traits
## tuple/index
## tuple/value
## tuple/type
## typeidx
## types/tagged
## uri
## utf8
## vector
## version
## view
## )
##
## if (NOT WIN32)
## list (APPEND TEST_BIN
## buffer/circular
## buffer/paged
## )
## endif ()
##
## if (SIMD)
## list (APPEND TEST_BIN
## coord/simd
## )
## endif()
##
## foreach(t ${TEST_BIN})
## string(REPLACE "/" "_" name "test/${t}")
## add_executable(util_${name} test/${t}.cpp)
## target_link_libraries(util_${name} PRIVATE cruft)
## target_include_directories(util_${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
## add_test(NAME util_${name} COMMAND util_${name})
## set_tests_properties(util_${name} PROPERTIES FAIL_REGULAR_EXPRESSION "not ok -")
## endforeach(t)
tests = [
'ascii',
'algo/search',
'algo/sort',
'alloc/aligned/foreign',
'alloc/aligned/direct',
'alloc/easy',
'alloc/linear',
'alloc/stack',
'affine',
'array/darray',
'array/sarray',
'array/parray',
'backtrace',
'bezier',
'bitwise',
'buffer/simple',
'cmdopt',
'colour',
'comparator',
'coord',
'encode/number',
'encode/base',
'endian',
'exe',
'expected',
'extent',
'fixed',
'float',
'format',
'geom/aabb',
'geom/ellipse',
'geom/frustum',
'geom/line',
'geom/plane',
'geom/ray',
'geom/segment',
'geom/sphere',
'hash/buzhash',
'hash/checksum',
'hash/crc',
'hash/fasthash',
'hash/fnv1a',
'hash/murmur',
'hash/siphash',
'hash/table',
'hash/xxhash',
'hton',
'io',
'introspection',
'iterator',
'job/dispatch',
'job/queue',
'kmeans',
'map/fixed',
'maths',
'maths/fast',
'matrix',
'memory/deleter',
'parallel/queue',
'parallel/stack',
'parse/enum',
'parse/value',
'parse/time',
'parse/si',
'point',
'polynomial',
'pool',
'preprocessor',
'quaternion',
'rand/buckets',
'random',
'range',
'rational',
'region',
'registrar',
'roots/bisection',
'scoped',
'signal',
'singleton',
'stream',
'string',
'stringid',
'strongdef',
'thread/event',
'thread/flag',
'thread/monitor',
'thread/semaphore',
'thread/spinlock',
'thread/ticketlock',
'time/8601',
'traits',
'tuple/index',
'tuple/value',
'tuple/type',
'typeidx',
'types/description',
'types/tagged',
'uri',
'utf8',
'vector',
'version',
'view',
]
if host_machine.system() != 'windows'
tests += [
'buffer/circular',
'buffer/paged',
]
endif
if get_option('simd')
tests += [
'coord/simd'
]
endif
foreach t: tests
test(
t.underscorify(),
executable(
'test_@0@'.format(t.underscorify()),
'test/@0@.cpp'.format(t),
link_with: libcruft,
dependencies: dependencies
),
protocol: 'tap'
)
endforeach
##
## configure_file (test/cpp.py.in util_test_cpp.py @ONLY)
## add_test (NAME util_test_cpp COMMAND ${PYTHON_EXECUTABLE} util_test_cpp.py)
@ -636,5 +683,26 @@ libcruft = library('cruft', sources)
##
##
#################################################################################
##configure_file(libcruft.pc.in libcruft.pc)
##configure_file(Doxyfile.in Doxyfile)
cmake_config = configuration_data()
pkg = import('pkgconfig')
pkg.generate(
libraries: dependencies,
version: meson.project_version(),
name: meson.project_name(),
filebase: 'cruft',
description: 'A simple utility library for C++'
)
configure_file(
input: 'Doxyfile.in',
output: 'Doxyfile',
configuration: {
'CMAKE_PROJECT_NAME': meson.project_name(),
'CMAKE_PROJECT_VERSION': meson.project_version(),
'CMAKE_CURRENT_SOURCE_DIR': meson.current_source_dir(),
'CMAKE_CURRENT_BINARY_DIR': meson.current_build_dir(),
}
)

1
meson_options.txt Normal file
View File

@ -0,0 +1 @@
option('simd', type: 'boolean', value: false)

View File

@ -12,7 +12,7 @@
#include "../std.hpp"
#include <cruft/util/preprocessor.hpp>
#include "preprocessor.hpp"
///////////////////////////////////////////////////////////////////////////////

View File

@ -9,7 +9,8 @@
#include "value.hpp"
#include "../cast.hpp"
#include <cruft/util/preprocessor.hpp>
#include "preprocessor.hpp"
#include <cstdlib>
#include <stdexcept>

View File

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