smasherprog / screen_capture_lite

cross platform screen/window capturing library
MIT License
616 stars 156 forks source link

generate screen_capture_liteConfig.cmake so that we can use find_package() #145

Closed RandomPrototypes closed 1 year ago

RandomPrototypes commented 1 year ago

Hello, I modified the cmakefiles so that it generates screen_capture_liteConfig.cmake in the install/lib/cmake/screen_capture_lite directory and generate either shared or static instead of both. This allows to embed it more easily in a project by using the find_package function. It only requires to put : find_package(screen_capture_lite REQUIRED) include_directories(${screen_capture_lite_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} ${screen_capture_lite_LIBS})

example of project using it : https://github.com/RandomPrototypes/screen_capture_opencv

smasherprog commented 1 year ago

I like where your going with this...

smasherprog commented 1 year ago

keep up the good work.. Looks good so far!!!

RandomPrototypes commented 1 year ago

Do you prefer having one target "screen_capture_lite" and setting if it's shared or static at build time, or two targets "screen_capture_lite-static" and "screen_capture_lite-shared" that could coexist in the same install folder? The two targets could be built at the same time or disabled by a cmake foag.

In the second case, it means we should use find_package(screen_capture_lite-static REQUIRED) or find_package(screen_capture_lite-shared REQUIRED) when creating a project that depends on screen_capture_lite instead of find_package(screen_capture_lite REQUIRED)

smasherprog commented 1 year ago

Dealers choice. What ever is easier

RandomPrototypes commented 1 year ago

I switched back to two targets (but only one is built at a time) so the modification is smaller and the tests don't need to be modified. The windows tests still have a problem, I'll look at it later.

An external project would use : find_package(screen_capture_lite_shared REQUIRED) or find_package(screen_capture_lite_static REQUIRED)

RandomPrototypes commented 1 year ago

It seems to build properly on every platform based on the automatic tests, but I only tried to run it on linux. If the flag BUILD_SHARED_LIBS is ON, it will build the target screen_capture_lite_shared. If it's OFF, it will build the target screen_capture_lite_static and only build the cpp parts (I think C# can only work with the shared, right?). I think the automatic tests only tried to build the shared (default) target, maybe it would be good to add the static target to the build.

smasherprog commented 1 year ago

Looks great to me! I love this PR