summaryrefslogtreecommitdiffstats
path: root/cmake/FindWrapSystemPNG.cmake
blob: cff160ad04eb9cf624c8cb0e8c8286fca1be26ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# We can't create the same interface imported target multiple times, CMake will complain if we do
# that. This can happen if the find_package call is done in multiple different subdirectories.
if(TARGET WrapSystemPNG::WrapSystemPNG)
    set(WrapSystemPNG_FOUND ON)
    return()
endif()

set(WrapSystemPNG_FOUND OFF)

find_package(PNG QUIET)

if(PNG_FOUND)
    set(potential_target_names PNG::PNG)
    foreach(target_name ${potential_target_names})
        if(TARGET ${target_name})
            set(WrapSystemPNG_FOUND ON)
            set(final_target_name ${target_name})

            add_library(WrapSystemPNG::WrapSystemPNG INTERFACE IMPORTED)
            target_link_libraries(WrapSystemPNG::WrapSystemPNG INTERFACE
                                  ${final_target_name})

            break()
        endif()
    endforeach()
endif()