-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
65 lines (53 loc) · 2.07 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
cmake_minimum_required(VERSION 3.5)
project(autotidy LANGUAGES CXX)
# Global project settings
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Enable ccache if available
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
endif()
# GCC/Clang common warnings
set(GCC_CLANG_WARNINGS
-Wall
-Wextra
-Wnon-virtual-dtor
-Wcast-align)
# GCC specific warnings
set(GCC_WARNINGS
-Wduplicated-branches
-Wduplicated-cond
-Wlogical-op
-Wnull-dereference
-Wno-missing-field-initializers)
# MSVC warnings
set(MSVC_WARNINGS /W4 /w14640 /permissive)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(WARNINGS ${WARNINGS} ${GCC_WARNINGS} ${GCC_CLANG_WARNINGS})
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(WARNINGS ${WARNINGS} ${CLANG_WARNINGS} ${GCC_CLANG_WARNINGS})
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(WARNINGS ${WARNINGS} ${MSVC_WARNINGS})
endif()
add_library(Warnings INTERFACE)
target_compile_options(Warnings INTERFACE ${WARNINGS})
# External dependencies
add_subdirectory(external/fmt)
add_subdirectory(external/abseil-cpp)
add_subdirectory(external/CLI11)
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "Enable testing")
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "Enable parse tools")
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "Enable contrib stuff in library")
set(YAML_CPP_INSTALL OFF CACHE BOOL "Enable generation of install target")
add_subdirectory(external/yaml-cpp)
add_executable(testcode src/testcode.cpp)
target_link_libraries(testcode PRIVATE Warnings fmt absl::strings)
add_executable(makedoc src/makedoc.cpp)
target_link_libraries(makedoc PRIVATE Warnings fmt absl::strings)
add_executable(tidytest src/testmain.cpp src/patched_file.test.cpp)
target_link_libraries(tidytest PRIVATE Warnings absl::strings absl::algorithm)
add_executable(autotidy src/main.cpp src/autotidy.cpp src/manpages.cpp)
target_link_libraries(autotidy PRIVATE Warnings fmt absl::strings CLI11 yaml-cpp)