File: CMakeLists.txt

package info (click to toggle)
cppcheck 2.17.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 25,384 kB
  • sloc: cpp: 263,341; python: 19,737; ansic: 7,953; sh: 1,018; makefile: 996; xml: 994; cs: 291
file content (106 lines) | stat: -rw-r--r-- 4,824 bytes parent folder | download
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
if (BUILD_GUI)

    # disable all clang-tidy checks for Qt generated files
    file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/.clang-tidy"
"---
Checks:          '-*,misc-definitions-in-headers'
WarningsAsErrors: '*'
CheckOptions:
  - { key: HeaderFileExtensions,          value: 'x' }
")

    add_compile_definitions($<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
    add_compile_definitions($<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG_OUTPUT>)
    add_compile_definitions($<$<NOT:$<CONFIG:Debug>>:QT_NO_WARNING_OUTPUT>)
    add_compile_definitions($<$<CONFIG:Debug>:QT_DEBUG>)

    file(GLOB hdrs "*.h")
    file(GLOB srcs "*.cpp")
    file(GLOB uis  "*.ui")
    file(GLOB tss  "*.ts")
    QT_WRAP_UI(uis_hdrs ${uis})
    QT_ADD_RESOURCES(resources "gui.qrc")
    # TODO: passing "-no-obsolete" here breaks the translations
    QT_CREATE_TRANSLATION(qms ${CMAKE_CURRENT_SOURCE_DIR} ${tss})
    list(APPEND cppcheck-gui-deps ${hdrs} ${uis_hdrs} ${resources} ${qms})
    add_custom_target(gui-build-deps SOURCES ${cppcheck-gui-deps})

    list(APPEND cppcheck-gui_SOURCES ${srcs})
    if (NOT BUILD_CORE_DLL)
        list(APPEND cppcheck-gui_SOURCES $<TARGET_OBJECTS:cppcheck-core> $<TARGET_OBJECTS:simplecpp_objs>)
        if(USE_BUNDLED_TINYXML2)
            list(APPEND cppcheck-gui_SOURCES $<TARGET_OBJECTS:tinyxml2_objs>)
        endif()
    endif()
    if (WIN32)
        list(APPEND cppcheck-gui_SOURCES cppcheck-gui.rc)
    endif()

    add_executable(cppcheck-gui ${cppcheck-gui-deps} ${cppcheck-gui_SOURCES})
    set_target_properties(cppcheck-gui PROPERTIES AUTOMOC ON)
    set_target_properties(cppcheck-gui PROPERTIES WIN32_EXECUTABLE ON)
    target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/lib/)
    if(USE_BUNDLED_TINYXML2)
        target_externals_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/)
    else()
        target_include_directories(cppcheck-gui SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
    endif()
    target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/)
    if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
        target_precompile_headers(cppcheck-gui PRIVATE precompiled.h)
    endif()
    if (HAVE_RULES)
        target_link_libraries(cppcheck-gui ${PCRE_LIBRARY})
    endif()
    if(tinyxml2_FOUND AND NOT USE_BUNDLED_TINYXML2)
        target_link_libraries(cppcheck-gui ${tinyxml2_LIBRARIES})
    endif()
    target_link_libraries(cppcheck-gui ${QT_CORE_LIB} ${QT_GUI_LIB} ${QT_WIDGETS_LIB} ${QT_PRINTSUPPORT_LIB} ${QT_HELP_LIB} ${QT_NETWORK_LIB})
    if(WITH_QCHART)
        target_link_libraries(cppcheck-gui ${QT_CHARTS_LIB})
    endif()
    if (BUILD_CORE_DLL)
        target_compile_definitions(cppcheck-gui PRIVATE CPPCHECKLIB_IMPORT TINYXML2_IMPORT)
        target_link_libraries(cppcheck-gui cppcheck-core)
    endif()
    if(MSVC)
        # compilation will fail as e.g. QList::realloc would be replaced by MSVC's macro definition
        target_compile_definitions(cppcheck-gui PRIVATE $<$<CONFIG:Debug>:DISABLE_CRTDBG_MAP_ALLOC>)
        if(NOT USE_QT6)
            target_compile_options(cppcheck-gui PRIVATE /wd4996) # warning C4996: 'QProcess::startDetached': Use QProcess::startDetached(const QString &program, const QStringList &arguments) instead
            target_compile_options(cppcheck-gui PRIVATE /wd4505) # warning C4505: 'x': unreferenced function with internal linkage has been removed
        endif()
    endif()
    if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
        # Q_UNUSED() in generated code
        target_compile_options_safe(cppcheck-gui -Wno-extra-semi-stmt)
        # caused by Qt generated moc code
        target_compile_options_safe(cppcheck-gui -Wno-redundant-parens)
    endif()

    if (QHELPGENERATOR)
        # TODO: generate in CMAKE_BINARY_DIR folder
        add_custom_target(online-help.qhc ${QHELPGENERATOR} ${CMAKE_CURRENT_SOURCE_DIR}/help/online-help.qhcp -o ${CMAKE_CURRENT_SOURCE_DIR}/help/online-help.qhc)
        add_dependencies(cppcheck-gui online-help.qhc)
    endif()

    install(TARGETS cppcheck-gui RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)
    install(FILES ${qms} DESTINATION ${FILESDIR}/lang COMPONENT applications)

    install(FILES cppcheck-gui.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)

    # icons
    install(FILES cppcheck-gui.svg DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
    install(FILES cppcheck-gui.png DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/64x64/apps)

    add_dependencies(cppcheck-gui copy_cfg)
    add_dependencies(cppcheck-gui copy_addons)
    add_dependencies(cppcheck-gui copy_platforms)
    if (NOT DISABLE_DMAKE)
        add_dependencies(cppcheck-gui run-dmake)
    endif()

    if (BUILD_TESTS)
        add_subdirectory(test)
    endif()
endif()