forked from cppcheck-opensource/cppcheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
67 lines (58 loc) · 2.22 KB
/
CMakeLists.txt
File metadata and controls
67 lines (58 loc) · 2.22 KB
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
file(GLOB_RECURSE hdrs "*.h")
file(GLOB_RECURSE srcs "*.cpp")
# move the slowest files to the top
set(srcs_slow "${CMAKE_CURRENT_SOURCE_DIR}/valueflow.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/tokenize.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/symboldatabase.cpp")
list(REMOVE_ITEM srcs ${srcs_slow})
list(INSERT srcs 0 ${srcs_slow})
function(build_src output filename)
get_filename_component(file ${filename} NAME)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/build/mc_${file})
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
if (USE_MATCHCOMPILER_OPT STREQUAL "Verify")
set(verify_option "--verify")
else()
set(verify_option "")
endif()
add_custom_command(
OUTPUT ${outfile}
COMMAND ${Python_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tools/matchcompiler.py"
--read-dir="${CMAKE_CURRENT_SOURCE_DIR}"
--prefix="mc_"
--line
${verify_option}
${file}
DEPENDS ${file}
DEPENDS ${PROJECT_SOURCE_DIR}/tools/matchcompiler.py
)
set_source_files_properties(${outfile} PROPERTIES GENERATED TRUE)
endfunction()
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
set(srcs_build "")
foreach(file ${srcs})
build_src(srcs_build ${file})
endforeach()
set(srcs_lib ${srcs_build})
else()
set(srcs_lib ${srcs})
endif()
if(BUILD_SHARED_LIBS)
add_library(cppcheck-core ${srcs_lib} ${hdrs})
else()
# A OBJECT library is used because the auto-registration doesn't work with static libraries
add_library(cppcheck-core OBJECT ${srcs_lib} ${hdrs})
endif()
if (BUILD_SHARED_LIBS AND MSVC)
target_sources(cppcheck-core PRIVATE version.rc)
endif()
target_dll_compile_definitions(cppcheck-core EXPORT CPPCHECKLIB_EXPORT IMPORT CPPCHECKLIB_IMPORT)
target_include_directories(cppcheck-core PUBLIC .)
target_link_libraries(cppcheck-core PRIVATE tinyxml2 simplecpp picojson ${PCRE_LIBRARY})
if (HAVE_RULES)
target_include_directories(cppcheck-core SYSTEM PRIVATE ${PCRE_INCLUDE})
endif()
if (Boost_FOUND)
target_include_directories(cppcheck-core SYSTEM PUBLIC ${Boost_INCLUDE_DIRS})
endif()
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
target_precompile_headers(cppcheck-core PRIVATE precompiled.h)
endif()