[Cmake-commits] CMake branch, master, updated. v3.13.0-rc1-100-g7bacb22

Kitware Robot kwrobot at kitware.com
Fri Oct 12 08:25:04 EDT 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, master has been updated
       via  7bacb2295583f1a0e04a7312c370064310b1834b (commit)
       via  1cfe2442c4196e592a6d99c7a2a4f5aa94038a78 (commit)
       via  f76047f34a960272ca29518551fb23504c61ee7e (commit)
       via  3b80cd77fb3e1d0ee6a77a590830e7dc620df1a5 (commit)
      from  0d8a4ded12f621a410b60117a64b7842649f0d1d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7bacb2295583f1a0e04a7312c370064310b1834b
commit 7bacb2295583f1a0e04a7312c370064310b1834b
Merge: 1cfe244 3b80cd7
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Oct 12 12:17:51 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Oct 12 08:17:58 2018 -0400

    Merge topic 'cppcheck-exit-code'
    
    3b80cd77fb Fail the build if cppcheck returns a non-zero exit code
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2459


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1cfe2442c4196e592a6d99c7a2a4f5aa94038a78
commit 1cfe2442c4196e592a6d99c7a2a4f5aa94038a78
Merge: 0d8a4de f76047f
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Oct 12 12:15:17 2018 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Oct 12 08:15:25 2018 -0400

    Merge topic 'find_libinput'
    
    f76047f34a FindLibinput: Add module to find libinput
    
    Acked-by: Kitware Robot <kwrobot at kitware.com>
    Merge-request: !2420


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f76047f34a960272ca29518551fb23504c61ee7e
commit f76047f34a960272ca29518551fb23504c61ee7e
Author:     Frederik Gladhorn <gladhorn at kde.org>
AuthorDate: Thu Sep 27 09:41:02 2018 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Oct 11 10:43:45 2018 -0400

    FindLibinput: Add module to find libinput
    
    This module is inspired by one from KDE's KWin.

diff --git a/Copyright.txt b/Copyright.txt
index 743c634..0b0fbf1 100644
--- a/Copyright.txt
+++ b/Copyright.txt
@@ -39,6 +39,7 @@ The following individuals and institutions are among the Contributors:
 * Alexander Neundorf <neundorf at kde.org>
 * Alexander Smorkalov <alexander.smorkalov at itseez.com>
 * Alexey Sokolov <sokolov at google.com>
+* Alex Merry <alex.merry at kde.org>
 * Alex Turbov <i.zaufi at gmail.com>
 * Andreas Pakulat <apaku at gmx.de>
 * Andreas Schneider <asn at cryptomilk.org>
@@ -65,6 +66,7 @@ The following individuals and institutions are among the Contributors:
 * Kelly Thompson <kgt at lanl.gov>
 * Konstantin Podsvirov <konstantin at podsvirov.pro>
 * Mario Bensi <mbensi at ipsquad.net>
+* Martin Gräßlin <mgraesslin at kde.org>
 * Mathieu Malaterre <mathieu.malaterre at gmail.com>
 * Matthaeus G. Chajdas
 * Matthias Kretz <kretz at kde.org>
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index af8e33f..f9b4afb 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -165,6 +165,7 @@ They are normally called through the :command:`find_package` command.
    /module/FindLAPACK
    /module/FindLATEX
    /module/FindLibArchive
+   /module/FindLibinput
    /module/FindLibLZMA
    /module/FindLibXml2
    /module/FindLibXslt
diff --git a/Help/module/FindLibinput.rst b/Help/module/FindLibinput.rst
new file mode 100644
index 0000000..a8ca0b0
--- /dev/null
+++ b/Help/module/FindLibinput.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindLibinput.cmake
diff --git a/Help/release/dev/find_libinput.rst b/Help/release/dev/find_libinput.rst
new file mode 100644
index 0000000..ebb9e7a
--- /dev/null
+++ b/Help/release/dev/find_libinput.rst
@@ -0,0 +1,6 @@
+find_libinput
+-------------
+
+* The :module:`FindLibinput` module was added to find `libinput`_.
+
+.. _`libinput`: https://www.freedesktop.org/wiki/Software/libinput/
diff --git a/Modules/FindLibinput.cmake b/Modules/FindLibinput.cmake
new file mode 100644
index 0000000..df66cff
--- /dev/null
+++ b/Modules/FindLibinput.cmake
@@ -0,0 +1,83 @@
+# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindLibinput
+------------
+
+Find libinput headers and library.
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+``Libinput::Libinput``
+  The libinput library, if found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This will define the following variables in your project:
+
+``Libinput_FOUND``
+  true if (the requested version of) libinput is available.
+``Libinput_VERSION``
+  the version of libinput.
+``Libinput_LIBRARIES``
+  the libraries to link against to use libinput.
+``Libinput_INCLUDE_DIRS``
+  where to find the libinput headers.
+``Libinput_DEFINITIONS``
+  this should be passed to target_compile_options(), if the
+  target is not used for linking
+
+#]=======================================================================]
+
+
+# Use pkg-config to get the directories and then use these values
+# in the FIND_PATH() and FIND_LIBRARY() calls
+find_package(PkgConfig QUIET)
+pkg_check_modules(PKG_Libinput QUIET libinput)
+
+set(Libinput_DEFINITIONS ${PKG_Libinput_CFLAGS_OTHER})
+set(Libinput_VERSION ${PKG_Libinput_VERSION})
+
+find_path(Libinput_INCLUDE_DIR
+  NAMES
+    libinput.h
+  HINTS
+    ${PKG_Libinput_INCLUDE_DIRS}
+)
+find_library(Libinput_LIBRARY
+  NAMES
+    input
+  HINTS
+    ${PKG_Libinput_LIBRARY_DIRS}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Libinput
+  FOUND_VAR
+    Libinput_FOUND
+  REQUIRED_VARS
+    Libinput_LIBRARY
+    Libinput_INCLUDE_DIR
+  VERSION_VAR
+    Libinput_VERSION
+)
+
+if(Libinput_FOUND AND NOT TARGET Libinput::Libinput)
+  add_library(Libinput::Libinput UNKNOWN IMPORTED)
+  set_target_properties(Libinput::Libinput PROPERTIES
+    IMPORTED_LOCATION "${Libinput_LIBRARY}"
+    INTERFACE_COMPILE_OPTIONS "${Libinput_DEFINITIONS}"
+    INTERFACE_INCLUDE_DIRECTORIES "${Libinput_INCLUDE_DIR}"
+  )
+endif()
+
+mark_as_advanced(Libinput_LIBRARY Libinput_INCLUDE_DIR)
+
+if(Libinput_FOUND)
+  set(Libinput_LIBRARIES ${Libinput_LIBRARY})
+  set(Libinput_INCLUDE_DIRS ${Libinput_INCLUDE_DIR})
+  set(Libinput_VERSION_STRING ${Libinput_VERSION})
+endif()
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 0de6c41..9e192be 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1409,6 +1409,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
     add_subdirectory(FindLibRHash)
   endif()
 
+  if(CMake_TEST_FindLibinput)
+    add_subdirectory(FindLibinput)
+  endif()
+
   if(CMake_TEST_FindLibUV)
     add_subdirectory(FindLibUV)
   endif()
diff --git a/Tests/FindLibinput/CMakeLists.txt b/Tests/FindLibinput/CMakeLists.txt
new file mode 100644
index 0000000..8538a55
--- /dev/null
+++ b/Tests/FindLibinput/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindLibinput.Test COMMAND
+  ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+  --build-and-test
+  "${CMake_SOURCE_DIR}/Tests/FindLibinput/Test"
+  "${CMake_BINARY_DIR}/Tests/FindLibinput/Test"
+  ${build_generator_args}
+  --build-project TestFindLibinput
+  --build-options ${build_options}
+  --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+  )
diff --git a/Tests/FindLibinput/Test/CMakeLists.txt b/Tests/FindLibinput/Test/CMakeLists.txt
new file mode 100644
index 0000000..1cc68d4
--- /dev/null
+++ b/Tests/FindLibinput/Test/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.10)
+project(TestFindLibinput C)
+include(CTest)
+
+find_package(Libinput REQUIRED)
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt Libinput::Libinput)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${Libinput_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${Libinput_LIBRARIES})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindLibinput/Test/main.c b/Tests/FindLibinput/Test/main.c
new file mode 100644
index 0000000..3919962
--- /dev/null
+++ b/Tests/FindLibinput/Test/main.c
@@ -0,0 +1,13 @@
+#include <libinput.h>
+#include <stdio.h>
+
+int main()
+{
+  struct libinput_interface interface;
+  interface.open_restricted = 0;
+  interface.close_restricted = 0;
+  struct libinput* li;
+  li = libinput_udev_create_context(&interface, NULL, NULL);
+  printf("Found Libinput.\n");
+  return 0;
+}

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b80cd77fb3e1d0ee6a77a590830e7dc620df1a5
commit 3b80cd77fb3e1d0ee6a77a590830e7dc620df1a5
Author:     Harald Brinkmann <Harald.Brinkmann at detectomat.com>
AuthorDate: Tue Oct 9 08:18:29 2018 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Thu Oct 11 07:56:05 2018 -0400

    Fail the build if cppcheck returns a non-zero exit code
    
    This allows the build failure to be tuned with cppcheck's
    options --error-exitcode=<n> and --exitcode-suppressions=<file>.

diff --git a/Help/prop_tgt/LANG_CPPCHECK.rst b/Help/prop_tgt/LANG_CPPCHECK.rst
index 5f8be00..16b0f48 100644
--- a/Help/prop_tgt/LANG_CPPCHECK.rst
+++ b/Help/prop_tgt/LANG_CPPCHECK.rst
@@ -6,7 +6,9 @@ This property is supported only when ``<LANG>`` is ``C`` or ``CXX``.
 Specify a :ref:`;-list <CMake Language Lists>` containing a command line
 for the ``cppcheck`` static analysis tool.  The :ref:`Makefile Generators`
 and the :generator:`Ninja` generator will run ``cppcheck`` along with the
-compiler and report any problems.
+compiler and report any problems.  If the command-line specifies the
+exit code options to ``cppcheck`` then the build  will fail if the
+tool returns non-zero.
 
 This property is initialized by the value of the
 :variable:`CMAKE_<LANG>_CPPCHECK` variable if it is set when a target is
diff --git a/Help/release/dev/cppcheck-exit-code.rst b/Help/release/dev/cppcheck-exit-code.rst
new file mode 100644
index 0000000..d66c762
--- /dev/null
+++ b/Help/release/dev/cppcheck-exit-code.rst
@@ -0,0 +1,6 @@
+cppcheck-exit-code
+------------------
+
+* When using cppcheck via the :variable:`CMAKE_<LANG>_CPPCHECK` variable
+  or :prop_tgt:`<LANG>_CPPCHECK` property, the build will now fail if
+  ``cppcheck`` returns non-zero as configured by its command-line options.
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 1d2f741..e2225ff 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -323,11 +323,15 @@ static int HandleCppCheck(const std::string& runCmd,
       stdErr.find("(performance)") != std::string::npos ||
       stdErr.find("(portability)") != std::string::npos ||
       stdErr.find("(information)") != std::string::npos) {
-    std::cerr << "Warning: cppcheck reported diagnostics:\n";
+    if (ret == 0) {
+      std::cerr << "Warning: cppcheck reported diagnostics:\n";
+    } else {
+      std::cerr << "Error: cppcheck reported failure:\n";
+    }
   }
   std::cerr << stdErr;
-  // ignore errors so build continues
-  return 0;
+
+  return ret;
 }
 
 typedef int (*CoCompileHandler)(const std::string&, const std::string&,
diff --git a/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt b/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt
index 573541a..d197c91 100644
--- a/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt
+++ b/Tests/RunCMake/Cppcheck/C-bad-Build-result.txt
@@ -1 +1 @@
-0
+[^0]
diff --git a/Tests/RunCMake/Cppcheck/C-error-Build-result.txt b/Tests/RunCMake/Cppcheck/C-error-Build-result.txt
new file mode 100644
index 0000000..d197c91
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-error-Build-result.txt
@@ -0,0 +1 @@
+[^0]
diff --git a/Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt b/Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt
new file mode 100644
index 0000000..4a24c0c
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt
@@ -0,0 +1 @@
+.*Error: cppcheck reported failure.*error.*warning.*style.*performance.*information.*
diff --git a/Tests/RunCMake/Cppcheck/C-error.cmake b/Tests/RunCMake/Cppcheck/C-error.cmake
new file mode 100644
index 0000000..2254d75
--- /dev/null
+++ b/Tests/RunCMake/Cppcheck/C-error.cmake
@@ -0,0 +1,3 @@
+enable_language(C)
+set(CMAKE_C_CPPCHECK "${PSEUDO_CPPCHECK}" -error)
+add_executable(main main.c)
diff --git a/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake
index 5fd4ead..e395f36 100644
--- a/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Cppcheck/RunCMakeTest.cmake
@@ -15,6 +15,7 @@ endfunction()
 
 run_cppcheck(C)
 run_cppcheck(CXX)
+run_cppcheck(C-error)
 run_cppcheck(C-bad)
 
 if(NOT RunCMake_GENERATOR STREQUAL "Watcom WMake")
diff --git a/Tests/RunCMake/pseudo_cppcheck.c b/Tests/RunCMake/pseudo_cppcheck.c
index 75f3cec..5b1531b 100644
--- a/Tests/RunCMake/pseudo_cppcheck.c
+++ b/Tests/RunCMake/pseudo_cppcheck.c
@@ -5,13 +5,16 @@
 int main(int argc, char* argv[])
 {
   int i;
+  int result = 0;
   for (i = 1; i < argc; ++i) {
-    if (strcmp(argv[i], "-bad") == 0)
-      if (strcmp(argv[i], "-bad") == 0) {
-        fprintf(stdout, "stdout from bad command line arg '-bad'\n");
-        fprintf(stderr, "stderr from bad command line arg '-bad'\n");
-        return 1;
-      }
+    if (strcmp(argv[i], "-bad") == 0) {
+      fprintf(stdout, "stdout from bad command line arg '-bad'\n");
+      fprintf(stderr, "stderr from bad command line arg '-bad'\n");
+      return 1;
+    } else if (strcmp(argv[i], "-error") == 0) {
+      // The real cppcheck allows to set the exitcode with --error-exitcode
+      result = 5;
+    }
   }
   fprintf(stderr,
           "[/foo/bar.c:2]: (error) Array 'abc[10]' accessed at index 12,"
@@ -31,6 +34,6 @@ int main(int argc, char* argv[])
   fprintf(stderr,
           "[/foo/bar.c:2]: (information) cannot find all the include "
           "files (use --check-config for details)\n");
-  // we allow this to return 1 as we ignore it
-  return 1;
+
+  return result;
 }

-----------------------------------------------------------------------

Summary of changes:
 Copyright.txt                                      |  2 +
 Help/manual/cmake-modules.7.rst                    |  1 +
 Help/module/FindLibinput.rst                       |  1 +
 Help/prop_tgt/LANG_CPPCHECK.rst                    |  4 +-
 Help/release/dev/cppcheck-exit-code.rst            |  6 ++
 Help/release/dev/find_libinput.rst                 |  6 ++
 Modules/FindLibinput.cmake                         | 83 ++++++++++++++++++++++
 Source/cmcmd.cxx                                   | 10 ++-
 Tests/CMakeLists.txt                               |  4 ++
 Tests/{FindBZip2 => FindLibinput}/CMakeLists.txt   |  8 +--
 Tests/FindLibinput/Test/CMakeLists.txt             | 14 ++++
 Tests/FindLibinput/Test/main.c                     | 13 ++++
 Tests/RunCMake/Cppcheck/C-bad-Build-result.txt     |  2 +-
 .../C-error-Build-result.txt}                      |  0
 Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt   |  1 +
 Tests/RunCMake/Cppcheck/C-error.cmake              |  3 +
 Tests/RunCMake/Cppcheck/RunCMakeTest.cmake         |  1 +
 Tests/RunCMake/pseudo_cppcheck.c                   | 19 ++---
 18 files changed, 161 insertions(+), 17 deletions(-)
 create mode 100644 Help/module/FindLibinput.rst
 create mode 100644 Help/release/dev/cppcheck-exit-code.rst
 create mode 100644 Help/release/dev/find_libinput.rst
 create mode 100644 Modules/FindLibinput.cmake
 copy Tests/{FindBZip2 => FindLibinput}/CMakeLists.txt (52%)
 create mode 100644 Tests/FindLibinput/Test/CMakeLists.txt
 create mode 100644 Tests/FindLibinput/Test/main.c
 copy Tests/RunCMake/{GoogleTest/GoogleTest-test-missing-result.txt => Cppcheck/C-error-Build-result.txt} (100%)
 create mode 100644 Tests/RunCMake/Cppcheck/C-error-Build-stdout.txt
 create mode 100644 Tests/RunCMake/Cppcheck/C-error.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list