find_package method

I build a opencv library and put it on D:/TEST/opencv/release
opencv structure like this

HOW TO build it successfully

method 1
On the cmakelist.txt

find_package(OpenCV REQUIRED PATHS "D:/TEST/opencv/release" NO_DEFAULT_PATH)

method 2
set windows environment path
On the cmakelist.txt

find_package(OpenCV REQUIRED)

method 3
visual studio 2019
How can I do with visual studio 2019 to set the path?

If I have many library,how can I manage the path?
Should I export them with windows env or hard code on cmakelist.
Do you have the suggest tool?

It looks like it is already built. I presume you’re asking how to use it.

Method 2 is what I’d recommend though munging with the environment is unnecessary; just set OpenCV_DIR in the UI or pass it on the command line. VS2019 shouldn’t be any different than anything else.

CMake doesn’t really provide much help for PATH itself. You can discover DLLs with file(GET_RUNTIME_DEPENDENCIES), the $<TARGET_RUNTIME_DLLS> genex, or by crafting PATH as needed manually.

I already test it for some days.But I dont find any tutorial for cmake project to assign lib path. I always get the answer that you can use vcpkg.
If you know how to assign it with vs2019, thank you a lot.

I think VS2019 probably has somewhere in its property panels to add PATH entries when using the Run menu, but I don’t use it enough to be of much guidance beyond that, sorry.