From 79ba5d9c260ca4e2890b8e9c9efd79e3df5fe763 Mon Sep 17 00:00:00 2001 From: Alexandre Bouvier Date: Thu, 12 Oct 2023 16:36:26 +0200 Subject: cmake: prefer system stb headers --- CMakeModules/Findstb.cmake | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 CMakeModules/Findstb.cmake (limited to 'CMakeModules/Findstb.cmake') diff --git a/CMakeModules/Findstb.cmake b/CMakeModules/Findstb.cmake new file mode 100644 index 000000000..bff998580 --- /dev/null +++ b/CMakeModules/Findstb.cmake @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: 2023 Alexandre Bouvier +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_path(stb_image_INCLUDE_DIR stb_image.h PATH_SUFFIXES stb) +find_path(stb_image_resize_INCLUDE_DIR stb_image_resize.h PATH_SUFFIXES stb) +find_path(stb_image_write_INCLUDE_DIR stb_image_write.h PATH_SUFFIXES stb) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(stb + REQUIRED_VARS + stb_image_INCLUDE_DIR + stb_image_resize_INCLUDE_DIR + stb_image_write_INCLUDE_DIR +) + +if (stb_FOUND AND NOT TARGET stb::headers) + add_library(stb::headers INTERFACE IMPORTED) + set_property(TARGET stb::headers PROPERTY + INTERFACE_INCLUDE_DIRECTORIES + "${stb_image_INCLUDE_DIR}" + "${stb_image_resize_INCLUDE_DIR}" + "${stb_image_write_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced( + stb_image_INCLUDE_DIR + stb_image_resize_INCLUDE_DIR + stb_image_write_INCLUDE_DIR +) -- cgit v1.2.3