-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
83 lines (68 loc) · 2.88 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
cmake_minimum_required (VERSION 3.10.2)
enable_testing()
option(ENABLE_CPPCHECK "use cppcheck" OFF)
option(OPTIMIZE "Turn on compiler optimizations" ON)
project(liblogger
DESCRIPTION "Logging library for C/C++"
VERSION "1.0.0"
LANGUAGES CXX
)
add_definitions(-DPACKAGE_VERSION="${PROJECT_VERSION}")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
#Use ccache if its installed
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
#Use cppcheck if its installed
if(ENABLE_CPPCHECK)
find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck)
if (CMAKE_CXX_CPPCHECK)
list(APPEND CMAKE_CXX_CPPCHECK
"--enable=warning"
"--inconclusive"
"--inline-suppr"
)
endif()
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CODECOV_OUTPUTFILE cmake_coverage.output )
set(CODECOV_HTMLOUTPUTDIR coverage_results)
if (CMAKE_COMPILER_IS_GNUCXX)
find_program(CODECOV_GCOV gcov )
find_program(CODECOV_LCOV lcov )
find_program(CODECOV_GENHTML genhtml )
add_definitions(-fprofile-arcs -ftest-coverage )
link_libraries(gcov)
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} --coverage)
endif (CMAKE_COMPILER_IS_GNUCXX )
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(FLAGS "-O3 -fno-strict-aliasing")
set(FLAGS "${FLAGS} -ggdb -g3 -Wall -Wextra -Wundef -Wwrite-strings -Wpointer-arith -Wmissing-declarations -Wredundant-decls")
set(FLAGS "${FLAGS} -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wcast-align -Wformat-nonliteral -Wformat-security")
set(FLAGS "${FLAGS} -Wsign-compare -Wstrict-aliasing -Wshadow -Winline -Wpacked -Wmissing-format-attribute -Wmissing-noreturn -Winit-self")
set(FLAGS "${FLAGS} -Wmissing-include-dirs -Wunused-but-set-variable -Warray-bounds -Wreturn-type ")
set(FLAGS "${FLAGS} -Wno-switch -Wno-inline -Wno-error=unused-parameter")
set(FLAGS "${FLAGS} -Wno-error=missing-field-initializers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAGS} -Wno-overloaded-virtual")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
find_package(Threads REQUIRED)
set(THREADS_PREFER_PTHREAD_FLAG ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(logmq)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/liblogger.pc.cmake liblogger.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/liblogger.pc
DESTINATION share/pkgconfig
)
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "James Stevenson <james@stev.org>")
SET(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
INCLUDE(CPack)