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
|
|
|
|
2023-03-31 10:37:53 +02:00
|
|
|
include(cmake/cxx11.cmake)
|
|
|
|
use_cxx11()
|
|
|
|
|
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-09-26 18:21:43 +02:00
|
|
|
include(cmake/ccache.cmake)
|
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)
|
2022-04-15 18:49:24 +02:00
|
|
|
include(cmake/printInfo.cmake)
|
2022-08-28 00:21:10 +02:00
|
|
|
if(BUILD_GUI)
|
2022-02-07 17:35:25 +01:00
|
|
|
include(cmake/qtCompat.cmake)
|
|
|
|
endif()
|
2019-06-28 06:57:05 +02:00
|
|
|
|
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
|
|
|
|
2022-08-28 00:21:10 +02:00
|
|
|
if(LIBXML2_XMLLINT_EXECUTABLE)
|
2022-06-03 23:07:28 +02:00
|
|
|
add_custom_target(validateCFG DEPENDS validateCFG-cmd)
|
|
|
|
add_custom_command(OUTPUT validateCFG-cmd
|
|
|
|
COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng)
|
2020-11-02 20:16:15 +01:00
|
|
|
foreach(cfg ${cfgs})
|
2022-06-03 23:07:28 +02:00
|
|
|
add_custom_command(OUTPUT validateCFG-cmd APPEND
|
|
|
|
COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng ${cfg})
|
2020-11-02 20:16:15 +01:00
|
|
|
endforeach()
|
2022-06-03 23:07:28 +02:00
|
|
|
# this is a symbolic name for a build rule and not an output file
|
|
|
|
set_source_files_properties(validateCFG-cmd PROPERTIES SYMBOLIC "true")
|
2022-04-13 20:56:07 +02:00
|
|
|
|
2022-08-06 19:56:32 +02:00
|
|
|
add_custom_target(validatePlatforms ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/platforms/cppcheck-platforms.rng)
|
|
|
|
foreach(platform ${platforms})
|
|
|
|
get_filename_component(platformname ${platform} NAME_WE)
|
|
|
|
add_custom_target(validatePlatforms-${platformname} ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/platforms/cppcheck-platforms.rng ${platform})
|
|
|
|
add_dependencies(validatePlatforms validatePlatforms-${platformname})
|
|
|
|
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)
|
|
|
|
|
2023-12-17 15:42:17 +01:00
|
|
|
add_custom_target(example-xml $<TARGET_FILE:cppcheck> --xml --enable=all --inconclusive --max-configs=1 ${CMAKE_SOURCE_DIR}/samples -i${CMAKE_SOURCE_DIR}/samples/syntaxError/bad.c 2> ${CMAKE_BINARY_DIR}/example.xml
|
2022-04-13 20:56:07 +02:00
|
|
|
DEPENDS cppcheck)
|
|
|
|
|
|
|
|
add_custom_target(createXMLExamples DEPENDS errorlist-xml example-xml)
|
|
|
|
|
2022-08-28 00:21:10 +02:00
|
|
|
if(PYTHON_EXECUTABLE)
|
2022-04-13 20:56:07 +02:00
|
|
|
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()
|
|
|
|
|
2022-08-28 00:21:10 +02:00
|
|
|
if(BUILD_TESTS)
|
2015-11-26 21:01:07 +01:00
|
|
|
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}")
|
|
|
|
|
2023-01-26 22:05:40 +01:00
|
|
|
add_custom_target(copy_platforms ALL
|
|
|
|
${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/platforms"
|
|
|
|
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/platforms"
|
|
|
|
COMMENT "Copying platforms 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)
|
2022-08-28 00:21:10 +02:00
|
|
|
add_subdirectory(lib) # CppCheck Library
|
2015-02-13 19:00:14 +01:00
|
|
|
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
|
|
|
|
add_subdirectory(tools)
|
2023-10-09 22:20:36 +02:00
|
|
|
add_subdirectory(man)
|
2015-02-13 19:00:14 +01:00
|
|
|
|
2020-04-02 13:55:49 +02:00
|
|
|
include(cmake/clang_tidy.cmake)
|