CMake: Add a flag to control whether to built tint_unittests
Bug: dawn:605 Change-Id: I03860c263746939112e03544fbc3579631423c37 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35282 Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
350330bb46
commit
f3717fa249
|
@ -34,6 +34,7 @@ option(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ON)
|
|||
option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ON)
|
||||
option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
|
||||
option(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
|
||||
option(TINT_BUILD_TESTS "Build tests" ON)
|
||||
|
||||
option(TINT_ENABLE_MSAN "Enable memory sanitizer" OFF)
|
||||
option(TINT_ENABLE_ASAN "Enable address sanitizer" OFF)
|
||||
|
@ -59,6 +60,7 @@ message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}")
|
|||
message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}")
|
||||
message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}")
|
||||
message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}")
|
||||
message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}")
|
||||
message(STATUS "Tint build with ASAN: ${TINT_ENABLE_ASAN}")
|
||||
message(STATUS "Tint build with MSAN: ${TINT_ENABLE_MSAN}")
|
||||
message(STATUS "Tint build with UBSAN: ${TINT_ENABLE_UBSAN}")
|
||||
|
|
|
@ -355,7 +355,34 @@ if(${TINT_BUILD_HLSL_WRITER})
|
|||
)
|
||||
endif()
|
||||
|
||||
set(TINT_TEST_SRCS
|
||||
## Tint library
|
||||
add_library(libtint ${TINT_LIB_SRCS})
|
||||
tint_default_compile_options(libtint)
|
||||
if (${COMPILER_IS_LIKE_GNU})
|
||||
target_compile_options(libtint PRIVATE -fvisibility=hidden)
|
||||
endif()
|
||||
set_target_properties(libtint PROPERTIES OUTPUT_NAME "tint")
|
||||
|
||||
if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
|
||||
tint_spvtools_compile_options(libtint)
|
||||
if (${TINT_BUILD_FUZZERS})
|
||||
tint_spvtools_compile_options(libtint-fuzz)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (${TINT_BUILD_FUZZERS})
|
||||
# Tint library with fuzzer instrumentation
|
||||
add_library(libtint-fuzz ${TINT_LIB_SRCS})
|
||||
tint_default_compile_options(libtint-fuzz)
|
||||
if (${COMPILER_IS_LIKE_GNU})
|
||||
target_compile_options(libtint-fuzz PRIVATE -fvisibility=hidden)
|
||||
endif()
|
||||
target_compile_options(libtint-fuzz PUBLIC -fsanitize=fuzzer -fsanitize-coverage=trace-cmp)
|
||||
target_link_options(libtint-fuzz PUBLIC -fsanitize=fuzzer -fsanitize-coverage=trace-cmp)
|
||||
endif()
|
||||
|
||||
if(${TEST_BUILD_TESTS})
|
||||
set(TINT_TEST_SRCS
|
||||
ast/array_accessor_expression_test.cc
|
||||
ast/assignment_statement_test.cc
|
||||
ast/binding_decoration_test.cc
|
||||
|
@ -441,36 +468,9 @@ set(TINT_TEST_SRCS
|
|||
validator/validator_test.cc
|
||||
validator/validator_type_test.cc
|
||||
writer/float_to_string_test.cc
|
||||
)
|
||||
)
|
||||
|
||||
## Tint library
|
||||
add_library(libtint ${TINT_LIB_SRCS})
|
||||
tint_default_compile_options(libtint)
|
||||
if (${COMPILER_IS_LIKE_GNU})
|
||||
target_compile_options(libtint PRIVATE -fvisibility=hidden)
|
||||
endif()
|
||||
|
||||
if (${TINT_BUILD_FUZZERS})
|
||||
# Tint library with fuzzer instrumentation
|
||||
add_library(libtint-fuzz ${TINT_LIB_SRCS})
|
||||
tint_default_compile_options(libtint-fuzz)
|
||||
if (${COMPILER_IS_LIKE_GNU})
|
||||
target_compile_options(libtint-fuzz PRIVATE -fvisibility=hidden)
|
||||
endif()
|
||||
target_compile_options(libtint-fuzz PUBLIC -fsanitize=fuzzer -fsanitize-coverage=trace-cmp)
|
||||
target_link_options(libtint-fuzz PUBLIC -fsanitize=fuzzer -fsanitize-coverage=trace-cmp)
|
||||
endif()
|
||||
|
||||
set_target_properties(libtint PROPERTIES OUTPUT_NAME "tint")
|
||||
|
||||
if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
|
||||
tint_spvtools_compile_options(libtint)
|
||||
if (${TINT_BUILD_FUZZERS})
|
||||
tint_spvtools_compile_options(libtint-fuzz)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${TINT_BUILD_SPV_READER})
|
||||
if(${TINT_BUILD_SPV_READER})
|
||||
list(APPEND TINT_TEST_SRCS
|
||||
reader/spirv/enum_converter_test.cc
|
||||
reader/spirv/fail_stream_test.cc
|
||||
|
@ -502,9 +502,9 @@ if(${TINT_BUILD_SPV_READER})
|
|||
reader/spirv/spirv_tools_helpers_test.h
|
||||
reader/spirv/usage_test.cc
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${TINT_BUILD_WGSL_READER})
|
||||
if(${TINT_BUILD_WGSL_READER})
|
||||
list(APPEND TINT_TEST_SRCS
|
||||
reader/wgsl/lexer_test.cc
|
||||
reader/wgsl/parser_test.cc
|
||||
|
@ -580,9 +580,9 @@ if(${TINT_BUILD_WGSL_READER})
|
|||
reader/wgsl/parser_impl_variable_storage_decoration_test.cc
|
||||
reader/wgsl/token_test.cc
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${TINT_BUILD_SPV_WRITER})
|
||||
if(${TINT_BUILD_SPV_WRITER})
|
||||
list(APPEND TINT_TEST_SRCS
|
||||
writer/spirv/binary_writer_test.cc
|
||||
writer/spirv/builder_accessor_expression_test.cc
|
||||
|
@ -615,9 +615,9 @@ if(${TINT_BUILD_SPV_WRITER})
|
|||
writer/spirv/spv_dump.h
|
||||
writer/spirv/test_helper.h
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${TINT_BUILD_WGSL_WRITER})
|
||||
if(${TINT_BUILD_WGSL_WRITER})
|
||||
list(APPEND TINT_TEST_SRCS
|
||||
writer/wgsl/generator_impl_test.cc
|
||||
writer/wgsl/generator_impl_alias_type_test.cc
|
||||
|
@ -647,9 +647,9 @@ if(${TINT_BUILD_WGSL_WRITER})
|
|||
writer/wgsl/generator_impl_variable_test.cc
|
||||
writer/wgsl/test_helper.h
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${TINT_BUILD_MSL_WRITER})
|
||||
if(${TINT_BUILD_MSL_WRITER})
|
||||
list(APPEND TINT_TEST_SRCS
|
||||
writer/msl/generator_impl_alias_type_test.cc
|
||||
writer/msl/generator_impl_array_accessor_test.cc
|
||||
|
@ -683,9 +683,9 @@ if(${TINT_BUILD_MSL_WRITER})
|
|||
writer/msl/namer_test.cc
|
||||
writer/msl/test_helper.h
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (${TINT_BUILD_HLSL_WRITER})
|
||||
if (${TINT_BUILD_HLSL_WRITER})
|
||||
list(APPEND TINT_TEST_SRCS
|
||||
writer/hlsl/generator_impl_alias_type_test.cc
|
||||
writer/hlsl/generator_impl_array_accessor_test.cc
|
||||
|
@ -719,25 +719,26 @@ if (${TINT_BUILD_HLSL_WRITER})
|
|||
writer/hlsl/namer_test.cc
|
||||
writer/hlsl/test_helper.h
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(tint_unittests ${TINT_TEST_SRCS})
|
||||
add_executable(tint_unittests ${TINT_TEST_SRCS})
|
||||
|
||||
if(NOT MSVC)
|
||||
if(NOT MSVC)
|
||||
target_compile_options(tint_unittests PRIVATE
|
||||
-Wno-global-constructors
|
||||
-Wno-weak-vtables
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
## Test executable
|
||||
target_include_directories(
|
||||
## Test executable
|
||||
target_include_directories(
|
||||
tint_unittests PRIVATE ${gmock_SOURCE_DIR}/include)
|
||||
target_link_libraries(tint_unittests libtint gmock_main)
|
||||
tint_default_compile_options(tint_unittests)
|
||||
target_link_libraries(tint_unittests libtint gmock_main)
|
||||
tint_default_compile_options(tint_unittests)
|
||||
|
||||
if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
|
||||
if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
|
||||
tint_spvtools_compile_options(tint_unittests)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_test(NAME tint_unittests COMMAND tint_unittests)
|
||||
add_test(NAME tint_unittests COMMAND tint_unittests)
|
||||
endif()
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
if (NOT TARGET gmock)
|
||||
if (${TINT_BUILD_TESTS} AND NOT TARGET gmock)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in New Issue