-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
95 lines (79 loc) · 2.69 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
cmake_minimum_required(VERSION 3.11)
project(markov_typing)
find_package(Qt5Widgets REQUIRED)
find_package(nlohmann_json QUIET)
find_package(CLI11 QUIET)
set(CLANG_FORMAT FALSE CACHE BOOL "Format the code with clang format.")
set(USE_BOOST_FS FALSE CACHE BOOL "Use boost filesystem. Does not work atm.")
set(CMAKE_AUTOMOC ON)
cmake_policy(SET CMP0100 NEW)
if(USE_BOOST_FS)
find_package(Boost REQUIRED COMPONENTS filesystem)
set(FS_LINK Boost::filesystem)
add_compile_options(-DBOOST_FILESYSTEM)
else()
set(FS_LINK stdc++fs)
endif()
if(NOT nlohmann_json_FOUND AND NOT EXISTS ${CMAKE_SOURCE_DIR}/third_party/nlohmann/json.hpp)
message("Downloading nlohmann/json")
file(DOWNLOAD
https://github.com/nlohmann/json/releases/download/v3.1.2/json.hpp
${CMAKE_SOURCE_DIR}/third_party/nlohmann/json.hpp
)
endif()
if(NOT CLI11_FOUND AND NOT EXISTS ${CMAKE_SOURCE_DIR}/third_party/CLI/CLI.hpp)
message("Downloading CLI11")
file(DOWNLOAD
https://github.com/CLIUtils/CLI11/releases/download/v1.6.1/CLI11.hpp
${CMAKE_SOURCE_DIR}/third_party/CLI/CLI.hpp
)
endif()
set(TYPING_SOURCES
${CMAKE_SOURCE_DIR}/src/main.cc
${CMAKE_SOURCE_DIR}/src/probability_matrix.hh
${CMAKE_SOURCE_DIR}/src/probability_matrix.cc
${CMAKE_SOURCE_DIR}/src/sentence.hh
${CMAKE_SOURCE_DIR}/src/stats.hh
${CMAKE_SOURCE_DIR}/src/utils.hh
${CMAKE_SOURCE_DIR}/src/io.hh
${CMAKE_SOURCE_DIR}/src/io.cc
${CMAKE_SOURCE_DIR}/src/qt_gui/mainwindow.cc
${CMAKE_SOURCE_DIR}/src/qt_gui/practice_area.cc
${CMAKE_SOURCE_DIR}/src/qt_gui/char_sets_picker.cc
)
add_executable(markov-typing ${TYPING_SOURCES})
target_link_libraries(markov-typing
PRIVATE
Qt5::Widgets
# TODO it would be better to use boost::filesystem until compilers
# stabilize filesystem support
${FS_LINK}
)
target_compile_features(markov-typing
PRIVATE
cxx_std_17
)
target_compile_options(markov-typing
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:-Wall>
$<$<CXX_COMPILER_ID:Clang>:-Wall>
$<$<CONFIG:Debug>:-DDEBUG>
)
target_include_directories(markov-typing PRIVATE third_party)
if(UNIX)
# YouCompleteMe setup
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
add_custom_target(link_for_compile_commands ALL
COMMAND
${CMAKE_COMMAND} -E create_symlink
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_SOURCE_DIR}/compile_commands.json
)
endif()
if(UNIX AND ${CLANG_FORMAT})
add_custom_target(clang-format ALL
clang-format -i ${TYPING_SOURCES}
)
endif()
include(GNUInstallDirs)
install(TARGETS markov-typing DESTINATION "${CMAKE_INSTALL_BINDIR}")