Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User-friendly skip component warning #165

Merged
merged 5 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cmake/IgnConfigureBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ macro(ign_configure_build)
#============================================================================
# Print warnings and errors
if(build_warnings)
message(WARNING "-- BUILD WARNINGS")
set(all_warnings " CONFIGURATION WARNINGS:")
foreach (msg ${build_warnings})
message(WARNING "-- ${msg}")
ign_string_append(all_warnings " -- ${msg}" DELIM "\n")
endforeach ()
message(WARNING "-- END BUILD WARNINGS\n")
message(WARNING "${all_warnings}")
endif (build_warnings)

if(build_errors)
Expand Down Expand Up @@ -191,7 +191,7 @@ macro(ign_configure_build)
# Add the source code directories of each component if they exist
foreach(component ${ign_configure_build_COMPONENTS})

if(NOT SKIP_${component})
if(NOT SKIP_${component} AND NOT INTERNAL_SKIP_${component})

set(found_${component}_src FALSE)

Expand Down Expand Up @@ -255,7 +255,9 @@ macro(ign_configure_build)
else()

set(skip_msg "Skipping the component [${component}]")
if(${component}_MISSING_DEPS)
if(SKIP_${component})
mxgrey marked this conversation as resolved.
Show resolved Hide resolved
ign_string_append(skip_msg "by user request")
mxgrey marked this conversation as resolved.
Show resolved Hide resolved
elseif(${component}_MISSING_DEPS)
ign_string_append(skip_msg "because the following packages are missing: ${${component}_MISSING_DEPS}")
mxgrey marked this conversation as resolved.
Show resolved Hide resolved
endif()

Expand Down
25 changes: 15 additions & 10 deletions cmake/IgnUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ macro(ign_find_package PACKAGE_NAME)

#------------------------------------
# Construct the warning/error message to produce
set(${PACKAGE_NAME}_msg "Missing: ${${PACKAGE_NAME}_pretty}")
set(${PACKAGE_NAME}_msg "Missing dependency [${${PACKAGE_NAME}_pretty}]")

if(ign_find_package_COMPONENTS)
ign_list_to_string(comp_str ign_find_package_COMPONENTS DELIM ", ")
Expand All @@ -219,19 +219,25 @@ macro(ign_find_package PACKAGE_NAME)

foreach(component ${ign_find_package_REQUIRED_BY})

# Otherwise, if it was only required by some of the components, create
# a warning about which components will not be available.
ign_build_warning("Cannot build component [${component}] - ${${PACKAGE_NAME}_msg}")
if(NOT SKIP_${component})
# Otherwise, if it was only required by some of the components, create
# a warning about which components will not be available, unless the
# user explicitly requested that it be skipped
ign_build_warning("Skipping component [${component}]: ${${PACKAGE_NAME}_msg}.\n ^~~~~ Set SKIP_${component}=true in cmake to suppress this warning.\n ")

# Also create a variable to indicate that we should skip the component
set(SKIP_${component} true)
# Create a variable to indicate that we need to skip the component
set(INTERNAL_SKIP_${component} true)

ign_string_append(${component}_MISSING_DEPS "${${PACKAGE_NAME}_pretty}" DELIM ", ")
# Track the missing dependencies
ign_string_append(${component}_MISSING_DEPS "${${PACKAGE_NAME}_pretty}" DELIM ", ")
endif()

endforeach()

else()
ign_build_warning(${${PACKAGE_NAME}_msg})
if(NOT ign_find_package_QUIET)
mxgrey marked this conversation as resolved.
Show resolved Hide resolved
ign_build_warning(${${PACKAGE_NAME}_msg})
endif()
endif()

endif()
Expand Down Expand Up @@ -771,8 +777,7 @@ endmacro(ign_build_error)
# ign_build_warning macro
macro(ign_build_warning)
foreach(str ${ARGN})
set(msg "\t${str}" )
list(APPEND build_warnings ${msg})
list(APPEND build_warnings "${str}")
endforeach(str ${ARGN})
endmacro(ign_build_warning)

Expand Down