@@ -11,8 +11,18 @@ target_link_libraries(write_and_read_streams
1111 arrow-testing-data
1212)
1313
14+ # Create executable for the deserializer_example
15+ add_executable (deserializer_example deserializer_example.cpp)
16+
17+ # Link against sparrow-ipc and its dependencies
18+ target_link_libraries (deserializer_example
19+ PRIVATE
20+ sparrow-ipc
21+ sparrow::sparrow
22+ )
23+
1424# Set C++ standard to match the main project
15- set_target_properties (write_and_read_streams
25+ set_target_properties (write_and_read_streams deserializer_example
1626 PROPERTIES
1727 CXX_STANDARD 20
1828 CXX_STANDARD_REQUIRED ON
@@ -26,8 +36,15 @@ target_include_directories(write_and_read_streams
2636 ${CMAKE_BINARY_DIR} /generated
2737)
2838
39+ target_include_directories (deserializer_example
40+ PRIVATE
41+ ${CMAKE_SOURCE_DIR} /include
42+ ${CMAKE_BINARY_DIR} /generated
43+ )
44+
2945# Ensure generated flatbuffer headers are available
3046add_dependencies (write_and_read_streams generate_flatbuffers_headers)
47+ add_dependencies (deserializer_example generate_flatbuffers_headers)
3148
3249# Optional: Copy to build directory for easy execution
3350if (WIN32 )
@@ -38,7 +55,7 @@ if(WIN32)
3855 set (ZSTD_DLL_TARGET libzstd_static)
3956 endif ()
4057
41- # On Windows, copy required DLLs
58+ # On Windows, copy required DLLs for write_and_read_streams
4259 set (DLL_COPY_COMMANDS "" ) # Initialize a list to hold all copy commands
4360 # Add unconditional copy commands
4461 list (APPEND DLL_COPY_COMMANDS
@@ -66,6 +83,31 @@ if(WIN32)
6683 ${DLL_COPY_COMMANDS}
6784 COMMENT "Copying required DLLs to example executable directory"
6885 )
86+
87+ # On Windows, copy required DLLs for deserializer_example
88+ set (DLL_COPY_COMMANDS_DESER "" ) # Initialize a list to hold all copy commands
89+ list (APPEND DLL_COPY_COMMANDS_DESER
90+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
91+ "$<TARGET_FILE:sparrow::sparrow>"
92+ "$<TARGET_FILE_DIR:deserializer_example>"
93+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
94+ "$<TARGET_FILE:sparrow-ipc>"
95+ "$<TARGET_FILE_DIR:deserializer_example>"
96+ )
97+
98+ if (ZSTD_DLL_TARGET)
99+ list (APPEND DLL_COPY_COMMANDS_DESER
100+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
101+ "$<TARGET_FILE:${ZSTD_DLL_TARGET} >"
102+ "$<TARGET_FILE_DIR:deserializer_example>"
103+ )
104+ endif ()
105+
106+ add_custom_command (
107+ TARGET deserializer_example POST_BUILD
108+ ${DLL_COPY_COMMANDS_DESER}
109+ COMMENT "Copying required DLLs to deserializer_example executable directory"
110+ )
69111endif ()
70112
71113# Create a custom target to easily run the example
@@ -77,3 +119,13 @@ add_custom_target(run_example
77119)
78120
79121set_target_properties (run_example PROPERTIES FOLDER "Examples" )
122+
123+ # Create a custom target to run the deserializer example
124+ add_custom_target (run_deserializer_example
125+ COMMAND deserializer_example
126+ DEPENDS deserializer_example
127+ COMMENT "Running deserializer_example"
128+ USES_TERMINAL
129+ )
130+
131+ set_target_properties (run_deserializer_example PROPERTIES FOLDER "Examples" )
0 commit comments