This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
108 lines (94 loc) · 3.82 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
99
100
101
102
103
104
105
106
107
108
#
# Copyright 2018 The scinit authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.5.1)
project(cinit)
set(CMAKE_CXX_STANDARD 14)
if (${CMAKE_VERSION} VERSION_LESS "3.9.0")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmake ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmake-modules)
else()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/cmake-modules)
endif()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
message(STATUS "No build type specified, defaulting to Debug")
endif()
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Werror")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_BUILD_TYPE MATCHES Debug)
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
set(COVERAGE_LCOV_EXCLUDES '/usr' '*/boost/*' '*c++*' '*/yaml-cpp/*' '*/3rdparty/*')
SETUP_TARGET_FOR_COVERAGE_LCOV(
NAME cover
EXECUTABLE make test
DEPENDENCIES issue_reproducers
)
SETUP_TARGET_FOR_COVERAGE_LCOV(
NAME smoke-cover
EXECUTABLE sudo ../.circleci/smoke-test.sh
DEPENDENCIES issue_reproducers
)
endif()
include(GoogleTest)
enable_testing()
find_package(Boost 1.58 COMPONENTS program_options filesystem signals REQUIRED)
include_directories(${Boost_INCLUDE_DIR})
include_directories(3rdparty/spdlog/include)
set(SCINIT_SOURCE_FILES ChildProcess.cpp ChildProcess.h Config.h ConfigParseException.cpp log.h
ChildProcessException.cpp ChildProcessException.h ProcessHandler.cpp ProcessHandler.h
ProcessHandlerException.cpp ProcessHandlerException.h ChildProcessInterface.h ConfigInterface.h
ProcessHandlerInterface.h)
# Absolute paths are a lot easier to use in test targets from another subdirectory...
foreach(source ${SCINIT_SOURCE_FILES})
list(APPEND ABS_SCINIT_SOURCE_FILES ${PROJECT_SOURCE_DIR}/src/${source})
endforeach()
# All source files - used for clang-format
#set(ALL_SOURCE_FILES ${ABS_SCINIT_SOURCE_FILES})
# Add GTest here, since we need 'gtest_prod.h' in src/
add_subdirectory(3rdparty/googletest gtest-build EXCLUDE_FROM_ALL)
target_include_directories(gmock_main SYSTEM BEFORE INTERFACE
"${gtest_SOURCE_DIR}/include" "${gmock_SOURCE_DIR}/include")
# Clang-tidy
# TODO(uubk): hicpp-braces-around-statements
find_program(CLANG_TIDY NAMES clang-tidy-6.0 clang-tidy-5.0 clang-tidy-3.9 clang-tidy-3.8 clang-tidy)
if(NOT CLANG_TIDY)
message(WARNING "clang-tidy not found, checks will not be performed!")
else()
message(STATUS "clang-tidy found: ${CLANG_TIDY}, buildtype: ${CMAKE_BUILD_TYPE}")
set(CLANG_TIDY_ARGS "${CLANG_TIDY}")
endif()
# Inja
include_directories(AFTER SYSTEM 3rdparty/inja/src)
# Main source
add_subdirectory(src)
# Tests
add_subdirectory(test)
# Clang-format
file(GLOB_RECURSE SCINIT_TEST_SOURCE_FILES_CPP test/*.cpp)
file(GLOB_RECURSE SCINIT_TEST_SOURCE_FILES_H test/*.h)
file(GLOB_RECURSE SCINIT_MAIN_SOURCE_FILES_CPP src/*.cpp)
file(GLOB_RECURSE SCINIT_MAIN_SOURCE_FILES_H src/*.h)
set(ALL_SOURCE_FILES ${SCINIT_TEST_SOURCE_FILES_CPP} ${SCINIT_TEST_SOURCE_FILES_H} ${SCINIT_MAIN_SOURCE_FILES_CPP}
${SCINIT_MAIN_SOURCE_FILES_H})
add_custom_target(
format
COMMAND /usr/bin/clang-format
-style=file
-i
${ALL_SOURCE_FILES}
)