diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake index fdb251090939f7a55f066c8923a68233738fb471..80a82041d15c2be2713707698a899ce5588818e0 100644 --- a/cmake/modules/SearchInstalledSoftware.cmake +++ b/cmake/modules/SearchInstalledSoftware.cmake @@ -42,10 +42,14 @@ if(NOT builtin_zlib) foreach(suffix FOUND INCLUDE_DIR LIBRARY LIBRARY_DEBUG LIBRARY_RELEASE) unset(ZLIB_${suffix} CACHE) endforeach() - find_package(ZLIB) - if(NOT ZLIB_FOUND) - message(STATUS "Zlib not found. Switching on builtin_zlib option") - set(builtin_zlib ON CACHE BOOL "Enabled because Zlib not found (${builtin_zlib_description})" FORCE) + if(fail-on-missing) + find_package(ZLIB REQUIRED) + else() + find_package(ZLIB) + if(NOT ZLIB_FOUND) + message(STATUS "Zlib not found. Switching on builtin_zlib option") + set(builtin_zlib ON CACHE BOOL "Enabled because Zlib not found (${builtin_zlib_description})" FORCE) + endif() endif() endif()