Skip to content

Commit

Permalink
[cmake] Check for deps before adding.
Browse files Browse the repository at this point in the history
When embedding SwitftShader into a third party application, the top
level cmake files may already include googletest and SPIRV-Tools. This
CL updates the SwiftShader tests to only try to pull in googletest if
the `gtest` target is not found and only pull in SPIRV-Tools if the
`SPIRV-Tools` target is not found.

Change-Id: I3c3ebb528725017dbbb80aa05b01ee2de8d4a2d1
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/26788
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Dan Sinclair <dsinclair@google.com>
  • Loading branch information
dj2 committed Mar 13, 2019
1 parent 25ec7b0 commit 6480d4e
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions CMakeLists.txt
Expand Up @@ -109,13 +109,15 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Initialize submodules
###########################################################

if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/.git)
message(WARNING "
third_party/googletest submodule missing.
Running 'git submodule update --init' to download it:
")

execute_process(COMMAND git submodule update --init)
if (NOT TARGET gtest)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/.git)
message(WARNING "
third_party/googletest submodule missing.
Running 'git submodule update --init' to download it:
")

execute_process(COMMAND git submodule update --init)
endif()
endif()

###########################################################
Expand Down Expand Up @@ -2234,11 +2236,13 @@ if(BUILD_GLES_CM)
endif()

if(BUILD_VULKAN)
# This variable is also used by SPIRV-Tools to locate SPIRV-Headers
set(SPIRV-Headers_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SPIRV-Headers")
list(APPEND VULKAN_INCLUDE_DIR "${SPIRV-Headers_SOURCE_DIR}/include")
if (NOT TARGET SPIRV-Tools)
# This variable is also used by SPIRV-Tools to locate SPIRV-Headers
set(SPIRV-Headers_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SPIRV-Headers")
list(APPEND VULKAN_INCLUDE_DIR "${SPIRV-Headers_SOURCE_DIR}/include")

add_subdirectory(third_party/SPIRV-Tools)
add_subdirectory(third_party/SPIRV-Tools)
endif()

add_library(libvk_swiftshader SHARED ${VULKAN_LIST})
set_target_properties(libvk_swiftshader PROPERTIES
Expand Down

0 comments on commit 6480d4e

Please sign in to comment.