cmake: avoid recursive cmake lists for tests

This commit is contained in:
Danny Robson 2017-01-25 15:06:47 +11:00
parent f665244010
commit 845c8dd14d
2 changed files with 73 additions and 79 deletions

View File

@ -436,7 +436,79 @@ option (TESTS "enable unit testing" ON)
if (TESTS) if (TESTS)
include(CTest) include(CTest)
enable_testing() enable_testing()
add_subdirectory(test)
list (
APPEND TEST_BIN
alloc/aligned
alloc/arena
alloc/dynamic
alloc/linear
alloc/stack
affine
backtrace
bezier
bitwise
cmdopt
colour
coord
crypto/arc4
crypto/ice
crypto/tea
crypto/xtea
crypto/xxtea
exe
extent
fixed
float
format
geom/aabb
geom/ray
hash/checksum
hash/fasthash
hash/hmac
hash/hotp
hash/keccak
hash/md2
hash/md4
hash/md5
hash/murmur
hash/ripemd
hash/sha1
hash/sha2
hash/xxhash
hton
introspection
json_types
maths
matrix
memory/deleter
point
polynomial
pool
quaternion
rand/buckets
range
rational
region
roots/bisection
signal
stream
string
stringid
strongdef
tuple
uri
vector
version
view
)
foreach(t ${TEST_BIN})
string(REPLACE "/" "_" name "test/${t}")
add_executable(util_${name} test/${t}.cpp)
target_link_libraries(util_${name} PRIVATE cruft-util)
add_test(NAME util_${name} COMMAND util_${name})
endforeach(t)
endif () endif ()

View File

@ -1,78 +0,0 @@
list (
APPEND TEST_BIN
alloc/aligned
alloc/arena
alloc/dynamic
alloc/linear
alloc/stack
affine
backtrace
bezier
bitwise
cmdopt
colour
coord
crypto/arc4
crypto/ice
crypto/tea
crypto/xtea
crypto/xxtea
exe
extent
fixed
float
format
geom/aabb
geom/ray
hash/checksum
hash/fasthash
hash/hmac
hash/hotp
hash/keccak
hash/md2
hash/md4
hash/md5
hash/murmur
hash/ripemd
hash/sha1
hash/sha2
hash/xxhash
hton
introspection
json_types
maths
matrix
memory/deleter
point
polynomial
pool
quaternion
rand/buckets
range
rational
region
roots/bisection
signal
stream
string
stringid
strongdef
tuple
uri
vector
version
view
)
function(define_test path)
string(REPLACE "/" "_" name "${path}")
add_executable(${name} "${path}.cpp")
target_link_libraries(${name} cruft-util stdc++fs)
add_test(NAME ${name} COMMAND ${name})
endfunction(define_test)
foreach(t ${TEST_BIN})
define_test(${t})
endforeach(t)