Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conditional compilation Shapes Demo Windows #262

Merged
merged 4 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions examples/ShapesDemo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ if(NOT UCLIENT_BUILD_EXAMPLES)
find_package(microxrcedds_client REQUIRED)
endif()

if(NOT UCLIENT_PROFILE_UDP OR
NOT UCLIENT_PROFILE_TCP OR
NOT UCLIENT_PROFILE_SERIAL)
set(BUILD_EXAMPLE TRUE)

if(WIN32 AND (NOT UCLIENT_PROFILE_UDP OR
NOT UCLIENT_PROFILE_TCP))
message(WARNING "Can not compile example: The UCLIENT_PROFILE_UDP and UCLIENT_PROFILE_TCP must be enabled.")
set(BUILD_EXAMPLE FALSE)
elseif(UNIX AND (NOT UCLIENT_PROFILE_UDP OR
NOT UCLIENT_PROFILE_TCP OR NOT UCLIENT_PROFILE_SERIAL))
message(WARNING "Can not compile example: The UCLIENT_PROFILE_UDP, UCLIENT_PROFILE_TCP and UCLIENT_PROFILE_SERIAL must be enabled.")
else()
set(BUILD_EXAMPLE FALSE)
endif()

if(BUILD_EXAMPLE)
add_executable(${PROJECT_NAME} main.c ShapeType.c)
if(MSVC OR MSVC_IDE)
target_compile_options(${PROJECT_NAME} PRIVATE /wd4996)
Expand Down
8 changes: 8 additions & 0 deletions examples/ShapesDemo/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,14 @@
// Getting the max MTU at compile time.
#define MAX_UDP_TCP_MTU ((UXR_CONFIG_UDP_TRANSPORT_MTU > \
UXR_CONFIG_TCP_TRANSPORT_MTU) ? UXR_CONFIG_UDP_TRANSPORT_MTU : UXR_CONFIG_UDP_TRANSPORT_MTU)

#ifdef _WIN32
#define MAX_TRANSPORT_MTU MAX_UDP_TCP_MTU
#else
#define MAX_TRANSPORT_MTU ((UXR_CONFIG_SERIAL_TRANSPORT_MTU > \
MAX_UDP_TCP_MTU) ? UXR_CONFIG_SERIAL_TRANSPORT_MTU : MAX_UDP_TCP_MTU)
#endif /* ifdef _WIN32 */


// Stream buffers
#define MAX_HISTORY 16
Expand Down Expand Up @@ -569,7 +575,9 @@ void print_help(
printf("Usage: program --help\n");
printf(" program <transport> [--key <number>] [--history <number>]\n");
printf("List of available transports:\n");
#ifndef _WIN32
printf(" --serial <device>\n");
#endif /* ifmdef _WIN32 */
printf(" --udp4 <agent-ip> <agent-port>\n");
printf(" --udp6 <agent-ip> <agent-port>\n");
printf(" --tcp4 <agent-ip> <agent-port>\n");
Expand Down