2020-04-22 11:04:19 +02:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
2018-07-23 08:34:41 +02:00
|
|
|
project(Cppcheck)
|
2015-02-13 19:00:14 +01:00
|
|
|
|
2020-04-02 13:55:49 +02:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2015-11-26 20:25:09 +01:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2022-02-05 17:57:32 +01:00
|
|
|
include(cmake/compilerCheck.cmake)
|
2020-04-02 13:55:49 +02:00
|
|
|
include(cmake/versions.cmake)
|
|
|
|
include(cmake/options.cmake)
|
|
|
|
include(cmake/findDependencies.cmake)
|
|
|
|
include(cmake/compileroptions.cmake)
|
|
|
|
include(cmake/compilerDefinitions.cmake)
|
|
|
|
include(cmake/buildFiles.cmake)
|
|
|
|
include(cmake/cxx11.cmake)
|
2022-02-07 17:35:25 +01:00
|
|
|
if (BUILD_GUI)
|
|
|
|
include(cmake/qtCompat.cmake)
|
|
|
|
endif()
|
2019-06-28 06:57:05 +02:00
|
|
|
|
|
|
|
use_cxx11()
|
2015-02-13 19:00:14 +01:00
|
|
|
|
2019-08-17 10:53:07 +02:00
|
|
|
file(GLOB addons "addons/*.py")
|
2015-02-13 19:00:14 +01:00
|
|
|
file(GLOB cfgs "cfg/*.cfg")
|
2019-08-17 10:53:07 +02:00
|
|
|
file(GLOB platforms "platforms/*.xml")
|
2015-02-13 19:00:14 +01:00
|
|
|
|
2020-11-02 20:16:15 +01:00
|
|
|
if (LIBXML2_XMLLINT_EXECUTABLE)
|
|
|
|
add_custom_target(validateCFG ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng)
|
|
|
|
foreach(cfg ${cfgs})
|
|
|
|
get_filename_component(cfgname ${cfg} NAME_WE)
|
|
|
|
add_custom_target(validateCFG-${cfgname} ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng ${cfg})
|
|
|
|
add_dependencies(validateCFG validateCFG-${cfgname})
|
|
|
|
endforeach()
|
2022-04-13 20:56:07 +02:00
|
|
|
|
|
|
|
add_custom_target(errorlist-xml $<TARGET_FILE:cppcheck> --errorlist > ${CMAKE_BINARY_DIR}/errorlist.xml
|
|
|
|
DEPENDS cppcheck)
|
|
|
|
|
|
|
|
add_custom_target(example-xml $<TARGET_FILE:cppcheck> --xml --enable=all --inconclusive --max-configs=1 ${CMAKE_SOURCE_DIR}/samples 2> ${CMAKE_BINARY_DIR}/example.xml
|
|
|
|
DEPENDS cppcheck)
|
|
|
|
|
|
|
|
add_custom_target(createXMLExamples DEPENDS errorlist-xml example-xml)
|
|
|
|
|
|
|
|
if (PYTHON_EXECUTABLE)
|
|
|
|
add_custom_target(checkCWEEntries ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/listErrorsWithoutCWE.py -F ${CMAKE_BINARY_DIR}/errorlist.xml
|
|
|
|
DEPENDS errorlist-xml)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_target(validateXML ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/cppcheck-errors.rng
|
|
|
|
COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/cppcheck-errors.rng ${CMAKE_BINARY_DIR}/errorlist.xml
|
|
|
|
COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/cppcheck-errors.rng ${CMAKE_BINARY_DIR}/example.xml
|
|
|
|
DEPENDS createXMLExamples
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(validateRules ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/rules/*.xml)
|
2020-11-02 20:16:15 +01:00
|
|
|
endif()
|
|
|
|
|
2015-11-26 21:01:07 +01:00
|
|
|
if (BUILD_TESTS)
|
|
|
|
enable_testing()
|
|
|
|
endif()
|
|
|
|
|
2021-08-12 20:17:51 +02:00
|
|
|
add_custom_target(copy_cfg ALL
|
|
|
|
${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/cfg"
|
|
|
|
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/cfg"
|
|
|
|
COMMENT "Copying cfg files to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}")
|
|
|
|
|
|
|
|
add_custom_target(copy_addons ALL
|
|
|
|
${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/addons"
|
|
|
|
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/addons"
|
|
|
|
COMMENT "Copying addons files to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}")
|
|
|
|
|
2020-11-22 08:57:07 +01:00
|
|
|
if(USE_BUNDLED_TINYXML2)
|
|
|
|
message(STATUS "Using bundled version of tinyxml2")
|
|
|
|
add_subdirectory(externals/tinyxml2)
|
|
|
|
endif()
|
2016-08-06 18:21:54 +02:00
|
|
|
add_subdirectory(externals/simplecpp)
|
2015-02-13 19:00:14 +01:00
|
|
|
add_subdirectory(lib) # CppCheck Library
|
|
|
|
add_subdirectory(cli) # Client application
|
|
|
|
add_subdirectory(test) # Tests
|
2020-05-10 16:41:50 +02:00
|
|
|
add_subdirectory(gui) # Graphical application
|
|
|
|
add_subdirectory(tools/triage) # Triage tool
|
2020-03-31 09:33:58 +02:00
|
|
|
add_subdirectory(oss-fuzz) # OSS-Fuzz clients
|
2020-05-10 16:41:50 +02:00
|
|
|
add_subdirectory(tools)
|
2015-02-13 19:00:14 +01:00
|
|
|
|
2020-04-02 13:55:49 +02:00
|
|
|
include(cmake/printInfo.cmake)
|
|
|
|
include(cmake/clang_tidy.cmake)
|