{"action":"created","issue":{"url":"https://api.github.com/repos/Itseez/opencv/issues/5264","labels_url":"https://api.github.com/repos/Itseez/opencv/issues/5264/labels{/name}","comments_url":"https://api.github.com/repos/Itseez/opencv/issues/5264/comments","events_url":"https://api.github.com/repos/Itseez/opencv/issues/5264/events","html_url":"https://github.com/Itseez/opencv/issues/5264","id":103565545,"number":5264,"title":"OpenCV 3.0 links to both Debug and Release external ZLIB library on Windows","user":{"login":"willyd","id":628693,"avatar_url":"https://avatars.githubusercontent.com/u/628693?v=3","gravatar_id":"","url":"https://api.github.com/users/willyd","html_url":"https://github.com/willyd","followers_url":"https://api.github.com/users/willyd/followers","following_url":"https://api.github.com/users/willyd/following{/other_user}","gists_url":"https://api.github.com/users/willyd/gists{/gist_id}","starred_url":"https://api.github.com/users/willyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willyd/subscriptions","organizations_url":"https://api.github.com/users/willyd/orgs","repos_url":"https://api.github.com/users/willyd/repos","events_url":"https://api.github.com/users/willyd/events{/privacy}","received_events_url":"https://api.github.com/users/willyd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Itseez/opencv/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/Itseez/opencv/labels/category:%20build/install","name":"category: build/install","color":"ededed"},{"url":"https://api.github.com/repos/Itseez/opencv/labels/priority:%20normal","name":"priority: normal","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-08-27T18:16:40Z","updated_at":"2015-08-31T19:11:18Z","closed_at":null,"body":"Hi, I am trying to build OpenCV on Windows and using my own ZLIB library with my own FindZLIB module. My FindZLIB module does:\r\n```CMake\r\nset(ZLIB_LIBRARIES optimized ${ZLIB_LIBRARY} debug ${ZLIB_LIBRARY_DEBUG})\r\n```\r\nhowever line 469 in [OpenCVModule.cmake](https://github.com/Itseez/opencv/blob/3.0.0/cmake/OpenCVModule.cmake) messes up the libraries order. This makes opencv_core depend on both the debug and release libraries of ZLIB and any consuming project that uses OpenCV's exported targets link to both release and debug versions of ZLIB.\r\n\r\nI thought of three possible solutions:\r\n\r\n* Append `${ZLIB_LIBRARIES}` to the `extra_libs` when `BUILD_ZLIB=OFF` instead of passing it to ocv_add_module.\r\n* Preprocess the `OPENCV_MODULE_${m}_DEPS_EXT` list to merge together the keyword and the library so that a list like:\r\n```CMake\r\ndebug;c:/path/to/zlibd.lib;optimized;c:/path/to/zlib.lib\r\n```\r\nbecomes\r\n```CMake\r\n\"debug c:/path/to/zlibd.lib\";\"optimized c:/path/to/zlib.lib\"\r\n```\r\nand then split the merged list elements after.\r\n* Or, after `find_package(ZLIB)` succeeds create an imported target named `OpenCV::ZLIB` from the debug and optimized libraries and use `set(ZLIB_LIBRARIES OpenCV::ZLIB)`. And then extract the proper Release and Debug libs before linking `if(${ZLIB_LIBRARIES} EQUAL OpenCV::ZLIB)`.\r\n\r\nAll solutions seem a bit hackish. Is there a proper way of handling this use case?\r\n"},"comment":{"url":"https://api.github.com/repos/Itseez/opencv/issues/comments/136471263","html_url":"https://github.com/Itseez/opencv/issues/5264#issuecomment-136471263","issue_url":"https://api.github.com/repos/Itseez/opencv/issues/5264","id":136471263,"user":{"login":"willyd","id":628693,"avatar_url":"https://avatars.githubusercontent.com/u/628693?v=3","gravatar_id":"","url":"https://api.github.com/users/willyd","html_url":"https://github.com/willyd","followers_url":"https://api.github.com/users/willyd/followers","following_url":"https://api.github.com/users/willyd/following{/other_user}","gists_url":"https://api.github.com/users/willyd/gists{/gist_id}","starred_url":"https://api.github.com/users/willyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willyd/subscriptions","organizations_url":"https://api.github.com/users/willyd/orgs","repos_url":"https://api.github.com/users/willyd/repos","events_url":"https://api.github.com/users/willyd/events{/privacy}","received_events_url":"https://api.github.com/users/willyd/received_events","type":"User","site_admin":false},"created_at":"2015-08-31T19:11:18Z","updated_at":"2015-08-31T19:11:18Z","body":"static"}}