-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
52 lines (41 loc) · 1.83 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright (c) 2022-present, Zejun Wang ([email protected])
# All rights reserved.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0079 NEW)
project(easytokenizer LANGUAGES CXX C VERSION 0.2.0)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
#set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/../)
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -fPIC -funroll-loops")
# OMP
option(WITH_OMP "Compile with OpenMP" OFF)
if (WITH_OMP)
find_package(OpenMP REQUIRED)
add_definitions(-DWITH_OMP)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
message("CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tokenizer)
# add_libray
add_library(tokenizer_static_lib
${CMAKE_CURRENT_SOURCE_DIR}/tokenizer/tokenizer.cc
${CMAKE_CURRENT_SOURCE_DIR}/tokenizer/utf8proc.c)
target_link_libraries(tokenizer_static_lib pthread)
set_target_properties(tokenizer_static_lib PROPERTIES OUTPUT_NAME tokenizer)
# add_libray make SHARED
add_library(tokenizer_shared_lib SHARED
${CMAKE_CURRENT_SOURCE_DIR}/tokenizer/tokenizer.cc
${CMAKE_CURRENT_SOURCE_DIR}/tokenizer/utf8proc.c)
target_link_libraries(tokenizer_shared_lib pthread)
set_target_properties(tokenizer_shared_lib PROPERTIES OUTPUT_NAME tokenizer)
# CGO
add_library(tokenizer SHARED easytokenizer_wrapper.cc)
target_link_libraries(tokenizer PUBLIC tokenizer_static_lib)
target_include_directories(tokenizer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
install(TARGETS tokenizer DESTINATION ${CMAKE_INSTALL_LIBDIR})