Skip to content

Commit fa092d7

Browse files
committed
cmake: Clean up deps
Signed-off-by: Ryan Pavlik <[email protected]>
1 parent 86bf0a6 commit fa092d7

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

src/CMakeLists.txt

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,28 @@ set(CMAKE_CXX_STANDARD 14)
2020
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2121
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2222

23-
# All options defined here
23+
### Dependencies
24+
find_package(OpenGL)
25+
if(OPENGL_FOUND)
26+
add_definitions(-DXR_USE_GRAPHICS_API_OPENGL)
27+
elseif(BUILD_ALL_EXTENSIONS)
28+
message(FATAL_ERROR "OpenGL not found")
29+
endif()
30+
31+
if(NOT CMAKE_VERSION VERSION_LESS 3.7.0)
32+
# Find the Vulkan headers
33+
find_package(VulkanHeaders)
34+
find_package(Vulkan)
35+
endif()
36+
if(VulkanHeaders_FOUND)
37+
add_definitions(-DXR_USE_GRAPHICS_API_VULKAN)
38+
elseif(BUILD_ALL_EXTENSIONS)
39+
message(FATAL_ERROR "Vulkan headers not found")
40+
endif()
41+
42+
find_package(JsonCpp)
43+
44+
### All options defined here
2445
option(BUILD_LOADER "Build loader" ON)
2546
option(BUILD_ALL_EXTENSIONS "Build loader and layers with all extensions" OFF)
2647
option(BUILD_LOADER_WITH_EXCEPTION_HANDLING "Enable exception handling in the loader. Leave this on unless your standard library is built to not throw." ON)
@@ -40,7 +61,6 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/conformance" AND NOT CMAKE_SYSTEM_NAME ST
4061
endif()
4162
include(CMakeDependentOption)
4263

43-
find_package(JsonCpp)
4464
cmake_dependent_option(BUILD_WITH_SYSTEM_JSONCPP "Use system jsoncpp instead of vendored source" ON
4565
"JSONCPP_FOUND" OFF)
4666

@@ -75,23 +95,6 @@ elseif( PRESENTATION_BACKEND MATCHES "wayland" )
7595
set(BUILD_CONFORMANCE_TESTS OFF)
7696
endif()
7797

78-
# Enable graphics API available to the build.
79-
if (NOT CMAKE_VERSION VERSION_LESS 3.7.0)
80-
# Find the Vulkan headers
81-
find_package(VulkanHeaders)
82-
if (VulkanHeaders_FOUND)
83-
add_definitions(-DXR_USE_GRAPHICS_API_VULKAN)
84-
endif()
85-
# Find the Vulkan loader.
86-
find_package(Vulkan)
87-
# To use simply include ${Vulkan_LIBRARY} in your target_link_library or
88-
# wherever you normally link your library files to your target.
89-
endif()
90-
91-
if (BUILD_ALL_EXTENSIONS AND NOT VulkanHeaders_FOUND)
92-
message(FATAL_ERROR "Vulkan headers not found")
93-
endif()
94-
9598
# Find glslc shader compiler.
9699
# On Android, the NDK includes the binary, so no external dependency.
97100
if(ANDROID)
@@ -134,13 +137,6 @@ function(compile_glsl run_target_name)
134137

135138
endfunction()
136139

137-
find_package(OpenGL)
138-
if (OPENGL_FOUND)
139-
add_definitions(-DXR_USE_GRAPHICS_API_OPENGL)
140-
elseif(BUILD_ALL_EXTENSIONS)
141-
message(FATAL_ERROR "OpenGL not found")
142-
endif()
143-
144140
if(WIN32)
145141
add_definitions(-DXR_USE_GRAPHICS_API_D3D11)
146142
add_definitions(-DXR_USE_GRAPHICS_API_D3D12)

0 commit comments

Comments
 (0)