From 98fcd14142c4ceb7c16bf0488be7b08f9bdfe68c Mon Sep 17 00:00:00 2001 From: memorylorry Date: Sat, 24 Aug 2024 22:52:17 +0800 Subject: [PATCH] Properly use cmake variable in ONNXRuntime (#15776) Co-authored-by: UltralyticsAssistant --- examples/YOLOv8-ONNXRuntime-CPP/CMakeLists.txt | 3 +++ examples/YOLOv8-ONNXRuntime-CPP/README.md | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/examples/YOLOv8-ONNXRuntime-CPP/CMakeLists.txt b/examples/YOLOv8-ONNXRuntime-CPP/CMakeLists.txt index 86232ccb4f..a99662a511 100644 --- a/examples/YOLOv8-ONNXRuntime-CPP/CMakeLists.txt +++ b/examples/YOLOv8-ONNXRuntime-CPP/CMakeLists.txt @@ -49,6 +49,9 @@ elseif (APPLE) # set(ONNXRUNTIME_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime-osx-x64-${ONNXRUNTIME_VERSION}") # Apple Universal binary # set(ONNXRUNTIME_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime-osx-universal2-${ONNXRUNTIME_VERSION}") +else () + message(SEND_ERROR "Variable ONNXRUNTIME_ROOT is not set properly. Please check if your cmake project \ + is not compiled with `-D WIN32=TRUE`, `-D LINUX=TRUE`, or `-D APPLE=TRUE`!") endif () include_directories(${PROJECT_NAME} ${ONNXRUNTIME_ROOT}/include) diff --git a/examples/YOLOv8-ONNXRuntime-CPP/README.md b/examples/YOLOv8-ONNXRuntime-CPP/README.md index 1a27ce7237..ed9d936429 100644 --- a/examples/YOLOv8-ONNXRuntime-CPP/README.md +++ b/examples/YOLOv8-ONNXRuntime-CPP/README.md @@ -82,6 +82,19 @@ Note (2): Due to ONNX Runtime, we need to use CUDA 11 and cuDNN 8. Keep in mind cmake .. ``` + **Notice**: + + If you encounter an error indicating that the `ONNXRUNTIME_ROOT` variable is not set correctly, you can resolve this by building the project using the appropriate command tailored to your system. + + ```console + # compiled in a win32 system + cmake -D WIN32=TRUE .. + # compiled in a linux system + cmake -D LINUX=TRUE .. + # compiled in an apple system + cmake -D APPLE=TRUE .. + ``` + 5. Build the project: ```console