diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2017-08-16 16:24:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-08-30 14:23:46 (GMT) |
commit | 311b7b1a7095ec460fab950a6767571eb3b9652c (patch) | |
tree | 23843c9cd26d9d150e76fadda88a8fbf47d5f12c /Tests/RunCMake/Cppcheck | |
parent | fff28e30cd01a88b2e5f67db2aaf4c068f1bfc89 (diff) | |
download | CMake-311b7b1a7095ec460fab950a6767571eb3b9652c.zip CMake-311b7b1a7095ec460fab950a6767571eb3b9652c.tar.gz CMake-311b7b1a7095ec460fab950a6767571eb3b9652c.tar.bz2 |
Add properties to run cppcheck along with the compiler
Create a `<LANG>_CPPCHECK` target property (initialized by a
`CMAKE_<LANG>_CPPCHECK` variable) to specify a `cppcheck` command line
to be run along with the compiler.
Diffstat (limited to 'Tests/RunCMake/Cppcheck')
-rw-r--r-- | Tests/RunCMake/Cppcheck/C-Build-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/C-launch.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/C.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/CXX-launch.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/CXX.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/RunCMakeTest.cmake | 22 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/main.c | 4 | ||||
-rw-r--r-- | Tests/RunCMake/Cppcheck/main.cxx | 4 |
12 files changed, 50 insertions, 0 deletions
diff --git a/Tests/RunCMake/Cppcheck/C-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-Build-stdout.txt new file mode 100644 index 0000000..26eded3 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C-Build-stdout.txt @@ -0,0 +1 @@ +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt new file mode 100644 index 0000000..26eded3 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/Cppcheck/C-launch.cmake b/Tests/RunCMake/Cppcheck/C-launch.cmake new file mode 100644 index 0000000..e66ca20 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C.cmake) diff --git a/Tests/RunCMake/Cppcheck/C.cmake b/Tests/RunCMake/Cppcheck/C.cmake new file mode 100644 index 0000000..b1f5bf7 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/C.cmake @@ -0,0 +1,4 @@ + +enable_language(C) +set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}") +add_executable(main main.c) diff --git a/Tests/RunCMake/Cppcheck/CMakeLists.txt b/Tests/RunCMake/Cppcheck/CMakeLists.txt new file mode 100644 index 0000000..a640c56 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.7) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt b/Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt new file mode 100644 index 0000000..26eded3 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/CXX-Build-stdout.txt @@ -0,0 +1 @@ +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt b/Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt new file mode 100644 index 0000000..26eded3 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/CXX-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*Warning: cppcheck reported diagnostics.*error.*warning.*style.*performance.*information.* diff --git a/Tests/RunCMake/Cppcheck/CXX-launch.cmake b/Tests/RunCMake/Cppcheck/CXX-launch.cmake new file mode 100644 index 0000000..3002c9d --- /dev/null +++ b/Tests/RunCMake/Cppcheck/CXX-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX.cmake) diff --git a/Tests/RunCMake/Cppcheck/CXX.cmake b/Tests/RunCMake/Cppcheck/CXX.cmake new file mode 100644 index 0000000..3b79471 --- /dev/null +++ b/Tests/RunCMake/Cppcheck/CXX.cmake @@ -0,0 +1,3 @@ +enable_language(CXX) +set(CMAKE_CXX_CPPCHECK "${PSEUDO_CPPCHECK}") +add_executable(main main.cxx) diff --git a/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake new file mode 100644 index 0000000..ae14f8c --- /dev/null +++ b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake @@ -0,0 +1,22 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS "-DPSEUDO_CPPCHECK=${PSEUDO_CPPCHECK}") + +function(run_cppcheck lang) + # Use a single build tree for tests without cleaning. + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${lang}-build") + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${lang}) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(${lang}-Build ${CMAKE_COMMAND} --build .) +endfunction() + +run_cppcheck(C) +run_cppcheck(CXX) + +if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_cppcheck(C-launch) + run_cppcheck(CXX-launch) +endif() diff --git a/Tests/RunCMake/Cppcheck/main.c b/Tests/RunCMake/Cppcheck/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/Cppcheck/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} diff --git a/Tests/RunCMake/Cppcheck/main.cxx b/Tests/RunCMake/Cppcheck/main.cxx new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/RunCMake/Cppcheck/main.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} |