Add cmake build for Emscripten bindings and samples.
- Refactors the simple samples to use a single base so that we can
easily if-def for Emscripten builds.
- Remove #error in Dawn headers when building with Emscripten and
instead redirect to just including the Emscripten header.
- Cmake changes to make the Emscripten build only build the bindings
and samples.
- Add if-defs in some utilities since some texture formats and objects
are not defined in the Emscripten headers.
Bug: 346806934
Change-Id: Iec99fd4c0ce9d425973eddb553e926189c61dead
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/198614
Commit-Queue: Loko Kung <lokokung@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 11910b9..db54015 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -47,6 +47,36 @@
)
endif ()
+################################################################################
+# Start of Emscripten enabled third party directories
+# To minimize the number of third party targets to make when building with
+# Emscripten to the minimal set, only subdirectories added within the Start
+# and End of the Emscripten block are enabled .
+################################################################################
+
+if (NOT TARGET absl::strings)
+ # Recommended setting for compability with future abseil releases.
+ set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE)
+ message(STATUS "Dawn: using Abseil at ${DAWN_ABSEIL_DIR}")
+ if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR
+ ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"))
+ add_compile_options(
+ -Wno-array-parameter
+ -Wno-deprecated-builtins
+ -Wno-unknown-warning-option
+ )
+ endif()
+
+ add_subdirectory(${DAWN_ABSEIL_DIR} "${CMAKE_CURRENT_BINARY_DIR}/abseil")
+endif()
+
+################################################################################
+# End of Emscripten enabled third party directories
+################################################################################
+if (${DAWN_ENABLE_EMSCRIPTEN})
+ return()
+endif()
+
if (NOT TARGET SPIRV-Headers)
set(SPIRV_HEADERS_SKIP_EXAMPLES ON CACHE BOOL "" FORCE)
set(SPIRV_HEADERS_SKIP_INSTALL ON CACHE BOOL "" FORCE)
@@ -94,22 +124,6 @@
add_subdirectory(${DAWN_GLFW_DIR} "${CMAKE_CURRENT_BINARY_DIR}/glfw")
endif()
-if (NOT TARGET absl::strings)
- # Recommended setting for compability with future abseil releases.
- set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE)
- message(STATUS "Dawn: using Abseil at ${DAWN_ABSEIL_DIR}")
- if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR
- ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"))
- add_compile_options(
- -Wno-array-parameter
- -Wno-deprecated-builtins
- -Wno-unknown-warning-option
- )
- endif()
-
- add_subdirectory(${DAWN_ABSEIL_DIR} "${CMAKE_CURRENT_BINARY_DIR}/abseil")
-endif()
-
if (DAWN_BUILD_PROTOBUF AND NOT TARGET libprotobuf-mutator)
message(STATUS "Dawn: using LPM at ${DAWN_LPM_DIR}")
include("libprotobuf-mutator/BUILD.cmake")