-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
149 lines (127 loc) · 4.95 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
cmake_minimum_required (VERSION 2.6)
project (ClangLazy)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
find_package(Clang 3.6 MODULE REQUIRED)
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
add_definitions (-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)
add_definitions (-D_GNU_SOURCE -DHAVE_CLANG_CONFIG_H)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-common -Woverloaded-virtual -Wcast-qual -fno-strict-aliasing -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -fno-exceptions -fno-rtti")
elseif(MSVC)
# disable trigger-happy warnings from Clang/LLVM headers
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4244 /wd4291 /wd4800")
endif()
set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
if(NOT WIN32)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
# Look for std::regex support
message("Looking for std::regex support...")
try_run(RUN_RESULT COMPILE_RESULT ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake_has_regex_test.cpp)
if (RUN_RESULT EQUAL 0)
set(HAS_STD_REGEX TRUE)
else()
set(HAS_STD_REGEX FALSE)
endif()
# Don't link against LLVMSupport, causes: CommandLine Error: Option 'view-background' registered more than once!
STRING(REPLACE " " ";" LLVM_LIBS_LIST ${LLVM_LIBS}) # Transform into a list
LIST(REMOVE_ITEM LLVM_LIBS_LIST "-lLLVMSupport") # Remove element
macro(add_clang_plugin name)
set (srcs ${ARGN})
include_directories(${CLANG_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR})
link_directories("${LLVM_INSTALL_PREFIX}/lib" ${LLVM_LIBRARY_DIRS})
add_library( ${name} SHARED ${srcs} )
if (SYMBOL_FILE)
set_target_properties( ${name} PROPERTIES LINK_FlAGS
"-exported_symbols_list ${SYMBOL_FILE}")
endif()
foreach (clang_lib ${CLANG_LIBS})
target_link_libraries( ${name} ${clang_lib} )
endforeach()
foreach (llvm_lib ${LLVM_LIBS_LIST})
target_link_libraries( ${name} ${llvm_lib} )
endforeach()
foreach (user_lib ${USER_LIBS})
target_link_libraries( ${name} ${user_lib} )
endforeach()
endmacro(add_clang_plugin)
set(SYMBOL_FILE Lazy.exports)
set(SRC_FILES
checkbase.cpp
checkmanager.cpp
checks/auto-auto-auto.cpp
checks/autounexpectedqstringbuilder.cpp
checks/assertwithsideeffects.cpp
checks/container-anti-pattern.cpp
checks/container-inside-loop.cpp
checks/copyable-polymorphic.cpp
checks/detachingbase.cpp
checks/detachingmember.cpp
checks/detachingtemporary.cpp
checks/dynamic_cast.cpp
checks/foreach.cpp
checks/globalconstcharpointer.cpp
checks/isempty-vs-count.cpp
checks/inefficientqlistbase.cpp
checks/inefficientqlist.cpp
checks/inefficient-qlist-soft.cpp
checks/implicitcasts.cpp
checks/lambda-in-connect.cpp
checks/qdatetimeutc.cpp
checks/qgetenv.cpp
checks/qvariant-template-instantiation.cpp
checks/function-args-by-ref.cpp
checks/function-args-by-value.cpp
checks/qdeleteall.cpp
checks/qfileinfo-exists.cpp
checks/qmapkey.cpp
checks/qstringarg.cpp
checks/qstringref.cpp
checks/qstring-allocations.cpp
checks/qstring-insensitive-allocation.cpp
checks/qt4-qstring-from-array.cpp
checks/missing-type-info.cpp
checks/missing-qobject-macro.cpp
checks/nonpodstatic.cpp
checks/range-loop.cpp
checks/requiredresults.cpp
checks/reservecandidates.cpp
checks/ruleofbase.cpp
checks/ruleoftwosoft.cpp
checks/ruleofthree.cpp
checks/temporaryiterator.cpp
checks/unused-non-trivial-variable.cpp
checks/virtualcallsfromctor.cpp
checks/writingtotemporary.cpp
checks/wrong-qglobalstatic.cpp
Clazy.cpp
ContextUtils.cpp
FixItUtils.cpp
HierarchyUtils.cpp
LoopUtils.cpp
MacroUtils.cpp
TemplateUtils.cpp
StringUtils.cpp
TypeUtils.cpp
QtUtils.cpp
Utils.cpp)
if (HAS_STD_REGEX)
set(SRC_FILES ${SRC_FILES} checks/oldstyleconnect.cpp)
else()
message("old-style-connect check is disabled due to missing std::regex support")
endif()
add_clang_plugin(ClangLazy ${SRC_FILES})
set_target_properties(ClangLazy PROPERTIES
LINKER_LANGUAGE CXX
PREFIX "")
include("GNUInstallDirs")
install(TARGETS ClangLazy RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(NOT WIN32)
install(FILES ${CMAKE_SOURCE_DIR}/clazy DESTINATION bin PERMISSIONS OWNER_WRITE OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE)
else()
install(FILES ${CMAKE_SOURCE_DIR}/clazy.bat DESTINATION bin PERMISSIONS OWNER_WRITE OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE)
endif()