-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
48 lines (40 loc) · 1.32 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
cmake_minimum_required(VERSION 3.1)
project(ngram)
set(CMAKE_CXX_STANDARD 11)
# TODO: Stringify CMAKE_CXX_FLAGS
message("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-Wall -Wextra -g -DDEBUG -O0)
else ()
add_compile_options(-Wall -Wextra -O2)
endif ()
execute_process(
COMMAND git describe --dirty --always --abbrev=7
OUTPUT_VARIABLE BUILD_HEAD_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_compile_definitions(BUILD_HEAD_COMMIT="${BUILD_HEAD_COMMIT}")
execute_process(
COMMAND date "+%Y/%m/%d %H:%M:%S %z"
OUTPUT_VARIABLE BUILD_TIMESTAMP
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_compile_definitions(BUILD_TIMESTAMP="${BUILD_TIMESTAMP}")
execute_process(
COMMAND whoami
OUTPUT_VARIABLE BUILD_USER
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_compile_definitions(BUILD_USER="${BUILD_USER}")
# see: https://github.com/google/glog#incorporating-glog-into-a-cmake-project
find_package(glog 0.6.0 REQUIRED)
find_library(LIBPROTOBUF_LITE libprotobuf-lite.a REQUIRED)
add_library(
${PROJECT_NAME} SHARED
src/ngram.cpp
src/utils.cpp
src/token_vector.cpp
src/highlight.cpp
src/proto/highlight_result.pb.cc
)
target_link_libraries(${PROJECT_NAME} glog::glog ${LIBPROTOBUF_LITE})