Skip to content

Commit

Permalink
Adjust variable and function namings
Browse files Browse the repository at this point in the history
  • Loading branch information
zchrissirhcz committed Nov 23, 2024
1 parent ee8c169 commit 24a82b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cmake -S . -B build -G "Visual Studio 17 2022" -A x64

[rocbuild.cmake](rocbuild.cmake) is a set of functions/macros for daily building opeorations:
- copy dlls for recursive shared dependencies
- copy OpenCV's videoio dlls
- copy OpenCV's videoio plugin dlls
- enable Ninja colorful output by default
- use `CMAKE_BINARY_DIR` as output location for artifacts: `.a/.lib/.dll/.so/.exe/...`
- more fuctionalities to be added...
Expand Down
22 changes: 11 additions & 11 deletions rocbuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ endfunction()


# Scan opencv_videoio dlls and copy them to the target executable's folder
function(rocbuild_copy_opencv_videoio_plugin_dll target)
function(rocbuild_copy_opencv_videoio_plugin_dlls target)
# Sanity checks
if(CMAKE_CROSSCOMPILING OR (NOT WIN32))
return()
endif()

if(NOT TARGET ${target})
message(WARNING "rocbuild_copy_opencv_videoio_plugin_dll() was called with a non-target: ${target}")
message(WARNING "rocbuild_copy_opencv_videoio_plugin_dlls() was called with a non-target: ${target}")
return()
endif()

get_target_property(TYPE ${target} TYPE)
if(NOT ${TYPE} STREQUAL "EXECUTABLE")
message(WARNING "rocbuild_copy_opencv_videoio_plugin_dll() was called on a non-executable target: ${target}")
message(WARNING "rocbuild_copy_opencv_videoio_plugin_dlls() was called on a non-executable target: ${target}")
return()
endif()

Expand All @@ -87,23 +87,23 @@ function(rocbuild_copy_opencv_videoio_plugin_dll target)
set(COPY_SCRIPT_CONTENT "")

if(EXISTS "${OpenCV_DIR}/bin")
set(opencv_videoio_dll_dir "${OpenCV_DIR}/bin")
set(opencv_videoio_plugin_dll_dir "${OpenCV_DIR}/bin")
elseif(EXISTS "${OpenCV_DIR}/../bin")
set(opencv_videoio_dll_dir "${OpenCV_DIR}/../bin")
set(opencv_videoio_plugin_dll_dir "${OpenCV_DIR}/../bin")
else()
message(WARNING "Could not find opencv_videoio dlls in ${OpenCV_DIR}/bin or ${OpenCV_DIR}/../bin")
message(WARNING "Could not find opencv videoio plugin dlls in ${OpenCV_DIR}/bin or ${OpenCV_DIR}/../bin")
return()
endif()

file(REAL_PATH "${opencv_videoio_dll_dir}" opencv_videoio_dll_dir)
file(GLOB opencv_videoio_dlls "${opencv_videoio_dll_dir}/opencv_videoio_*.dll")
file(REAL_PATH "${opencv_videoio_plugin_dll_dir}" opencv_videoio_plugin_dll_dir)
file(GLOB opencv_videoio_plugin_dlls "${opencv_videoio_plugin_dll_dir}/opencv_videoio_*.dll")

# convert opencv_videoio_dlls to a string
string(REPLACE ";" "\n" opencv_videoio_dlls "${opencv_videoio_dlls}")
string(REPLACE ";" "\n" opencv_videoio_plugin_dlls "${opencv_videoio_plugin_dlls}")

string(APPEND COPY_SCRIPT_CONTENT
"set(opencv_videoio_dlls\n${opencv_videoio_dlls}\n)\n"
"foreach(file IN ITEMS \${opencv_videoio_dlls})\n"
"set(opencv_videoio_plugin_dlls\n${opencv_videoio_plugin_dlls}\n)\n"
"foreach(file IN ITEMS \${opencv_videoio_plugin_dlls})\n"
" if(EXISTS \"\${file}\")\n"
" execute_process(COMMAND \${CMAKE_COMMAND} -E copy_if_different \"\${file}\" \"$<TARGET_FILE_DIR:${target}>\")\n"
" endif()\n"
Expand Down

0 comments on commit 24a82b3

Please sign in to comment.