Fix clean CMake builds

Headers only INTERFACE library with generated headers don't work in CMake
because the GENERATED property is local to a directory. Instead we make a
STATIC library with a Dummy cpp file.

INTERFACE libraries can only have INTERFACE sources so the sources get added
to the dependant's list of sources. If these dependents are in another
directory, they don't see the GENERATED property and fail to configure
because the file doesn't exist on disk.

Use this trick for both dawn_headers and dawncpp_headers that are header
only libraries with generated headers.

Bug: dawn:333
Change-Id: Ib0d6dcc5f351a638d1c5360214c0ce14a28fee3e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15921
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/CMakeLists.txt b/src/dawn/CMakeLists.txt
index 9024051..0517343 100644
--- a/src/dawn/CMakeLists.txt
+++ b/src/dawn/CMakeLists.txt
@@ -22,8 +22,16 @@
     RESULT_VARIABLE "DAWN_HEADERS_GEN_SOURCES"
 )
 
-add_library(dawn_headers INTERFACE)
-target_sources(dawn_headers INTERFACE
+# Headers only INTERFACE library with generated headers don't work in CMake
+# because the GENERATED property is local to a directory. Instead we make a
+# STATIC library with a Dummy cpp file.
+#
+# INTERFACE libraries can only have INTERFACE sources so the sources get added
+# to the dependant's list of sources. If these dependents are in another
+# directory, they don't see the GENERATED property and fail to configure
+# because the file doesn't exist on disk.
+add_library(dawn_headers STATIC ${DAWN_DUMMY_FILE})
+target_sources(dawn_headers PRIVATE
     "${DAWN_INCLUDE_DIR}/dawn/dawn_wsi.h"
     ${DAWN_HEADERS_GEN_SOURCES}
 )
@@ -39,8 +47,10 @@
     RESULT_VARIABLE "DAWNCPP_HEADERS_GEN_SOURCES"
 )
 
-add_library(dawncpp_headers INTERFACE)
-target_sources(dawncpp_headers INTERFACE
+# This headers only library needs to be a STATIC library, see comment for
+# dawn_headers above.
+add_library(dawncpp_headers STATIC ${DAWN_DUMMY_FILE})
+target_sources(dawncpp_headers PRIVATE
     "${DAWN_INCLUDE_DIR}/dawn/EnumClassBitmasks.h"
     ${DAWNCPP_HEADERS_GEN_SOURCES}
 )