Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows CMakeLists.txt can be optimized #14

Open
yanshouwang opened this issue Apr 16, 2022 · 0 comments
Open

Windows CMakeLists.txt can be optimized #14

yanshouwang opened this issue Apr 16, 2022 · 0 comments

Comments

@yanshouwang
Copy link

This project opened my mind a lot, it's very helpful for us to use dart:ffi on all platforms.
But after some tests I found the windows' CMakeLists.txt is seems worng when bundle OpenCV library

target_compile_definitions(${PLUGIN_NAME} PRIVATE
  OpenCV_DLL_NAME=
  $<$<CONFIG:Debug>:${OpenCV_DEBUG_DLL_NAME}>
  $<$<CONFIG:Profile>:${OpenCV_RELEASE_DLL_NAME}>
  $<$<CONFIG:Release>:${OpenCV_RELEASE_DLL_NAME}>
)

I am not familiar with CMake syntax but this seems not correct, it's just defined a OpenCV_DLL_NAME= macro and will bundle the whole OpenCV bin folder to the flutter windows build folder with ${_OpenCV_LIB_PATH}/${OpenCV_DLL_NAME}

After some research, I found a better way to bundle the OpenCV dll

get_target_property(OPENCV_DLL_DEBUG opencv_world IMPORTED_LOCATION_DEBUG)
get_target_property(OPENCV_DLL_RELEASE opencv_world IMPORTED_LOCATION_RELEASE)

set(OPENCV_DLL
  $<$<CONFIG:Debug>:${OPENCV_DLL_DEBUG}>
  $<$<CONFIG:Profile>:${OPENCV_DLL_RELEASE}>
  $<$<CONFIG:Release>:${OPENCV_DLL_RELEASE}>
)

# List of absolute paths to libraries that should be bundled with the plugin
set(opencv_bundled_libraries
  ""
  ${OPENCV_DLL}
  PARENT_SCOPE
)

We can use this to avoid define OpenCV dll name in the CMakeLists.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant