if (TARGET catch2)
    message("Catch2 already defined, assuming this is from an external  include")
else (TARGET catch2)

    include(CheckIncludeFileCXX)

    find_package(Catch2)
    find_package(catch2-with-main)
    if (Catch2_FOUND)
        message("external catch")
        check_include_file_cxx("catch.hpp" HAS_CATCH_HPP -I/usr/include/catch2)
        check_include_file_cxx("catch_all.hpp" HAS_CATCH_ALL_HPP -I/usr/include/catch2)

        if (TARGET Catch2::Catch2WithMain)
            add_library(catch2_test INTERFACE)
            target_include_directories(catch2_test INTERFACE "/usr/include/catch2")
            target_link_libraries(catch2_test INTERFACE Catch2::Catch2WithMain)
        elseif (TARGET Catch2::Catch2)
            add_library(catch2_test INTERFACE)
            target_include_directories(catch2_test INTERFACE "/usr/include/catch2")
            target_link_libraries(catch2_test INTERFACE Catch2::Catch2)
        else ()
            message("No catch2 target")
        endif(TARGET Catch2::Catch2)

        if ("${HAS_CATCH_ALL_HPP}" AND (NOT "${HAS_CATCH_HPP}"))
            message("Adding transitional include")
            target_include_directories(catch2_test INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/transitional")
        endif ("${HAS_CATCH_ALL_HPP}" AND (NOT "${HAS_CATCH_HPP}"))
    else (Catch2)
        message("internal catch")
        add_library(catch2_test INTERFACE)
        target_include_directories(catch2_test INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
    endif(Catch2_FOUND)
endif(TARGET catch2)