Skip to content

Commit 67a28b9

Browse files
committed
Restrict vcpkg dependencies to Windows platform and improve CMake module path handling
Add platform specifiers to all vcpkg dependencies and enable vulkan feature for ktx. Move CMAKE_MODULE_PATH configuration before project() call to ensure custom find modules are prioritized. Update all Find modules to use _find_package when available for better vcpkg integration. Add vcpkg CONFIG mode support to Findstb.cmake. Remove trailing whitespace.
1 parent de6f1ad commit 67a28b9

15 files changed

Lines changed: 108 additions & 29 deletions

attachments/CMake/FindKTX.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
#
1515

1616
# Try to find the package using CONFIG mode first (e.g., from vcpkg)
17-
find_package(ktx CONFIG QUIET)
17+
if(COMMAND _find_package)
18+
_find_package(ktx CONFIG QUIET)
19+
else()
20+
find_package(ktx CONFIG QUIET)
21+
endif()
1822

1923
if(ktx_FOUND)
2024
if(NOT TARGET KTX::ktx AND TARGET ktx::ktx)

attachments/CMake/Findglm.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
#
1414

1515
# Try to find the package using CONFIG mode first (e.g., from vcpkg)
16-
find_package(glm CONFIG QUIET)
16+
if(COMMAND _find_package)
17+
_find_package(glm CONFIG QUIET)
18+
else()
19+
find_package(glm CONFIG QUIET)
20+
endif()
1721

1822
if(glm_FOUND)
1923
if(NOT TARGET glm::glm AND TARGET glm)

attachments/CMake/Findnlohmann_json.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
#
1414

1515
# Try to find the package using CONFIG mode first (e.g., from vcpkg)
16-
find_package(nlohmann_json CONFIG QUIET)
16+
if(COMMAND _find_package)
17+
_find_package(nlohmann_json CONFIG QUIET)
18+
else()
19+
find_package(nlohmann_json CONFIG QUIET)
20+
endif()
1721

1822
if(nlohmann_json_FOUND)
1923
if(NOT TARGET nlohmann_json::nlohmann_json AND TARGET nlohmann_json)

attachments/CMake/Findstb.cmake

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@
1212
# stb::stb
1313
#
1414

15+
# Try to find the package using CONFIG mode first (e.g., from vcpkg)
16+
if(COMMAND _find_package)
17+
_find_package(stb CONFIG QUIET)
18+
else()
19+
find_package(stb CONFIG QUIET)
20+
endif()
21+
22+
if(stb_FOUND)
23+
if(NOT TARGET stb::stb AND TARGET stb)
24+
add_library(stb::stb ALIAS stb)
25+
endif()
26+
return()
27+
endif()
28+
1529
# Try to find the package using pkg-config first
1630
find_package(PkgConfig QUIET)
1731
if(PKG_CONFIG_FOUND)
@@ -67,7 +81,7 @@ endif()
6781

6882
# Set the variables
6983
include(FindPackageHandleStandardArgs)
70-
find_package_handle_standard_args(stb
84+
find_package_handle_standard_args(stb
7185
REQUIRED_VARS stb_INCLUDE_DIR
7286
)
7387

@@ -83,4 +97,4 @@ if(stb_FOUND)
8397
endif()
8498
endif()
8599

86-
mark_as_advanced(stb_INCLUDE_DIR)
100+
mark_as_advanced(stb_INCLUDE_DIR)

attachments/CMake/Findtinygltf.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
#
1414

1515
# Try to find the package using CONFIG mode first (e.g., from vcpkg)
16-
find_package(tinygltf CONFIG QUIET)
16+
if(COMMAND _find_package)
17+
_find_package(tinygltf CONFIG QUIET)
18+
else()
19+
find_package(tinygltf CONFIG QUIET)
20+
endif()
1721

1822
if(tinygltf_FOUND)
1923
if(NOT TARGET tinygltf::tinygltf AND TARGET tinygltf)
@@ -23,7 +27,11 @@ if(tinygltf_FOUND)
2327
endif()
2428

2529
# First, try to find nlohmann_json
26-
find_package(nlohmann_json QUIET)
30+
if(COMMAND _find_package)
31+
_find_package(nlohmann_json QUIET)
32+
else()
33+
find_package(nlohmann_json QUIET)
34+
endif()
2735
if(NOT nlohmann_json_FOUND)
2836
include(FetchContent)
2937
message(STATUS "nlohmann_json not found, fetching v3.12.0 from GitHub...")

attachments/CMake/Findtinyobjloader.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
# tinyobjloader::tinyobjloader
1111

1212
# Try to find the package using CONFIG mode first (e.g., from vcpkg)
13-
find_package(tinyobjloader CONFIG QUIET)
13+
if(COMMAND _find_package)
14+
_find_package(tinyobjloader CONFIG QUIET)
15+
else()
16+
find_package(tinyobjloader CONFIG QUIET)
17+
endif()
1418

1519
if(tinyobjloader_FOUND)
1620
if(NOT TARGET tinyobjloader::tinyobjloader AND TARGET tinyobjloader)

attachments/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required (VERSION 3.29)
22

3+
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
4+
35
# vcpkg integration
46
if(WIN32)
57
# By default, we disable manifest mode to ensure compatibility with all vcpkg installations,
@@ -11,8 +13,6 @@ endif()
1113

1214
project (VulkanTutorial)
1315

14-
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
15-
1616
# Add option to enable/disable C++ 20 module
1717
option(ENABLE_CPP20_MODULE "Enable C++ 20 module support for Vulkan" OFF)
1818

attachments/simple_engine/CMake/FindKTX.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
#
1515

1616
# Try to find the package using CONFIG mode first (e.g., from vcpkg)
17-
find_package(ktx CONFIG QUIET)
17+
if(COMMAND _find_package)
18+
_find_package(ktx CONFIG QUIET)
19+
else()
20+
find_package(ktx CONFIG QUIET)
21+
endif()
1822

1923
if(ktx_FOUND)
2024
if(NOT TARGET KTX::ktx AND TARGET ktx::ktx)

attachments/simple_engine/CMake/Findglm.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
#
1414

1515
# Try to find the package using CONFIG mode first (e.g., from vcpkg)
16-
find_package(glm CONFIG QUIET)
16+
if(COMMAND _find_package)
17+
_find_package(glm CONFIG QUIET)
18+
else()
19+
find_package(glm CONFIG QUIET)
20+
endif()
1721

1822
if(glm_FOUND)
1923
if(NOT TARGET glm::glm AND TARGET glm)

attachments/simple_engine/CMake/Findnlohmann_json.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
#
1414

1515
# Try to find the package using CONFIG mode first (e.g., from vcpkg)
16-
find_package(nlohmann_json CONFIG QUIET)
16+
if(COMMAND _find_package)
17+
_find_package(nlohmann_json CONFIG QUIET)
18+
else()
19+
find_package(nlohmann_json CONFIG QUIET)
20+
endif()
1721

1822
if(nlohmann_json_FOUND)
1923
if(NOT TARGET nlohmann_json::nlohmann_json AND TARGET nlohmann_json)

0 commit comments

Comments
 (0)