-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
72 lines (58 loc) · 2.5 KB
/
CMakeLists.txt
File metadata and controls
72 lines (58 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
cmake_minimum_required(VERSION 3.20)
project(Cpp2Rust-TestSuite)
set(CPP2RUST_PROGRAMS woff2 brunsli)
set(CPP2RUST_MODELS unsafe refcount)
set(CPP2RUST_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/../cpp2rust)
set(CPP2RUST_BINARY ${CPP2RUST_SRCDIR}/build/cpp2rust/cpp2rust)
# -----------------------------------------------------------------------------
include(${CPP2RUST_SRCDIR}/cmake/rust-toolchain.cmake)
set(FILTER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/filter_compile_commands.py)
foreach(_prog IN LISTS CPP2RUST_PROGRAMS)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${_prog}.cmake)
set(_model_regen_targets "")
set(_model_build_targets "")
foreach(_model IN LISTS CPP2RUST_MODELS)
## FIXME: remove -Wstatic_mut_refs below when the generated code gets fixed
add_custom_target("build-${_prog}-${_model}"
COMMAND ${CMAKE_COMMAND} -E env "RUSTFLAGS=-Awarnings -Astatic_mut_refs" cargo +${RUST_STABLE_VERSION} build --release
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${_prog}/out/${_model}"
)
list(APPEND _model_regen_targets "regen-${_prog}-${_model}")
list(APPEND _model_build_targets "build-${_prog}-${_model}")
endforeach()
add_custom_target("build-${_prog}"
DEPENDS "build-${_prog}-original" ${_model_build_targets}
)
add_custom_target("regen-${_prog}"
DEPENDS "build-${_prog}-original" ${_model_regen_targets}
)
add_custom_target("check-${_prog}"
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/scripts/${_prog}-test.sh"
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CPP2RUST_MODELS}
DEPENDS "build-${_prog}"
USES_TERMINAL
)
add_custom_target("benchmark-${_prog}"
COMMAND python3
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/benchmark.py"
--programs ${_prog}
--csv "${CMAKE_BINARY_DIR}/bench_${_prog}.csv"
DEPENDS "build-${_prog}"
USES_TERMINAL
)
endforeach()
list(TRANSFORM CPP2RUST_PROGRAMS PREPEND "build-" OUTPUT_VARIABLE _build_targets)
list(TRANSFORM CPP2RUST_PROGRAMS PREPEND "check-" OUTPUT_VARIABLE _check_targets)
list(TRANSFORM CPP2RUST_PROGRAMS PREPEND "regen-" OUTPUT_VARIABLE _regen_targets)
add_custom_target("build" DEPENDS ${_build_targets})
add_custom_target("check" DEPENDS ${_check_targets})
add_custom_target("regen" DEPENDS ${_regen_targets})
add_custom_target("benchmark"
COMMAND python3
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/benchmark.py"
--csv "${CMAKE_BINARY_DIR}/bench.csv"
DEPENDS "build"
USES_TERMINAL
)