CMake: Massage CMakeLists for use by NodeJS bindings

Allow the third_party directory to be controlled by the outer sub-project.

Change-Id: I11030c75254c264c1955150bdf1983771b33b614
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/64500
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-09-20 19:47:05 +00:00 committed by Tint LUCI CQ
parent 17720fdec7
commit d1c6f83341
2 changed files with 10 additions and 1 deletions

View File

@ -41,6 +41,14 @@ else()
set(TINT_BUILD_TESTS_DEFAULT ON)
endif()
function (set_if_not_defined name value description)
if(NOT DEFINED ${name})
set(${name} ${value} PARENT_SCOPE)
endif()
endfunction()
set_if_not_defined(TINT_THIRD_PARTY_DIR "${tint_SOURCE_DIR}/third_party" "Directory in which to find third-party dependencies.")
option(TINT_BUILD_SAMPLES "Build samples" ON)
option(TINT_BUILD_DOCS "Build documentation" ${TINT_BUILD_DOCS_DEFAULT})
option(TINT_DOCS_WARN_AS_ERROR "When building documentation, treat warnings as errors" OFF)

View File

@ -35,6 +35,7 @@ if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
if (${TINT_BUILD_SPIRV_TOOLS_FUZZER})
set(SPIRV_BUILD_FUZZER ON CACHE BOOL "Controls whether spirv-fuzz is built" FORCE)
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools EXCLUDE_FROM_ALL)
set(SPIRV-Headers_SOURCE_DIR "${TINT_THIRD_PARTY_DIR}/spirv-headers")
add_subdirectory("${TINT_THIRD_PARTY_DIR}/spirv-tools" "${CMAKE_BINARY_DIR}/third_party/spirv-tools" EXCLUDE_FROM_ALL)
endif()
endif()