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,16 +81,18 @@ if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") OR
set(COMPILER_IS_LIKE_GNU TRUE) set(COMPILER_IS_LIKE_GNU TRUE)
endif() endif()
find_package(Doxygen) if(${TINT_BUILD_DOCS})
if(DOXYGEN_FOUND) find_package(Doxygen)
add_custom_target(tint-docs ALL if(DOXYGEN_FOUND)
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile add_custom_target(tint-docs ALL
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
COMMENT "Generating API documentation" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM) COMMENT "Generating API documentation"
else() VERBATIM)
message("Doxygen not found. Skipping documentation") else()
endif() message("Doxygen not found. Skipping documentation")
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.
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL) if (NOT TARGET gmock)
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})
set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers CACHE STRING "") if (NOT IS_DIRECTORY "${SPIRV-Headers_SOURCE_DIR}")
set(SPIRV_SKIP_TESTS ON CACHE BOOL ON) set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers CACHE STRING "")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools) endif()
if (NOT TARGET SPIRV-Tools)
set(SPIRV_SKIP_TESTS ON CACHE BOOL ON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools)
endif()
endif() endif()