@@ -70,10 +70,16 @@ foreach(_dir libcc2rs rules)
7070 write_rust_toolchain (${CMAKE_SOURCE_DIR} /${_dir} )
7171endforeach ()
7272
73- add_custom_target ("install-rust-toolchain"
74- COMMAND rustup toolchain install ${RUST_STABLE_VERSION}
75- USES_TERMINAL
76- )
73+ set (RUST_STAMP_FILE "${CMAKE_BINARY_DIR} /.rust-toolchain.stamp" )
74+
75+ add_custom_command (
76+ OUTPUT "${RUST_STAMP_FILE} "
77+ COMMAND rustup toolchain install ${RUST_STABLE_VERSION}
78+ COMMAND ${CMAKE_COMMAND} -E touch "${RUST_STAMP_FILE} "
79+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR} /cmake/rust-toolchain.cmake"
80+ USES_TERMINAL
81+ VERBATIM
82+ )
7783
7884add_subdirectory (cpp2rust )
7985add_subdirectory (libcc2rs )
@@ -90,7 +96,7 @@ add_custom_target("format"
9096 COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR} /rule-preprocessor/Cargo.toml
9197 COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR} /libcc2rs/Cargo.toml
9298 COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR} /libcc2rs-macros/Cargo.toml
93- DEPENDS "install-rust-toolchain "
99+ DEPENDS "${RUST_STAMP_FILE} "
94100 COMMENT "Running clang-format and cargo fmt on all source files"
95101 VERBATIM
96102 )
@@ -102,7 +108,7 @@ endif()
102108add_custom_target ("check-libcc2rs"
103109 COMMAND cargo test
104110 WORKING_DIRECTORY "${PROJECT_SOURCE_DIR} /libcc2rs"
105- DEPENDS install -rust-toolchain
111+ DEPENDS " ${RUST_STAMP_FILE} "
106112 USES_TERMINAL
107113 )
108114
@@ -172,12 +178,12 @@ add_custom_command(
172178 CARGO_TARGET_DIR=${PROJECT_SOURCE_DIR}/rule-preprocessor/target
173179 cargo run
174180 WORKING_DIRECTORY "${PROJECT_SOURCE_DIR} /rules"
175- DEPENDS ${rust_rules_inputs} ${rule_preprocessor_sources}
181+ DEPENDS ${rust_rules_inputs} ${rule_preprocessor_sources} " ${RUST_STAMP_FILE} "
176182 VERBATIM
177183)
178184
179185add_custom_target ("preprocess-rust-rules" ALL
180- DEPENDS ${rust_rules_ir_outputs} install -rust-toolchain )
186+ DEPENDS ${rust_rules_ir_outputs} )
181187
182188add_custom_target ("check-rules"
183189 COMMAND find ${PROJECT_SOURCE_DIR} /rules -name "ir_unsafe.json" -delete
0 commit comments