-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCMakeLists.txt
65 lines (54 loc) · 1.92 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
# Version 3.8 is the first version that supports CXX_STANDARD 17.
cmake_minimum_required(VERSION 3.8)
project(TMatrix CXX)
# Use the C++17 standard.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Setup different build types. Release is the default.
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
# Add linking with pthread.
set(CMAKE_EXE_LINKER_FLAGS "-pthread")
# Add the required ncurses library.
set(CURSES_NEED_NCURSES TRUE)
find_package(Curses REQUIRED)
link_libraries(${CURSES_LIBRARIES})
# Link libatomic explicitly because some platforms require it.
find_library(ATOMIC_LIB atomic)
# Check if libatomic is present (it may not be, for example on macOS).
if(ATOMIC_LIB)
link_libraries(${ATOMIC_LIB})
endif()
# Add all the .cpp files.
file(GLOB tmatrix_SRC "src/*.cpp")
add_executable(tmatrix ${tmatrix_SRC})
# Specify the include directory.
include_directories(include)
# Specify how to compress the man page.
configure_file(tmatrix.6 ${PROJECT_BINARY_DIR}/tmatrix.6)
add_custom_command(OUTPUT tmatrix.6.gz
COMMAND gzip -f tmatrix.6
DEPENDS tmatrix.6
)
add_custom_target(manpage ALL DEPENDS tmatrix.6.gz)
# If the user didn't change the default install prefix set it to "/usr"
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE)
endif()
# Install tmatrix binary and manpage.
install(TARGETS tmatrix DESTINATION bin)
install(FILES ${PROJECT_BINARY_DIR}/tmatrix.6.gz DESTINATION share/man/man6)
# Install bash and zsh completion scripts.
install(FILES completions/tmatrix-completion.bash
DESTINATION share/bash-completion/completions
RENAME tmatrix
)
install(FILES completions/tmatrix-completion.zsh
DESTINATION share/zsh/site-functions
RENAME _tmatrix
)