Skip to content

Commit 94a1e62

Browse files
committed
fix(CMakeLists): update RabbitMQ DLL copy logic for Windows and ensure server-enabled definition is set
1 parent 845446c commit 94a1e62

1 file changed

Lines changed: 8 additions & 29 deletions

File tree

src/NeTrainSimServer/CMakeLists.txt

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ target_link_libraries(${NETRAINSIM_SERVER_NAME} PRIVATE
5353
# Include Container library
5454
target_include_directories(${NETRAINSIM_CORE_NAME} PRIVATE ${CONTAINER_INCLUDE_DIRS})
5555
target_compile_definitions(${NETRAINSIM_CORE_NAME} PRIVATE BUILD_SERVER_ENABLED)
56+
target_compile_definitions(${NETRAINSIM_SERVER_NAME} PRIVATE BUILD_SERVER_ENABLED)
5657

5758
# Conditionally link Qt6Keychain if available for secure password storage
5859
if(Qt6Keychain_FOUND)
@@ -93,35 +94,13 @@ add_custom_command(TARGET ${NETRAINSIM_SERVER_NAME} POST_BUILD
9394
$<TARGET_FILE:Container::Container> $<TARGET_FILE_DIR:${NETRAINSIM_SERVER_NAME}> # Copy container.dll
9495
)
9596

96-
# Ensure the NeTrainSim DLL is copied to the output directory
97-
if(CMAKE_BUILD_TYPE STREQUAL "Release")
98-
if(WIN32)
99-
# Copy Windows DLLs in Release mode
100-
add_custom_command(TARGET ${NETRAINSIM_SERVER_NAME} POST_BUILD
101-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
102-
"${CONTAINER_BIN_DIR}/container.dll"
103-
"$<TARGET_FILE_DIR:${NETRAINSIM_SERVER_NAME}>/container.dll"
104-
)
105-
add_custom_command(TARGET ${NETRAINSIM_SERVER_NAME} POST_BUILD
106-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
107-
"${RABBITMQ_BIN_DIR}/rabbitmq.4.dll"
108-
"$<TARGET_FILE_DIR:${NETRAINSIM_SERVER_NAME}>/rabbitmq.4.dll"
109-
)
110-
endif()
111-
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
112-
if(WIN32)
113-
# Copy Windows debug DLLs
114-
add_custom_command(TARGET ${NETRAINSIM_SERVER_NAME} POST_BUILD
115-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
116-
"${CONTAINER_BIN_DIR}/containerd.dll"
117-
"$<TARGET_FILE_DIR:${NETRAINSIM_SERVER_NAME}>/containerd.dll"
118-
)
119-
add_custom_command(TARGET ${NETRAINSIM_SERVER_NAME} POST_BUILD
120-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
121-
"${RABBITMQ_BIN_DIR}/rabbitmq.4.dll"
122-
"$<TARGET_FILE_DIR:${NETRAINSIM_SERVER_NAME}>/rabbitmq.4.dll"
123-
)
124-
endif()
97+
# Copy RabbitMQ DLL to the output directory
98+
if(WIN32 AND DEFINED RABBITMQ_SHRD_LIB_DIR)
99+
add_custom_command(TARGET ${NETRAINSIM_SERVER_NAME} POST_BUILD
100+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
101+
"${RABBITMQ_SHRD_LIB_DIR}/rabbitmq.4.dll"
102+
"$<TARGET_FILE_DIR:${NETRAINSIM_SERVER_NAME}>/rabbitmq.4.dll"
103+
)
125104
endif()
126105

127106

0 commit comments

Comments
 (0)