Skip to content

Commit 56c3846

Browse files
committed
Remove annoying messages from FindRust package and print only if there is an error.
1 parent 50b1ed9 commit 56c3846

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cmake/FindRust.cmake

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,26 @@ if(Rust_RUSTUP_EXECUTABLE AND Rust_FIND_COMPONENTS)
6565
if(Rust_TOOLCHAIN)
6666
execute_process(
6767
COMMAND ${Rust_RUSTUP_EXECUTABLE} toolchain install ${Rust_TOOLCHAIN} --force
68+
OUTPUT_VARIABLE Rust_OUTPUT
69+
ERROR_VARIABLE Rust_OUTPUT
70+
RESULT_VARIABLE Rust_STATUS
6871
)
72+
73+
if(Rust_STATUS AND NOT Rust_STATUS EQUAL 0)
74+
message(FATAL_ERROR "${Rust_OUTPUT}")
75+
endif()
76+
6977
execute_process(
7078
COMMAND ${Rust_RUSTUP_EXECUTABLE} default ${Rust_TOOLCHAIN}
79+
OUTPUT_VARIABLE Rust_OUTPUT
80+
ERROR_VARIABLE Rust_OUTPUT
81+
RESULT_VARIABLE Rust_STATUS
7182
)
7283

84+
if(Rust_STATUS AND NOT Rust_STATUS EQUAL 0)
85+
message(FATAL_ERROR "${Rust_OUTPUT}")
86+
endif()
87+
7388
# Obtain toolchain full name and triplet (not needed for now)
7489
# execute_process(
7590
# COMMAND ${Rust_RUSTUP_EXECUTABLE} default
@@ -99,7 +114,14 @@ if(Rust_RUSTUP_EXECUTABLE AND Rust_FIND_COMPONENTS)
99114
foreach(Rust_TOOLCHAIN_COMPONENT ${Rust_TOOLCHAIN_COMPONENT_LIST})
100115
execute_process(
101116
COMMAND ${Rust_RUSTUP_EXECUTABLE} toolchain install ${Rust_TOOLCHAIN} --component ${Rust_TOOLCHAIN_COMPONENT}
117+
OUTPUT_VARIABLE Rust_OUTPUT
118+
ERROR_VARIABLE Rust_OUTPUT
119+
RESULT_VARIABLE Rust_STATUS
102120
)
121+
122+
if(Rust_STATUS AND NOT Rust_STATUS EQUAL 0)
123+
message(FATAL_ERROR "${Rust_OUTPUT}")
124+
endif()
103125
endforeach()
104126
endif()
105127

0 commit comments

Comments
 (0)