-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
48 lines (38 loc) · 1.23 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
cmake_minimum_required(VERSION 3.5)
project(CPP_RUNLOOP)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 99)
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
# CMake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
# Load modules
include(${CMAKE_MODULE_PATH}/git.cmake)
include(${CMAKE_MODULE_PATH}/include_guard.cmake)
# Clang format
file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.hpp)
file(GLOB_RECURSE TEST_FILES src/*.cpp src/*.hpp)
set(ALL_SOURCES ${SRC_FILES} ${TEST_FILES})
find_program(CLANG_FORMAT NAMES "clang-format" DOC "Path to clang-format executable")
if (NOT CLANG_FORMAT)
message(STATUS "clang-format not found.")
else ()
message(STATUS "clang-format found: ${CLANG_FORMAT}")
add_custom_target(
clang-format
COMMAND ${CLANG_FORMAT}
-style=file
-i
${ALL_SOURCES}
)
endif ()
# Clang tidy
find_program(CLANG_TIDY NAMES "clang-tidy" DOC "Path to clang-tidy executable")
if (NOT CLANG_TIDY)
message(STATUS "clang-tidy not found.")
else ()
message(STATUS "clang-tidy found: ${CLANG_TIDY}")
set(DO_CLANG_TIDY "${CLANG_TIDY}" "-fix;-fix-errors")
endif ()
# Sources
add_subdirectory(src)