fix(CI): cmake: add simple client and server only when source files exist.

This commit is contained in:
Matej Kenda 2024-03-29 15:34:17 +01:00
parent 78c9dd1879
commit 47a4db37e5

View File

@ -12,9 +12,6 @@ POCO_SOURCES_AUTO_PLAT(TEST_SRCS OFF
add_executable(NetSSL-testrunner ${TEST_SRCS}) add_executable(NetSSL-testrunner ${TEST_SRCS})
add_executable(NetSSL-server ${CMAKE_CURRENT_SOURCE_DIR}/ping/websocket-server.cpp)
add_executable(NetSSL-client ${CMAKE_CURRENT_SOURCE_DIR}/ping/websocket-client.cpp)
if(ANDROID) if(ANDROID)
add_test( add_test(
NAME NetSSL NAME NetSSL
@ -36,16 +33,28 @@ else()
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/dhparams.pem ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/dhparams.pem ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/NetSSL-testrunner.xml COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/NetSSL-testrunner.xml
) )
endif()
target_link_libraries(NetSSL-testrunner PUBLIC Poco::NetSSL Poco::Util Poco::XML CppUnit)
add_custom_command(
TARGET NetSSL-server POST_BUILD if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ping/websocket-server.cpp)
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/NetSSL-server.xml add_executable(NetSSL-server ping/websocket-server.cpp)
) target_link_libraries(NetSSL-server PUBLIC Poco::NetSSL Poco::Util)
if (NOT ANDROID)
add_custom_command(
TARGET NetSSL-server POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/NetSSL-server.xml
)
endif()
endif()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/ping/websocket-client.cpp)
add_executable(NetSSL-client ping/websocket-client.cpp)
target_link_libraries(NetSSL-client PUBLIC Poco::NetSSL Poco::Util)
if (NOT ANDROID)
add_custom_command( add_custom_command(
TARGET NetSSL-client POST_BUILD TARGET NetSSL-client POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/NetSSL-client.xml COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/testrunner.xml ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/NetSSL-client.xml
) )
endif()
endif() endif()
target_link_libraries(NetSSL-testrunner PUBLIC Poco::NetSSL Poco::Util Poco::XML CppUnit)
target_link_libraries(NetSSL-server PUBLIC Poco::NetSSL Poco::Util)
target_link_libraries(NetSSL-client PUBLIC Poco::NetSSL Poco::Util)