Browse Source

Make the Find module usable with a CMake subproject.

pull/2/head
Vladimír Vondruš 7 years ago
parent
commit
daac3ac5f4
  1. 15
      modules/FindMagnumBindings.cmake
  2. 3
      src/CMakeLists.txt

15
modules/FindMagnumBindings.cmake

@ -28,7 +28,7 @@
# #
# Additionally these variables are defined for internal usage: # Additionally these variables are defined for internal usage:
# #
# MAGNUMBINDINGS_*_INCLUDE_DIR - Component include dir (w/o dependencies) # MAGNUMBINDINGS_INCLUDE_DIR - Magnum bindings include dir (w/o dependencies)
# #
# #
@ -58,6 +58,11 @@
find_package(Magnum REQUIRED) find_package(Magnum REQUIRED)
# Global bindings include dir
find_path(MAGNUMBINDINGS_INCLUDE_DIR Magnum
HINTS ${MAGNUMBINDINGS_INCLUDE_DIR})
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_COMPONENT_LIST Python) set(_MAGNUMBINDINGS_HEADER_ONLY_COMPONENT_LIST Python)
@ -93,12 +98,16 @@ foreach(_component ${MagnumBindings_FIND_COMPONENTS})
# Find includes # Find includes
find_path(_MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_DIR find_path(_MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_DIR
NAMES ${_MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_PATH_NAMES} NAMES ${_MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_PATH_NAMES}
HINTS ${MAGNUM_INCLUDE_DIR}) HINTS ${MAGNUMBINDINGS_INCLUDE_DIR})
mark_as_advanced(_MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_DIR) mark_as_advanced(_MAGNUMBINDINGS_${_COMPONENT}_INCLUDE_DIR)
# Link to core Magnum library # Link to core Magnum library
set_property(TARGET MagnumBindings::${_component} APPEND PROPERTY set_property(TARGET MagnumBindings::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Magnum::Magnum) INTERFACE_LINK_LIBRARIES Magnum::Magnum)
# Add bindings incldue dir
set_property(TARGET MagnumBindings::${_component} APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${MAGNUMBINDINGS_INCLUDE_DIR})
endif() endif()
# Decide if the component was found # Decide if the component was found
@ -112,5 +121,5 @@ endforeach()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MagnumBindings find_package_handle_standard_args(MagnumBindings
REQUIRED_VARS MAGNUM_INCLUDE_DIR REQUIRED_VARS MAGNUMBINDINGS_INCLUDE_DIR
HANDLE_COMPONENTS) HANDLE_COMPONENTS)

3
src/CMakeLists.txt

@ -30,3 +30,6 @@ add_subdirectory(Magnum)
if(WITH_PYTHON) if(WITH_PYTHON)
add_subdirectory(python) add_subdirectory(python)
endif() endif()
# Magnum Bindings include dir for superprojects
set(MAGNUMBINDINGS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" FORCE)

Loading…
Cancel
Save