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,6 +355,33 @@ if(${TINT_BUILD_HLSL_WRITER})
|
|||
)
|
||||
endif()
|
||||
|
||||
## 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
|
||||
|
@ -443,33 +470,6 @@ set(TINT_TEST_SRCS
|
|||
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})
|
||||
list(APPEND TINT_TEST_SRCS
|
||||
reader/spirv/enum_converter_test.cc
|
||||
|
@ -741,3 +741,4 @@ if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
|
|||
endif()
|
||||
|
||||
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