Skip to content

Commit ff46d14

Browse files
authored
build: allow auto-build of just requried packages (#4927)
The CMake (or env) variable OpenImageIO_BUILD_MISSING_DEPS enumerates dependencies to try to locally auto-build if not found. If set to "all", it will build them all. This patch also allows you to set it to "required", which will try to auto-build any missing dependences that are required, but not bother with non-required missing packages. It also works to use required and also have list items naming additional optional dependencies, such as -DOpenImageIO_BUILD_MISSING_DEPS="required;WebP" build all required dependecies, and also WebP (which is optional), if they are no found already installed. Signed-off-by: Larry Gritz <[email protected]>
1 parent 2ccad14 commit ff46d14

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/cmake/dependency_utils.cmake

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ set_option (${PROJECT_NAME}_ALWAYS_PREFER_CONFIG
1111
"Prefer a dependency's exported config file if it's available" OFF)
1212

1313
set_cache (${PROJECT_NAME}_BUILD_MISSING_DEPS ""
14-
"Try to download and build any of these missing dependencies (or 'all')")
14+
"Try to download and build any of these missing dependencies (or 'all' or 'required')")
1515
set_cache (${PROJECT_NAME}_BUILD_LOCAL_DEPS ""
1616
"Force local builds of these dependencies if possible (or 'all')")
1717

@@ -123,6 +123,8 @@ function (print_package_notfound_report)
123123
message (STATUS " ${_pkg}")
124124
endforeach ()
125125
message (STATUS "${ColorBoldWhite}To build them automatically if not found, build again with option:${ColorReset}")
126+
message (STATUS " ${ColorBoldGreen}-D${PROJECT_NAME}_BUILD_MISSING_DEPS=required${ColorReset}")
127+
message (STATUS " or")
126128
message (STATUS " ${ColorBoldGreen}-D${PROJECT_NAME}_BUILD_MISSING_DEPS=all${ColorReset}")
127129
endif ()
128130
message (STATUS)
@@ -321,7 +323,9 @@ macro (checked_find_package pkgname)
321323
set (_pkg_BUILD_LOCAL "always")
322324
elseif ("${pkgname}" IN_LIST ${PROJECT_NAME}_BUILD_MISSING_DEPS
323325
OR ${PROJECT_NAME}_BUILD_MISSING_DEPS STREQUAL "ALL"
324-
OR ${PROJECT_NAME}_BUILD_MISSING_DEPS STREQUAL "all")
326+
OR ${PROJECT_NAME}_BUILD_MISSING_DEPS STREQUAL "all"
327+
OR ("required" IN_LIST ${PROJECT_NAME}_BUILD_MISSING_DEPS
328+
AND _pkg_REQUIRED))
325329
set_if_not (_pkg_BUILD_LOCAL "missing")
326330
endif ()
327331
set (${pkgname}_local_build_script "${PROJECT_SOURCE_DIR}/src/cmake/build_${pkgname}.cmake")
@@ -611,7 +615,7 @@ macro (build_dependency_with_cmake pkgname)
611615
list (APPEND ${pkgname}_GIT_CLONE_ARGS --depth 1)
612616
endif ()
613617
if (_pkg_QUIET OR "${_pkg_QUIET}" STREQUAL "")
614-
list (APPEND ${pkgname}_GIT_CLONE_ARGS -q)
618+
list (APPEND ${pkgname}_GIT_CLONE_ARGS -q ERROR_VARIABLE ${pkgname}_clone_errors)
615619
set (_pkg_exec_quiet OUTPUT_QUIET)
616620
endif ()
617621

0 commit comments

Comments
 (0)