Browse Source

modules: provide additional info about not found components on CMake 3.16.

pull/11/head
Vladimír Vondruš 5 years ago
parent
commit
b63ae43f1e
  1. 2
      doc/python/pages/changelog.rst
  2. 39
      modules/FindMagnumBindings.cmake

2
doc/python/pages/changelog.rst

@ -46,6 +46,8 @@ Changelog
Python's ``<Python.h>`` Python's ``<Python.h>``
- Applied minor performance fixes suggested by Clang Tidy (see :gh:`mosra/magnum-bindings#10`) - Applied minor performance fixes suggested by Clang Tidy (see :gh:`mosra/magnum-bindings#10`)
- Linux and macOS builds were migrated from Travis to Circle CI - Linux and macOS builds were migrated from Travis to Circle CI
- On CMake 3.16 and newer, `FindMagnumBindings.cmake` can provide additional
details if some component is not found
- The Homebrew package now uses `std_cmake_args` instead of hardcoded build - The Homebrew package now uses `std_cmake_args` instead of hardcoded build
type and install prefix, which resolves certain build issues (see type and install prefix, which resolves certain build issues (see
:gh:`mosra/homebrew-magnum#6`) :gh:`mosra/homebrew-magnum#6`)

39
modules/FindMagnumBindings.cmake

@ -66,6 +66,8 @@ mark_as_advanced(MAGNUMBINDINGS_INCLUDE_DIR)
# Component distinction (listing them explicitly to avoid mistakes with finding # Component distinction (listing them explicitly to avoid mistakes with finding
# components from other repositories) # components from other repositories)
set(_MAGNUMBINDINGS_HEADER_ONLY_COMPONENTS Python) set(_MAGNUMBINDINGS_HEADER_ONLY_COMPONENTS Python)
# Nothing is enabled by default right now
set(_MAGNUMBINDINGS_IMPLICITLY_ENABLED_COMPONENTS )
# No inter-component dependencies right now # No inter-component dependencies right now
@ -83,6 +85,7 @@ foreach(_component ${MagnumBindings_FIND_COMPONENTS})
endforeach() endforeach()
# Join the lists, remove duplicate components # Join the lists, remove duplicate components
set(_MAGNUMBINDINGS_ORIGINAL_FIND_COMPONENTS ${MagnumBindings_FIND_COMPONENTS})
if(_MAGNUMBINDINGS_ADDITIONAL_COMPONENTS) if(_MAGNUMBINDINGS_ADDITIONAL_COMPONENTS)
list(INSERT MagnumBindings_FIND_COMPONENTS 0 ${_MAGNUMBINDINGS_ADDITIONAL_COMPONENTS}) list(INSERT MagnumBindings_FIND_COMPONENTS 0 ${_MAGNUMBINDINGS_ADDITIONAL_COMPONENTS})
endif() endif()
@ -135,7 +138,41 @@ foreach(_component ${MagnumBindings_FIND_COMPONENTS})
endif() endif()
endforeach() endforeach()
# For CMake 3.16+ with REASON_FAILURE_MESSAGE, provide additional potentially
# useful info about the failed components.
if(NOT CMAKE_VERSION VERSION_LESS 3.16)
set(_MAGNUMBINDINGS_REASON_FAILURE_MESSAGE)
# Go only through the originally specified find_package() components, not
# the dependencies added by us afterwards
foreach(_component ${_MAGNUMBINDINGS_ORIGINAL_FIND_COMPONENTS})
if(MagnumBindings_${_component}_FOUND)
continue()
endif()
# If it's not known at all, tell the user -- it might be a new library
# and an old Find module, or something platform-specific.
if(NOT _component IN_LIST _MAGNUMBINDINGS_LIBRARY_COMPONENTS AND NOT _component IN_LIST _MAGNUMBINDINGS_PLUGIN_COMPONENTS)
list(APPEND _MAGNUMBINDINGS_REASON_FAILURE_MESSAGE "${_component} is not a known component on this platform.")
# Otherwise, if it's not among implicitly built components, hint that
# the user may need to enable it
# TODO: currently, the _FOUND variable doesn't reflect if dependencies
# were found. When it will, this needs to be updated to avoid
# misleading messages.
elseif(NOT _component IN_LIST _MAGNUMBINDINGS_IMPLICITLY_ENABLED_COMPONENTS)
string(TOUPPER ${_component} _COMPONENT)
list(APPEND _MAGNUMBINDINGS_REASON_FAILURE_MESSAGE "${_component} is not built by default. Make sure you enabled WITH_${_COMPONENT} when building Magnum Bindings")
# Otherwise we have no idea. Better be silent than to print something
# misleading.
else()
endif()
endforeach()
string(REPLACE ";" " " _MAGNUMBINDINGS_REASON_FAILURE_MESSAGE "${_MAGNUMBINDINGS_REASON_FAILURE_MESSAGE}")
set(_MAGNUMBINDINGS_REASON_FAILURE_MESSAGE REASON_FAILURE_MESSAGE "${_MAGNUMBINDINGS_REASON_FAILURE_MESSAGE}")
endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MagnumBindings find_package_handle_standard_args(MagnumBindings
REQUIRED_VARS MAGNUMBINDINGS_INCLUDE_DIR REQUIRED_VARS MAGNUMBINDINGS_INCLUDE_DIR
HANDLE_COMPONENTS) HANDLE_COMPONENTS
${_MAGNUMBINDINGS_REASON_FAILURE_MESSAGE})

Loading…
Cancel
Save