Skip to content

Commit bdcf39e

Browse files
author
Abdalrahman Ibrahim
committed
fix: use GLOB to robustness check extracted YOLOs-CPP directory
1 parent 46d22cb commit bdcf39e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

CMakeLists.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,20 @@ if(NOT EXISTS "${YOLOS_CPP_DIR}/include/yolos/yolos.hpp")
166166
message(FATAL_ERROR "Failed to extract YOLOs-CPP")
167167
endif()
168168

169-
# Rename extracted folder (usually YOLOs-CPP-master) to standard name
169+
# Find the extracted folder (can vary by branch, e.g. YOLOs-CPP-main or YOLOs-CPP-master)
170+
file(GLOB EXTRACTED_DIRS "${CMAKE_BINARY_DIR}/YOLOs-CPP-*")
171+
if(NOT EXTRACTED_DIRS)
172+
message(FATAL_ERROR "Extraction failed: Could not find YOLOs-CPP-* directory in ${CMAKE_BINARY_DIR}")
173+
endif()
174+
175+
# Use the first match
176+
list(GET EXTRACTED_DIRS 0 EXTRACTED_DIR)
177+
178+
# Remove build dir if it exists from previous run
170179
file(REMOVE_RECURSE "${YOLOS_CPP_DIR}")
171-
file(RENAME "${CMAKE_BINARY_DIR}/YOLOs-CPP-${YOLOS_CPP_VERSION}" "${YOLOS_CPP_DIR}")
180+
181+
# Rename to standard build directory
182+
file(RENAME "${EXTRACTED_DIR}" "${YOLOS_CPP_DIR}")
172183
file(REMOVE "${CMAKE_BINARY_DIR}/yolos_cpp.tar.gz")
173184
endif()
174185

0 commit comments

Comments
 (0)