Skip to content
Permalink
Browse files

Safer adding of stb/ suffix to include directory.

  • Loading branch information
rcurtin committed Jan 8, 2020
1 parent 16ee2fa commit 4d782785f97ac8d96e7cd9d24c352ffd58e6c190
Showing with 10 additions and 1 deletion.
  1. +10 −1 CMake/FindStbImage.cmake
@@ -14,7 +14,6 @@ find_path(STB_IMAGE_INCLUDE_DIR

if(STB_IMAGE_INCLUDE_DIR)
set(STB_IMAGE_FOUND YES)
set(STB_IMAGE_INCLUDE_DIR "${STB_IMAGE_INCLUDE_DIR}/stb/")
else ()
find_path(STB_IMAGE_INCLUDE_DIR
NAMES stb_image.h stb_image_write.h
@@ -25,6 +24,16 @@ else ()
endif ()
endif ()

# Make sure that stb/ is the last part of the include directory, if it was
# found.
if (STB_IMAGE_INCLUDE_DIR)
string(REGEX MATCH ".*stb[/]?" STB_INCLUDE_HAS_TRAILING_STB
"${STB_IMAGE_INCLUDE_DIR}")
if (NOT STB_INCLUDE_HAS_TRAILING_STB)
set(STB_IMAGE_INCLUDE_DIR "${STB_IMAGE_INCLUDE_DIR}/stb/")
endif ()
endif ()

# Checks 'REQUIRED'.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(STB_IMAGE

0 comments on commit 4d78278

Please sign in to comment.
You can’t perform that action at this time.