Skip to content

Commit

Permalink
Add a conditional build to only build the examples if the Windows pla…
Browse files Browse the repository at this point in the history
…tform is detected
  • Loading branch information
shishir-bytebeam committed Sep 30, 2024
1 parent 31ed053 commit ec50f91
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,38 +53,38 @@ set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build mbed TLS shared library.")
add_subdirectory(external/mbedtls)
target_link_libraries(bytebeam_firmware_sdk mbedtls mbedx509 mbedcrypto)

# examples/
# Install rules for SDK and example
install(TARGETS bytebeam_firmware_sdk
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)

# Build the examples if host is Windows
if(WIN32)
set(PLATFORM_SOURCES platform/Win32/platform_win32_port.c)

target_include_directories(bytebeam_firmware_sdk PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/platform/Win32
${CMAKE_CURRENT_SOURCE_DIR}/portable
${CMAKE_CURRENT_SOURCE_DIR}/include/bytebeam
)
else()
set(PLATFORM_SOURCES "")
endif()

# Create an example executable for bytebeam_stream_publish
add_executable(bytebeam_stream_publish
examples/bytebeam_stream_publish.c
${PLATFORM_SOURCES}
)
add_executable(bytebeam_stream_publish
examples/bytebeam_stream_publish.c
${PLATFORM_SOURCES}
)

# Link the example with the SDK library
target_link_libraries(bytebeam_stream_publish bytebeam_firmware_sdk)
target_link_libraries(bytebeam_stream_publish bytebeam_firmware_sdk)

# Set the output directory for the example executable
set_target_properties(bytebeam_stream_publish PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/examples"
)
set_target_properties(bytebeam_stream_publish PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/examples"
)

# Install rules for SDK and example
install(TARGETS bytebeam_firmware_sdk
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
install(TARGETS bytebeam_stream_publish
RUNTIME DESTINATION bin
)
install(TARGETS bytebeam_stream_publish
RUNTIME DESTINATION bin
)

else()
set(PLATFORM_SOURCES "")
endif()

0 comments on commit ec50f91

Please sign in to comment.