File: CMakeLists.txt

package info (click to toggle)
logserver 1.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 720 kB
  • sloc: cpp: 10,815; makefile: 3
file content (112 lines) | stat: -rw-r--r-- 3,018 bytes parent folder | download
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
cmake_minimum_required(VERSION 3.10)
set(CMAKE_VERBOSE_MAKEFILE ON)
project(logserver VERSION 1.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

add_compile_options(-Wall -Wextra -pedantic -Wunreachable-code -Wshadow)

file(GLOB SOURCES "src/*.cc")

find_package(Curses REQUIRED)

find_package(ZLIB REQUIRED)
if (ZLIB_FOUND)
    message(STATUS "Found zlib libraries at ${ZLIB_LIBRARIES}")
    message(STATUS "Found zlib include dirs at ${ZLIB_INCLUDE_DIRS}")
else()
    if (${MACOSX})
        message(FATAL_ERROR "Sawdust dependency - Zlib not found. Install with  `brew install zlib`")
    else ()
        message(FATAL_ERROR "Sawdust dependency - Zlib not found. Install with  `sudo apt-get install zlib1g-dev`")
    endif ()
endif ()

add_executable(logserver ${SOURCES})


add_executable(fuzzserver ${SOURCES})
target_compile_definitions(fuzzserver PRIVATE __FUZZ_IX__)

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native -flto")

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
else()
    add_compile_options(-O0 -g)
endif()

target_include_directories(logserver PRIVATE
			   "${PROJECT_SOURCE_DIR}"
			   "${CURSES_INCLUDE_DIR}"
			  )

target_link_libraries(logserver PRIVATE
		      "${CURSES_LIBRARIES}"
		      ZLIB::ZLIB)

target_include_directories(fuzzserver PRIVATE
			   "${PROJECT_SOURCE_DIR}"
			   "${CURSES_INCLUDE_DIR}"
			  )

target_link_libraries(fuzzserver PRIVATE
		      "${CURSES_LIBRARIES}"
		      ZLIB::ZLIB)

install(TARGETS logserver
        RUNTIME DESTINATION bin)

install(FILES README.md DESTINATION share/doc/logserver)

add_custom_command(
    OUTPUT "${CMAKE_SOURCE_DIR}/man/logserver.1.gz"
    COMMAND txt2man -s 1 -t logserver "${CMAKE_SOURCE_DIR}/man/logserver.txt" | gzip > "${CMAKE_SOURCE_DIR}/man/logserver.1.gz"
    DEPENDS man/logserver.txt
    VERBATIM
)

add_custom_target(
    generate_man ALL
    DEPENDS man/logserver.1.gz
)
install(FILES man/logserver.1.gz DESTINATION share/man/man1)


file(GLOB TEST_SOURCES "tests/test_*.cc")

add_executable(runtests ${TEST_SOURCES})

find_package(Catch2 3 REQUIRED)
include(Catch)
catch_discover_tests(runtests)

target_link_libraries(runtests PRIVATE
  Catch2::Catch2WithMain
  ZLIB::ZLIB
)

target_include_directories(runtests PRIVATE
    ${CMAKE_SOURCE_DIR}/src
)


set(CPACK_GENERATOR "DEB")
# Package metadata
set(CPACK_PACKAGE_NAME "logserver")
set(CPACK_PACKAGE_VERSION "1.13.2")
set(CPACK_PACKAGE_CONTACT "logserver@potatocrunchcereal.com")
set(CPACK_PACKAGE_DESCRIPTION "pager designed for rapid navigation with multiple keyword searching on giant log files")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Joel Reardon")
set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")

# Where to install (optional, defaults to /usr/local)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")

# Add license info, if you want
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")

include(CPack)