Consider avoid use of non-standard cmake find methods
aborzunov opened this issue · comments
Consider avoid use of non-standard cmake find methods with fallback to vendored dependency in favour of find_package(PNG)
Expected Behavior
Cmake scripts should use only find_package
. Provide dedicated cmake option to compile with vendored dependency.
Current Behavior
Non-standard find_libpng
fails and silently build libpng
with vendored zlib with wrong version, notwithstanding the fact, that we provided libpng
1.6.37 compiled with zlib 1.2.12 and compatible zlib
1.2.12.
Steps to Reproduce
- 19.23:
- Github Release page: 19.23
- macOS, Clang (M1/arm64):
- Clang: 13.0/12.0:
I'm not sure what you mean. dlib's cmake script uses find_package(PNG QUIET)
to find libpng. Only if that fails does the fallback happen.
Actually, it uses include(cmake_utils/find_libpng.cmake)
to find libpng here:
if (DLIB_PNG_SUPPORT)
include(cmake_utils/find_libpng.cmake)
if (PNG_FOUND)
include_directories(${PNG_INCLUDE_DIR})
set (dlib_needed_libraries ${dlib_needed_libraries} ${PNG_LIBRARIES})
else()
# If we can't find libpng then statically compile it in.
include_directories(external/libpng external/zlib)
set(source_files ${source_files}
Apparently, it works on default combination of OS/compiler/... but fails on non-default, whereas package manager provide dependencies that can be found using FindLibpng.cmake
script in build directory using CMake find_package
method.
I also don't get what you mean: include(cmake_utils/find_libpng.cmake)
uses the “standard” find_package(PNG QUIET)
Sorry, my fault. Didn't examine cmake_utils/find_libpng.cmake
. Indeed, issue is senseless in this wording.
Thanks.