Do you mean that I need to set(BUILD_opencv_world ON) in my CMakeLists.txt? Why it is "opencv"_word? Should I modify it as my project name? For example set(BUILD_helloworld_world ON). Can CMake recognize the BUILD_helloworld_world variable?
You mentioned the variable in the original post. Or was this a hypothetical switch you would use to do this? OpenCV needs to support this natively as an option; it’s not trivial to “just combine DLLs”, especially on Windows.
When opencv builds with BUILD_opencv_world set to on, its basically using a single link line to generate the shared library vs multiple link lines.
The easiest way to accomplish what you are doing, would be to follow the same pattern.
Typically, the easiest way to generate a DLL on windows, is you create a an “EXPORT/IMPORT” macro that precedes each symbol being exported
When your library generation is being compiled and reads the header for the library function, the macro is set to declspec(export), when the executable or another library is reading the header its set to declspec(import)
You likely have multiple of these macros, one for each shared library. You will have to modify the macro logic so its defined as external for the logic of “Am I building the unified DLL or my single DLL then export, otherwise import”
Then from a CMake POV, you need to do a couple of things when this flag is turned on.
set the compiler flag
Generate static libraries where previously shared libraries were created
Create a new target shared library, that linked in all the static libraries