From df950995e8fb6cfdb6619ea89452835e77a82737 Mon Sep 17 00:00:00 2001 From: Zhi Guan Date: Sun, 2 Jun 2024 13:15:32 +0800 Subject: [PATCH] Update tlcp_commands.cmake --- cmake/tlcp_commands.cmake | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/cmake/tlcp_commands.cmake b/cmake/tlcp_commands.cmake index 3c2d141b..8f2e7eb3 100644 --- a/cmake/tlcp_commands.cmake +++ b/cmake/tlcp_commands.cmake @@ -15,22 +15,39 @@ if(NOT EXISTS enckey.pem) message(FATAL_ERROR "file does not exist") endif() -execute_process( - COMMAND bash -c "sudo nohup bin/gmssl tlcp_server -port 4433 -cert tlcp_server_certs.pem -key signkey.pem -pass P@ssw0rd -ex_key enckey.pem -ex_pass P@ssw0rd > tlcp_server.log 2>&1 &" - RESULT_VARIABLE SERVER_RESULT - TIMEOUT 5 -) +if(WIN32) + execute_process( + COMMAND cmd /c "start /B bin\\gmssl tlcp_server -port 4433 -cert tlcp_server_certs.pem -key signkey.pem -pass P@ssw0rd -ex_key enckey.pem -ex_pass P@ssw0rd > tlcp_server.log 2>&1" + RESULT_VARIABLE SERVER_RESULT + TIMEOUT 5 + ) +else() + execute_process( + COMMAND bash -c "sudo nohup bin/gmssl tlcp_server -port 4433 -cert tlcp_server_certs.pem -key signkey.pem -pass P@ssw0rd -ex_key enckey.pem -ex_pass P@ssw0rd > tlcp_server.log 2>&1 &" + RESULT_VARIABLE SERVER_RESULT + TIMEOUT 5 + ) +endif() if(NOT ${SERVER_RESULT} EQUAL 0) message(FATAL_ERROR "server failed to start") endif() execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 2) -execute_process( - COMMAND bash -c "bin/gmssl tlcp_client -host localhost -port 4433 -cacert rootcacert.pem > tlcp_client.log 2>&1" - RESULT_VARIABLE CLIENT_RESULT - TIMEOUT 5 -) + +if (WIN32) + execute_process( + COMMAND cmd /c "start /B bin\\gmssl tlcp_client -host localhost -port 4433 -cacert rootcacert.pem > tlcp_client.log 2>&1" + RESULT_VARIABLE CLIENT_RESULT + TIMEOUT 5 + ) +else() + execute_process( + COMMAND bash -c "bin/gmssl tlcp_client -host localhost -port 4433 -cacert rootcacert.pem > tlcp_client.log 2>&1" + RESULT_VARIABLE CLIENT_RESULT + TIMEOUT 5 + ) +endif() file(READ "tlcp_client.log" CLIENT_LOG_CONTENT) string(FIND "${CLIENT_LOG_CONTENT}" "Connection established" FOUND_INDEX)