Fix VS clang-cl build

* Disable "undefined-var-template" in code, rather than in build files
* Add back some missing headers required when building in this context
* Make sure gtest/gmock do not override the default runtime library

Change-Id: I12c05943fc1d2dee4733ae70db7da026f67e0dad
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44180
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Antonio Maiorano 2021-03-09 21:51:50 +00:00 committed by Commit Bot service account
parent 5fb87dd915
commit 6ce58becd2
4 changed files with 33 additions and 5 deletions

View File

@ -17,6 +17,26 @@
#include <utility>
#if defined(__clang__)
/// Temporarily disable certain warnings when using Castable API
#define TINT_CASTABLE_PUSH_DISABLE_WARNINGS() \
_Pragma("clang diagnostic push") /**/ \
_Pragma("clang diagnostic ignored \"-Wundefined-var-template\"") /**/ \
static_assert(true, "require extra semicolon")
/// Restore disabled warnings
#define TINT_CASTABLE_POP_DISABLE_WARNINGS() \
_Pragma("clang diagnostic pop") /**/ \
static_assert(true, "require extra semicolon")
#else
#define TINT_CASTABLE_PUSH_DISABLE_WARNINGS() \
static_assert(true, "require extra semicolon")
#define TINT_CASTABLE_POP_DISABLE_WARNINGS() \
static_assert(true, "require extra semicolon")
#endif
TINT_CASTABLE_PUSH_DISABLE_WARNINGS();
namespace tint {
namespace detail {
@ -26,10 +46,13 @@ struct TypeInfoOf;
/// Helper macro to instantiate the TypeInfo<T> template for `CLASS`.
#define TINT_INSTANTIATE_TYPEINFO(CLASS) \
TINT_CASTABLE_PUSH_DISABLE_WARNINGS(); \
template <> \
const tint::TypeInfo tint::detail::TypeInfoOf<CLASS>::info { \
&tint::detail::TypeInfoOf<CLASS::TrueBase>::info, #CLASS, \
}
const tint::TypeInfo tint::detail::TypeInfoOf<CLASS>::info{ \
&tint::detail::TypeInfoOf<CLASS::TrueBase>::info, \
#CLASS, \
}; \
TINT_CASTABLE_POP_DISABLE_WARNINGS()
/// TypeInfo holds type information for a Castable type.
struct TypeInfo {
@ -197,4 +220,6 @@ inline TO* As(FROM* obj) {
} // namespace tint
TINT_CASTABLE_POP_DISABLE_WARNINGS();
#endif // SRC_CASTABLE_H_

View File

@ -15,6 +15,7 @@
#include "src/reader/spirv/parser_impl.h"
#include <limits>
#include <locale>
#include "source/opt/build_module.h"
#include "src/ast/bitcast_expression.h"

View File

@ -16,6 +16,7 @@
#ifndef SRC_SOURCE_H_
#define SRC_SOURCE_H_
#include <iostream>
#include <string>
#include <vector>

View File

@ -13,6 +13,7 @@
# limitations under the License.
if (${TINT_BUILD_TESTS} AND NOT TARGET gmock)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL)
endif()