Skip to content

Commit 7760c6d

Browse files
committed
cmake: use $<TARGET_FILE:xxx> for binaries
Rather than handle the difference in output binaries per-platform on our own, rely on the target artifact generator expression[0] cmake already provides. [0]: https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#target-artifacts
1 parent 3bb6372 commit 7760c6d

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

cmake/rust.cmake

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,6 @@ add_custom_target(
3030
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
3131
)
3232

33-
# The location/names of the example binaries change based on platform, and
34-
# in the case of WIN32, by the Config.
35-
if(WIN32)
36-
set(CLIENT_BINARY "${CMAKE_BINARY_DIR}\\tests\\$<CONFIG>\\client.exe")
37-
set(SERVER_BINARY "${CMAKE_BINARY_DIR}\\tests\\$<CONFIG>\\server.exe")
38-
else()
39-
set(CLIENT_BINARY "${CMAKE_BINARY_DIR}/tests/client")
40-
set(SERVER_BINARY "${CMAKE_BINARY_DIR}/tests/server")
41-
endif()
42-
4333
add_custom_target(connect-test DEPENDS client)
4434

4535
# For WIN32 when using dynamic linking we need to put the .dll
@@ -58,8 +48,8 @@ add_custom_command(
5848
TARGET connect-test
5949
POST_BUILD
6050
COMMAND
61-
${CMAKE_COMMAND} -E env RUSTLS_PLATFORM_VERIFIER=1 ${CLIENT_BINARY}
62-
example.com 443 /
51+
${CMAKE_COMMAND} -E env RUSTLS_PLATFORM_VERIFIER=1
52+
"$<TARGET_FILE:client>" example.com 443 /
6353
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
6454
)
6555

@@ -79,9 +69,9 @@ add_custom_command(
7969
TARGET integration-test
8070
POST_BUILD
8171
COMMAND
82-
${CMAKE_COMMAND} -E env CLIENT_BINARY=${CLIENT_BINARY} ${CMAKE_COMMAND}
83-
-E env SERVER_BINARY=${SERVER_BINARY} cargo test --locked
84-
${CARGO_FEATURES} "$<IF:$<CONFIG:Release>,--release,>" --test
72+
${CMAKE_COMMAND} -E env CLIENT_BINARY="$<TARGET_FILE:client>"
73+
${CMAKE_COMMAND} -E env SERVER_BINARY="$<TARGET_FILE:server>" cargo test
74+
--locked ${CARGO_FEATURES} "$<IF:$<CONFIG:Release>,--release,>" --test
8575
client_server client_server_integration -- --ignored --exact
8676
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
8777
)

0 commit comments

Comments
 (0)