Commit 1e2fba30 by Antonio Maiorano

CMake: make submodule initialization work for add_subdirectory(SwiftShader)

Pass "-C ${SWIFTSHADER_DIR}" to the git submodule command so that it executes from the SwiftShader directory, and not CMAKE_CURRENT_SOURCE, which will be an outer directory. Also, make sure to always check if one target from the submodule already exists to allow parent projects to add their own version. Also: * Refactor submodule init code into function(InitSubmodule) * Only download libbacktrace if REACTOR_EMIT_DEBUG_INFO is enabled * Add downloads of json and cppdap if SWIFTSHADER_BUILD_CPPDAP is enabled Bug: b/145758253 Change-Id: I3bd3f3fcb7f7190f052d2e6f144468bffa0c79da Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43951 Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 8772b42a
...@@ -184,58 +184,45 @@ set(TESTS_DIR ${SWIFTSHADER_DIR}/tests) ...@@ -184,58 +184,45 @@ set(TESTS_DIR ${SWIFTSHADER_DIR}/tests)
# Initialize submodules # Initialize submodules
########################################################### ###########################################################
if (SWIFTSHADER_BUILD_TESTS) function(InitSubmodule target submodule_dir)
if (NOT TARGET gtest) if (NOT TARGET ${target})
if(NOT EXISTS ${THIRD_PARTY_DIR}/googletest/.git) if(NOT EXISTS ${submodule_dir}/.git)
message(WARNING " message(WARNING "
googletest submodule missing. Target ${target} from submodule ${submodule_dir} missing.
Running 'git submodule update --init' to download it: Running 'git submodule update --init' to download it:
") ")
execute_process(COMMAND git submodule update --init ${THIRD_PARTY_DIR}/googletest) execute_process(COMMAND git -C ${SWIFTSHADER_DIR} submodule update --init ${submodule_dir})
endif() endif()
endif() endif()
endfunction()
if (SWIFTSHADER_BUILD_TESTS)
InitSubmodule(gtest ${THIRD_PARTY_DIR}/googletest)
endif() endif()
if(SWIFTSHADER_BUILD_BENCHMARKS) if(SWIFTSHADER_BUILD_BENCHMARKS)
if (NOT TARGET benchmark::benchmark) InitSubmodule(benchmark::benchmark ${THIRD_PARTY_DIR}/benchmark)
if(NOT EXISTS ${THIRD_PARTY_DIR}/benchmark/.git) endif()
message(WARNING "
benchmark submodule missing.
Running 'git submodule update --init' to download it:
")
execute_process(COMMAND git submodule update --init ${THIRD_PARTY_DIR}/benchmark)
endif()
endif()
endif(SWIFTSHADER_BUILD_BENCHMARKS)
if (NOT TARGET libbacktrace)
if(NOT EXISTS ${THIRD_PARTY_DIR}/libbacktrace/src/.git)
message(WARNING "
libbacktrace/src submodule missing.
Running 'git submodule update --init' to download it:
")
execute_process(COMMAND git submodule update --init ${THIRD_PARTY_DIR}/libbacktrace) if(REACTOR_EMIT_DEBUG_INFO)
endif() InitSubmodule(libbacktrace ${THIRD_PARTY_DIR}/libbacktrace/src)
endif() endif()
if(SWIFTSHADER_GET_PVR) if(SWIFTSHADER_GET_PVR)
if(NOT EXISTS ${THIRD_PARTY_DIR}/PowerVR_Examples/.git) InitSubmodule(PVRCore ${THIRD_PARTY_DIR}/PowerVR_Examples)
message(WARNING "
PowerVR_Examples submodule missing.
Running 'git submodule update --init' to download it:
")
execute_process(COMMAND git submodule update --init ${THIRD_PARTY_DIR}/PowerVR_Examples)
endif()
set(SWIFTSHADER_GET_PVR FALSE CACHE BOOL "Check out the PowerVR submodule" FORCE) set(SWIFTSHADER_GET_PVR FALSE CACHE BOOL "Check out the PowerVR submodule" FORCE)
endif() endif()
if(EXISTS ${THIRD_PARTY_DIR}/PowerVR_Examples/.git) if(EXISTS ${THIRD_PARTY_DIR}/PowerVR_Examples/.git)
set(HAVE_PVR_SUBMODULE TRUE) set(HAVE_PVR_SUBMODULE TRUE)
endif() endif()
if(SWIFTSHADER_BUILD_CPPDAP)
InitSubmodule(json ${THIRD_PARTY_DIR}/json)
InitSubmodule(cppdap ${THIRD_PARTY_DIR}/cppdap)
endif()
########################################################### ###########################################################
# Convenience macros # Convenience macros
########################################################### ###########################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment