Enable Tint as part of a larger CMake project

- Add googletest and spirv-tools local builds only if their CMake targets
  are not already configured.
- Add local spirv-headers as an include directory only if the associated
  CMake directory does not already point to a directory.

Change-Id: I53ebb0d8fdf7703e8219000b78c75c30859c91a4
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/24020
Reviewed-by: dan sinclair <dsinclair@google.com>
This commit is contained in:
David Neto 2020-06-26 22:29:27 +00:00 committed by dan sinclair
parent d4eafb631d
commit 5b46d71ae7
2 changed files with 23 additions and 14 deletions

View File

@ -81,6 +81,7 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR
set(COMPILER_IS_LIKE_GNU TRUE) set(COMPILER_IS_LIKE_GNU TRUE)
endif() endif()
if(${TINT_BUILD_DOCS})
find_package(Doxygen) find_package(Doxygen)
if(DOXYGEN_FOUND) if(DOXYGEN_FOUND)
add_custom_target(tint-docs ALL add_custom_target(tint-docs ALL
@ -90,7 +91,8 @@ if(DOXYGEN_FOUND)
VERBATIM) VERBATIM)
else() else()
message("Doxygen not found. Skipping documentation") message("Doxygen not found. Skipping documentation")
endif() endif(DOXYGEN_FOUND)
endif(TINT_BUILD_DOCS)
if(MSVC) if(MSVC)
# We don't want to have to copy the C Runtime DLL everywhere the executable # We don't want to have to copy the C Runtime DLL everywhere the executable

View File

@ -12,10 +12,17 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
if (NOT TARGET gmock)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL)
endif()
if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER}) if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
if (NOT IS_DIRECTORY "${SPIRV-Headers_SOURCE_DIR}")
set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers CACHE STRING "") set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers CACHE STRING "")
endif()
if (NOT TARGET SPIRV-Tools)
set(SPIRV_SKIP_TESTS ON CACHE BOOL ON) set(SPIRV_SKIP_TESTS ON CACHE BOOL ON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools)
endif() endif()
endif()