[cmake-developers] Integration of clang-tidy

2016-04-08 Thread Daniel Pfeifer
Hi,

I implemented the integration of `clang-tidy` along the lines of the
`include-what-you-use` integration.
There is a new `_CLANG_TIDY` target property that is initialized
with the value of the `CMAKE__CLANG_TIDY` variable.
It contains the command line for `clang-tidy` as a ;-list.

Example use:

$ cmake -DCMAKE_CXX_CLANG_TIDY:STRING="clang-tidy;-checks=-*,readability-*" ..
$ cmake --build .

It is also possible to let `clang-tidy` apply fixit hints directly:

$ cmake 
-DCMAKE_CXX_CLANG_TIDY:STRING="clang-tidy;-checks=-*,readability-redundant-string-cstr;-fix"
..

The output is recognized by CTest's diagnostic parser. I haven't
checked how they look on CDash.

cheers, Daniel
From c1996b295d2e49134b6f5ef2be690588e5bf2732 Mon Sep 17 00:00:00 2001
From: Daniel Pfeifer 
Date: Fri, 8 Apr 2016 22:09:27 +0200
Subject: [PATCH] Provide integration for clang-tidy

---
 Help/manual/cmake-properties.7.rst |  1 +
 Help/manual/cmake-variables.7.rst  |  1 +
 Help/prop_tgt/LANG_CLANG_TIDY.rst  | 13 
 Help/release/dev/clang-tidy.rst|  7 ++
 Help/variable/CMAKE_LANG_CLANG_TIDY.rst|  6 ++
 Source/cmMakefileTargetGenerator.cxx   | 19 -
 Source/cmNinjaTargetGenerator.cxx  | 18 -
 Source/cmTarget.cxx|  2 +
 Source/cmcmd.cxx   | 80 --
 Tests/RunCMake/CMakeLists.txt  |  2 +
 Tests/RunCMake/ClangTidy/C-Build-stdout.txt|  1 +
 Tests/RunCMake/ClangTidy/C-launch-Build-stdout.txt |  1 +
 Tests/RunCMake/ClangTidy/C-launch.cmake|  3 +
 Tests/RunCMake/ClangTidy/C.cmake   |  3 +
 Tests/RunCMake/ClangTidy/CMakeLists.txt|  3 +
 Tests/RunCMake/ClangTidy/CXX-Build-stdout.txt  |  1 +
 .../RunCMake/ClangTidy/CXX-launch-Build-stdout.txt |  1 +
 Tests/RunCMake/ClangTidy/CXX-launch.cmake  |  3 +
 Tests/RunCMake/ClangTidy/CXX.cmake |  3 +
 Tests/RunCMake/ClangTidy/RunCMakeTest.cmake| 22 ++
 Tests/RunCMake/ClangTidy/main.c|  1 +
 Tests/RunCMake/ClangTidy/main.cxx  |  1 +
 Tests/RunCMake/pseudo_tidy.c   | 16 +
 23 files changed, 181 insertions(+), 27 deletions(-)
 create mode 100644 Help/prop_tgt/LANG_CLANG_TIDY.rst
 create mode 100644 Help/release/dev/clang-tidy.rst
 create mode 100644 Help/variable/CMAKE_LANG_CLANG_TIDY.rst
 create mode 100644 Tests/RunCMake/ClangTidy/C-Build-stdout.txt
 create mode 100644 Tests/RunCMake/ClangTidy/C-launch-Build-stdout.txt
 create mode 100644 Tests/RunCMake/ClangTidy/C-launch.cmake
 create mode 100644 Tests/RunCMake/ClangTidy/C.cmake
 create mode 100644 Tests/RunCMake/ClangTidy/CMakeLists.txt
 create mode 100644 Tests/RunCMake/ClangTidy/CXX-Build-stdout.txt
 create mode 100644 Tests/RunCMake/ClangTidy/CXX-launch-Build-stdout.txt
 create mode 100644 Tests/RunCMake/ClangTidy/CXX-launch.cmake
 create mode 100644 Tests/RunCMake/ClangTidy/CXX.cmake
 create mode 100644 Tests/RunCMake/ClangTidy/RunCMakeTest.cmake
 create mode 100644 Tests/RunCMake/ClangTidy/main.c
 create mode 100644 Tests/RunCMake/ClangTidy/main.cxx
 create mode 100644 Tests/RunCMake/pseudo_tidy.c

diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 73d1142..3403dcd 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -197,6 +197,7 @@ Properties on Targets
/prop_tgt/JOB_POOL_COMPILE
/prop_tgt/JOB_POOL_LINK
/prop_tgt/LABELS
+   /prop_tgt/LANG_CLANG_TIDY
/prop_tgt/LANG_COMPILER_LAUNCHER
/prop_tgt/LANG_INCLUDE_WHAT_YOU_USE
/prop_tgt/LANG_VISIBILITY_PRESET
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 3f73b32..7cf3a3d 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -259,6 +259,7 @@ Variables that Control the Build
/variable/CMAKE_INSTALL_RPATH
/variable/CMAKE_INSTALL_RPATH_USE_LINK_PATH
/variable/CMAKE_IOS_INSTALL_COMBINED
+   /variable/CMAKE_LANG_CLANG_TIDY
/variable/CMAKE_LANG_COMPILER_LAUNCHER
/variable/CMAKE_LANG_INCLUDE_WHAT_YOU_USE
/variable/CMAKE_LANG_VISIBILITY_PRESET
diff --git a/Help/prop_tgt/LANG_CLANG_TIDY.rst b/Help/prop_tgt/LANG_CLANG_TIDY.rst
new file mode 100644
index 000..2887e23
--- /dev/null
+++ b/Help/prop_tgt/LANG_CLANG_TIDY.rst
@@ -0,0 +1,13 @@
+_CLANG_TIDY
+-
+
+This property is implemented only when  is ``C`` or ``CXX``.
+
+Specify a :ref:`;-list ` containing a command
+line for the ``clang-tidy`` tool.  The :ref:`Makefile Generators`
+and the :generator:`Ninja` generator will run this tool along with the
+compiler and report a warning if the tool reports any problems.
+
+This property is initialized by the value of
+the :variable:`CMAKE__CLANG_TIDY` variable if it is set
+when a target is created.
diff --git a/Help/release/dev/clang-ti

[cmake-developers] [CMake 0016056]: file(GENERATE) not processing variables from INPUT file

2016-04-08 Thread Mantis Bug Tracker

The following issue has been SUBMITTED. 
== 
https://cmake.org/Bug/view.php?id=16056 
== 
Reported By:johnnyzz
Assigned To:
== 
Project:CMake
Issue ID:   16056
Category:   CMake
Reproducibility:always
Severity:   minor
Priority:   normal
Status: new
== 
Date Submitted: 2016-04-08 19:18 CEST
Last Modified:  2016-04-08 19:18 CEST
== 
Summary:file(GENERATE) not processing variables from INPUT
file
Description: 
There is a bug when generating a file with:

file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/output1.txt" 
  INPUT ${CMAKE_SOURCE_DIR}/input.txt
)

file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/output2.txt" 
  CONTENT "SOURCE DIR = '${CMAKE_SOURCE_DIR}'"
)

- Using "INPUT filename", variables are not processed, but "CONTENT text" with
the same content works properly

Steps to Reproduce: 
1) cmake .
2) cat output1.txt
3) cat output2.txt

-> The variable in output1.txt is not replaced by its value
== 

Issue History 
Date ModifiedUsername   FieldChange   
== 
2016-04-08 19:18 johnnyzz   New Issue
2016-04-08 19:18 johnnyzz   File Added: CMakeLists.txt
==

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Suggest if function has lte gte operators

2016-04-08 Thread Harry Mallon
That is completely fair. Perhaps a bit of Friday brain from me. It still could 
reduce complexity if you are trying to do something more complicated.

In my opinion A is easier to read than B.

A: if ( $1 STRGREATER_EQ $2 AND $3 STRLESS $4 AND $5 STRLESS_EQ $6 )
B: if ( NOT $1 STRLESS $2 AND $3 STRLESS $4 AND NOT $5 STRGREATER $6)

H


Harry Mallon
CODEX | Software Engineer
60 Poland Street | London | England | W1F 7NT
E ha...@codexdigital.com | T +44 203 7000 989
> On 8 Apr 2016, at 15:42, Ben Boeckel  wrote:
>
> On Fri, Apr 08, 2016 at 14:24:08 +, Harry Mallon wrote:
>> CMake's "if" functionality is missing greater than or equal to and
>> less than or equal to. This change could be tweaked and added to
>> provide this functionality to avoid things like "if(VERSION_STRING
>> VERSION_GREATER "4.8.0" OR VERSION_STRING VERSION_EQUAL "4.8.0")".
>
> This can also be done as:
>
>if (NOT VERSION_STRING VERSION_LESS "4.8.0")
>
> I'm ambivalent on the idea of new operators. Documentation for this
> pattern would likely help.
>
> --Ben
>

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Suggest if function has lte gte operators

2016-04-08 Thread Brad King
On 04/08/2016 10:24 AM, Harry Mallon wrote:
> "if(VERSION_STRING VERSION_GREATER "4.8.0" OR VERSION_STRING VERSION_EQUAL 
> "4.8.0")".

As others have said this can be done with

if(NOT version VERSION_LESS 4.8.0)

> Commit on github:
> https://github.com/hm1992/CMake/commit/75b318f8809ae71685cad068cd2e8ce9f19fb28a

I don't think we have a strong use case for the proposed operators,
but I've taken a small cleanup from that commit:

 cmConditionEvaluator: Use pre-allocated keywords in more places
 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=aff4a5fa

Thanks,
-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Suggest if function has lte gte operators

2016-04-08 Thread Ben Boeckel
On Fri, Apr 08, 2016 at 14:24:08 +, Harry Mallon wrote:
> CMake's "if" functionality is missing greater than or equal to and
> less than or equal to. This change could be tweaked and added to
> provide this functionality to avoid things like "if(VERSION_STRING
> VERSION_GREATER "4.8.0" OR VERSION_STRING VERSION_EQUAL "4.8.0")".

This can also be done as:

if (NOT VERSION_STRING VERSION_LESS "4.8.0")

I'm ambivalent on the idea of new operators. Documentation for this
pattern would likely help.

--Ben
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Suggest if function has lte gte operators

2016-04-08 Thread Rolf Eike Beer
Am Freitag, 8. April 2016, 14:24:08 schrieb Harry Mallon:
> CMake's "if" functionality is missing greater than or equal to and less than
> or equal to. This change could be tweaked and added to provide this
> functionality to avoid things like "if(VERSION_STRING VERSION_GREATER
> "4.8.0" OR VERSION_STRING VERSION_EQUAL "4.8.0")".
> 
> Commit on github:
> https://github.com/hm1992/CMake/commit/75b318f8809ae71685cad068cd2e8ce9f19fb
> 28a
> 
> Would this be of interest for merging? I don't really have the time to do
> extensive testing on it at the moment.

The common way is to use the power of not:

LTE -> NOT GE
GTE -> NOT LE

Greetings,

Eike

signature.asc
Description: This is a digitally signed message part.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

[cmake-developers] Suggest if function has lte gte operators

2016-04-08 Thread Harry Mallon
CMake's "if" functionality is missing greater than or equal to and less than or 
equal to. This change could be tweaked and added to provide this functionality 
to avoid things like "if(VERSION_STRING VERSION_GREATER "4.8.0" OR 
VERSION_STRING VERSION_EQUAL "4.8.0")".

Commit on github:
https://github.com/hm1992/CMake/commit/75b318f8809ae71685cad068cd2e8ce9f19fb28a

Would this be of interest for merging? I don't really have the time to do 
extensive testing on it at the moment.

Harry

Harry Mallon

CODEX | Software Engineer

60 Poland Street | London | England | W1F 7NT

E ha...@codexdigital.com | T +44 203 7000 
989

Website | Facebook 
| Twitter

[http://www.codexdigital.com/?action=asset&id=83095F5A-2233-47F5-9598-19228D7E37AE]
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers