-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
98 lines (72 loc) · 3.52 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
cmake_minimum_required(VERSION 3.15)
#! Check every comment after the "#!"
#! CHANGE YOUR PROJECT NAME
# It is used as your project's main executable name.
set(PROJECT_NAME N-Grams)
project(${PROJECT_NAME} C CXX) # project(${PROJECT_NAME} C CXX ASM)
set(CMAKE_CXX_STANDARD 17)
##########################################################
# User configurable options of the template
##########################################################
# Note: symbols like WARNINGS_AS_ERRORS in configuration are intentionally variables
# and not CMake options --using options creates too much problem for students.
#! It is a good practice to set "WARNINGS_AS_ERRORS" ON,
# but sometimes it creates too much trouble, so default is OFF.
set(WARNINGS_AS_ERRORS OFF)
#! Always use PVS Studio while developing.
set(ENABLE_PVS_STUDIO OFF)
#! Select appropriate sanitizers.
# Definitely enable sanitizers while developing.
# Disable it for the production builds and before submitting for grading.
# Only one of Memory (MSAN), Address (ASAN), or Thread (TSan)
# sanitizers is applicable at the time -- the first defined.
#! UndefinedBehaviorSanitizer (UBSan)
# Info: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
set(ENABLE_UBSan OFF)
#! AddressSanitizer -- detects use after free or after scope exit,
# memory overflows and leaks.
# Info: https://github.com/google/sanitizers/wiki/AddressSanitizer
set(ENABLE_ASAN OFF)
#! ThreadSanitizer -- detects data races.
set(ENABLE_TSan OFF)
#! MemorySanitizer detects uninitialized memory reads
# Info: https://github.com/google/sanitizers/wiki/MemorySanitizer
set(ENABLE_MSAN OFF)
#! Be default -- build release version if not specified otherwise.
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()
# Warnings as errors should be imported here -- do not move this line
include(cmake/CompilerWarnings.cmake)
##########################################################
# Project files, packages, libraries and so on
##########################################################
#! Project main executable source compilation
add_executable(${PROJECT_NAME} src/main.cpp src/main.h indexing/myqueue.hpp parser/parser.cpp parser/parser.h indexing/processing.cpp indexing/processing.h prediction/prediction.h prediction/prediction.cpp)
#! Add external packages
# options_parser requires boost::program_options library
set (Boost_USE_STATIC_LIBS OFF) # enable dynamic linking
set (Boost_USE_MULTITHREAD ON) # enable multithreading
find_package(Boost 1.71.0 COMPONENTS program_options system REQUIRED COMPONENTS filesystem locale system)
target_include_directories(${PROJECT_NAME} PRIVATE ${Boost_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} Boost::program_options Boost::system Boost::locale)
find_package(TBB REQUIRED)
target_link_libraries(${PROJECT_NAME} TBB::tbb)
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} Threads::Threads)
if (APPLE)
set(LibArchive_INCLUDE_DIR "/usr/local/opt/libarchive/include")
endif()
find_package(LibArchive REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${LibArchive_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} LibArchive::LibArchive)
##########################################################
# Fixed CMakeLists.txt part
##########################################################
INSTALL(PROGRAMS
$<TARGET_FILE:${PROJECT_NAME}> # ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
DESTINATION bin)
# Define ALL_TARGETS variable to use in PVS and Sanitizers
set(ALL_TARGETS ${PROJECT_NAME})
# Include CMake setup
include(cmake/main-config.cmake)