Skip to content

Commit d197bdd

Browse files
committed
Use vcpkg for stb dependency with FetchContent fallback
1 parent f8162f3 commit d197bdd

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

cmake/stb.cmake

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
# STB single-file public domain libraries for image encoding
33
# https://github.com/nothings/stb
44

5-
FetchContent_Declare(
6-
stb
7-
GIT_REPOSITORY https://github.com/nothings/stb.git
8-
GIT_TAG master # Could pin to specific commit for stability
9-
GIT_SHALLOW TRUE
10-
)
5+
find_package(Stb CONFIG QUIET)
116

12-
FetchContent_MakeAvailable(stb)
7+
if(NOT Stb_FOUND)
8+
include(FetchContent)
9+
FetchContent_Declare(
10+
stb
11+
GIT_REPOSITORY https://github.com/nothings/stb.git
12+
GIT_TAG 5c205738c191bcb0abc65c4febfa9bd25ff35234
13+
)
1314

14-
# Create interface library for stb headers
15-
add_library(stb INTERFACE)
16-
target_include_directories(stb INTERFACE ${stb_SOURCE_DIR})
15+
FetchContent_MakeAvailable(stb)
1716

17+
add_library(stb INTERFACE)
18+
target_include_directories(stb INTERFACE ${stb_SOURCE_DIR})
19+
endif()

vcpkg.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"builtin-baseline": "b02e341c927f16d991edbd915d8ea43eac52096c",
44
"dependencies": [
55
"zlib",
6-
"ffmpeg"
6+
"ffmpeg",
7+
"stb"
78
]
89
}

0 commit comments

Comments
 (0)