summaryrefslogtreecommitdiffstats
path: root/cmake/FindWrapSystemPNG.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/FindWrapSystemPNG.cmake')
-rw-r--r--cmake/FindWrapSystemPNG.cmake27
1 files changed, 27 insertions, 0 deletions
diff --git a/cmake/FindWrapSystemPNG.cmake b/cmake/FindWrapSystemPNG.cmake
new file mode 100644
index 0000000000..cff160ad04
--- /dev/null
+++ b/cmake/FindWrapSystemPNG.cmake
@@ -0,0 +1,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()
+