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)
endif()
find_package(Doxygen)
if(DOXYGEN_FOUND)
add_custom_target(tint-docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation"
VERBATIM)
else()
message("Doxygen not found. Skipping documentation")
endif()
if(${TINT_BUILD_DOCS})
find_package(Doxygen)
if(DOXYGEN_FOUND)
add_custom_target(tint-docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation"
VERBATIM)
else()
message("Doxygen not found. Skipping documentation")
endif(DOXYGEN_FOUND)
endif(TINT_BUILD_DOCS)
if(MSVC)
# 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
# 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})
set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers CACHE STRING "")
set(SPIRV_SKIP_TESTS ON CACHE BOOL ON)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools)
if (NOT IS_DIRECTORY "${SPIRV-Headers_SOURCE_DIR}")
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)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools)
endif()
endif()