tomopy/tomopy

View on GitHub
Config.cmake.in

Summary

Maintainability
Test Coverage
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/libtomoTargets.cmake")
set(libtomo_LIBRARIES) # clear variable

foreach(_TARG @libtomo_TARGETS@)
    # there is a check in the build-tree that ensures this is a valid string manip
    string(REPLACE "libtomo::tomo-" "" _TARG_BASIC "${_TARG}")

    if(NOT TARGET ${_TARG})
        # if the target doesn't exist add it to the libtomo_FIND_COMPONENTS
        # and set that it is not found so check_required_components will fail
        list(APPEND libtomo_FIND_COMPONENTS ${_TARG_BASIC})
        set(libtomo_${_TARG_BASIC}_FOUND 0)
    else()
        set(libtomo_${_TARG_BASIC}_FOUND 1)
        if(NOT libtomo_FIND_COMPONENTS)
            # if COMPONENTS are not specified, always add to libtomo_LIBRARIES
            list(APPEND libtomo_LIBRARIES ${_TARG})
        elseif(${_TARG_BASIC} IN_LIST libtomo_FIND_COMPONENTS)
            # if COMPONENTS was specified, add only if in COMPONENTS list
            list(APPEND libtomo_LIBRARIES ${_TARG})
        endif()
    endif()
endforeach()

check_required_components(libtomo)

if(libtomo_FOUND)
    add_library(libtomo::libtomo INTERFACE IMPORTED)
    target_link_libraries(libtomo::libtomo INTERFACE ${libtomo_LIBRARIES})
endif()