Skip to content

Commit

Permalink
cmake: use $<TARGET_FILE:xxx> for binaries
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cpu committed Dec 12, 2024
1 parent 8b38738 commit 43ce352
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions cmake/rust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ add_custom_target(
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)

# The location/names of the example binaries change based on platform, and
# in the case of WIN32, by the Config.
if(WIN32)
set(CLIENT_BINARY "${CMAKE_BINARY_DIR}\\tests\\$<CONFIG>\\client.exe")
set(SERVER_BINARY "${CMAKE_BINARY_DIR}\\tests\\$<CONFIG>\\server.exe")
else()
set(CLIENT_BINARY "${CMAKE_BINARY_DIR}/tests/client")
set(SERVER_BINARY "${CMAKE_BINARY_DIR}/tests/server")
endif()

add_custom_target(connect-test DEPENDS client)

# For WIN32 when using dynamic linking we need to put the .dll
Expand All @@ -58,8 +48,8 @@ add_custom_command(
TARGET connect-test
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E env RUSTLS_PLATFORM_VERIFIER=1 ${CLIENT_BINARY}
example.com 443 /
${CMAKE_COMMAND} -E env RUSTLS_PLATFORM_VERIFIER=1
"$<TARGET_FILE:client>" example.com 443 /
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)

Expand All @@ -79,9 +69,9 @@ add_custom_command(
TARGET integration-test
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E env CLIENT_BINARY=${CLIENT_BINARY} ${CMAKE_COMMAND}
-E env SERVER_BINARY=${SERVER_BINARY} cargo test --locked
${CARGO_FEATURES} "$<IF:$<CONFIG:Release>,--release,>" --test
${CMAKE_COMMAND} -E env CLIENT_BINARY="$<TARGET_FILE:client>"
${CMAKE_COMMAND} -E env SERVER_BINARY="$<TARGET_FILE:server>" cargo test
--locked ${CARGO_FEATURES} "$<IF:$<CONFIG:Release>,--release,>" --test
client_server client_server_integration -- --ignored --exact
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)

0 comments on commit 43ce352

Please sign in to comment.