1# Copyright (c) Meta Platforms, Inc. and affiliates. 2# All rights reserved. 3# 4# This source code is licensed under the BSD-style license found in the 5# LICENSE file in the root directory of this source tree. 6 7# This file should be formatted with 8# ~~~ 9# cmake-format -i CMakeLists.txt 10# ~~~ 11# It should also be cmake-lint clean. 12# 13 14cmake_minimum_required(VERSION 3.19) 15project(tokenizer_test) 16 17# Use C++17 for test. 18set(CMAKE_CXX_STANDARD 17) 19 20set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../../..) 21 22include(${EXECUTORCH_ROOT}/build/Test.cmake) 23 24set(_tokenizer_test_srcs 25 test_tiktoken.cpp test_bpe_tokenizer.cpp 26 ${CMAKE_CURRENT_SOURCE_DIR}/../tiktoken.cpp 27 ${CMAKE_CURRENT_SOURCE_DIR}/../bpe_tokenizer.cpp 28) 29 30set(ENV{RESOURCES_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/resources) 31set(ABSL_ENABLE_INSTALL ON) 32set(ABSL_PROPAGATE_CXX_STD ON) 33set(_pic_flag ${CMAKE_POSITION_INDEPENDENT_CODE}) 34set(CMAKE_POSITION_INDEPENDENT_CODE ON) 35add_subdirectory( 36 ${CMAKE_CURRENT_SOURCE_DIR}/../../third-party/abseil-cpp 37 ${CMAKE_CURRENT_BINARY_DIR}/abseil-cpp 38) 39add_subdirectory( 40 ${CMAKE_CURRENT_SOURCE_DIR}/../../third-party/re2 41 ${CMAKE_CURRENT_BINARY_DIR}/re2 42) 43set(CMAKE_POSITION_INDEPENDENT_CODE ${_pic_flag}) 44 45et_cxx_test(tokenizer_test SOURCES ${_tokenizer_test_srcs} EXTRA_LIBS re2::re2) 46target_include_directories( 47 tokenizer_test 48 PRIVATE ${CMAKE_INSTALL_PREFIX}/include 49 ${CMAKE_CURRENT_SOURCE_DIR}/../../third-party/abseil-cpp 50) 51