Re: [cmake-developers] Code style auto-formatting
On Thu, Nov 19, 2015 at 3:26 PM, Brad Kingwrote: > On 11/19/2015 09:22 AM, Robert Dailey wrote: >> Tonight I will do some testing and submit a patch + example files >> converted to the style Brad suggested. We can fine-tune it as needed. > > Rather than a patch please work on a script to perform the conversion. > Then at any time we can choose to run the script as the one-shot conversion > and commit as a robot user. Any sweeping patch would be too big to > post to the list anyway. Ideally the script should be simple enough > to cut-n-paste into a shell so we can just record it in the commit > message. > > See this commit for an example of this approach: > > https://cmake.org/gitweb?p=cmake.git;a=commit;h=7bbaa428 It took a while, but i figured out .clang-format definitions (there are two required) and a script that, after applying, does not break compilation and unit tests. The .clang-format for the root directory looks like this: --- BasedOnStyle: Mozilla AlignAfterOpenBracket: false AlignOperands: false AllowShortFunctionsOnASingleLine: None AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None ColumnLimit: 79 ContinuationIndentWidth: 4 IncludeCategories: - Regex: 'cmStandardIncludes' Priority: -1 Standard: Cpp03 ... This is the script to perform the reformatting of most C/C++ source code: git ls-files -z -- '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' \ | egrep -z -v '(Lexer|Parser|ParserHelper)\.' \ | egrep -z -v '^(Utilities/(KW|cm).*/|Source/(kwsys|CursesDialog/form)/)' \ | egrep -z -v '^Tests/Module/GenerateExportHeader' \ | egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' \ | xargs -0 clang-format -i I have attached a patch that adds the .clang-format and two other patches that need to be applied before reformatting. I have pushed all those changes (including reformatting) to github: https://github.com/purpleKarrot/CMake/commits/clang-format Notes: * Trying to reformat Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h makes clang-format crash. * Clang-Format dedents preprocessor directives. See also: https://llvm.org/bugs/show_bug.cgi?id=17362 * I did not include '*.in' files in the list, because Clang-Format does strange things to @VARIALES@. Please feel free to add/remove options from the .clang-format files. IncludeCategories and Standard should stay as they are. cheers, Daniel From 452087a4b9f05742aed38040ab8d9b970fd05719 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Wed, 27 Apr 2016 22:47:02 +0200 Subject: [PATCH 1/3] CursesDialog: add missing cmState include --- Source/CursesDialog/cmCursesMainForm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index 255c823..d194168 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -13,6 +13,7 @@ #define cmCursesMainForm_h #include "../cmStandardIncludes.h" +#include "../cmState.h" #include "cmCursesForm.h" #include "cmCursesStandardIncludes.h" -- 2.8.0 From de7ca8575286bf995a771f894bf5087698686482 Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Wed, 27 Apr 2016 23:29:43 +0200 Subject: [PATCH 2/3] StringFileTest: add blank line between includes This test generates a header file which is not self-contained. Since Clang-Format reorders includes alphabetically, this makes the test fail. Add a blank line to introduce a logical separation between two blocks of include files. --- Tests/StringFileTest/StringFile.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Tests/StringFileTest/StringFile.cxx b/Tests/StringFileTest/StringFile.cxx index 9eba6bf..073e30c 100644 --- a/Tests/StringFileTest/StringFile.cxx +++ b/Tests/StringFileTest/StringFile.cxx @@ -1,5 +1,6 @@ #include #include + #include "OutputFile.h" int main(int, char*[]) -- 2.8.0 From 8feb2d2efc1287048ca66305db222bb197dcba4d Mon Sep 17 00:00:00 2001 From: Daniel Pfeifer Date: Wed, 27 Apr 2016 20:31:23 +0200 Subject: [PATCH 3/3] add .clang-format configuration files For most of the code, Standard must be set to Cpp03, so that `A` is not rewritten as `A`. For the code under Tests/CompileFeatures, Standard must be set to Cpp11, so that `U"foo"` is not rewritten as `U "foo"`. Priorize the "cmStandardIncludes.h" header, so that it is always included first. --- .clang-format | 14 ++ Tests/CompileFeatures/.clang-format | 11 +++ 2 files changed, 25 insertions(+) create mode 100644 .clang-format create mode 100644 Tests/CompileFeatures/.clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 000..4076bcd --- /dev/null +++ b/.clang-format @@ -0,0 +1,14 @@ +--- +BasedOnStyle: Mozilla +AlignAfterOpenBracket: false +AlignOperands: false +AllowShortFunctionsOnASingleLine: None
Re: [cmake-developers] Integration of clang-tidy
On Wed, Apr 27, 2016 at 3:10 PM, Brad Kingwrote: > On 04/26/2016 05:32 PM, Daniel Pfeifer wrote: >> This is a follow up patch: > > Thanks. > >> -tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin()+1, orig_cmd.end()); >> +tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin(), orig_cmd.end()); > > What is the purpose of this hunk? Does clang-tidy expect to be > given the full compiler command line including "cc"? This does > not look related to the change described in the commit message. It is unrelated. Clang-Tidy picks the interesting pieces from the compiler command line and ignores the rest. Whether cc is given or not makes no difference. But maybe we should leave the decision what to pick to Clang-Tidy? It may be clearer to forward the original command line unmodified. -- 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] Integration of clang-tidy
On Wed, Apr 27, 2016 at 10:47 PM, Gregor Jasnywrote: > Hallo Daniel, > > On 09/04/16 00:31, Daniel Pfeifer wrote: >> 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. > > I'm wondering what's the advantage of having this built-in support for > clang tidy over using the generated compile command database instead? The compile command database is just this: a database of compile commands. It does not execute clang-tidy at all. To execute clang-tidy for all source files that are listed in the database, you need a separate tool. There is this one, which requires Python: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/run-clang-tidy.py Having this functionality built into CMake means: * No additional dependencies. * Warning messages inside your IDE. * Warning messages on CDash. Since clang-tidy is executed directly before the compiler for each individual source file, you may set CMAKE_CXX_CLANG_TIDY to "clang-tidy;-fix-errors" and successfully compile invalid code. :-) -- 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] RFC: LLVM community CMake documentation
Hello cmake-developers, Earlier this year the LLVM community finished migrating to CMake as our one and only build system. One of the lingering things on my to-do list to help this transition is to write some basic documentation for the CMake language to help LLVM developers get a feel for the language. I’ve attached the working draft of my documentation, and would greatly appreciate any feedback from members of the CMake community. While it is not my goal to be a definitive source, I would like to be as accurate as I can be. Thank you, -Chris CMakePrimer.rst Description: Binary data -- 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] Integration of clang-tidy
Hallo Daniel, On 09/04/16 00:31, Daniel Pfeifer wrote: > 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. I'm wondering what's the advantage of having this built-in support for clang tidy over using the generated compile command database instead? Thanks, Gregor -- 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] Integration of clang-tidy
On 04/26/2016 05:32 PM, Daniel Pfeifer wrote: > This is a follow up patch: Thanks. > -tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin()+1, orig_cmd.end()); > +tidy_cmd.insert(tidy_cmd.end(), orig_cmd.begin(), orig_cmd.end()); What is the purpose of this hunk? Does clang-tidy expect to be given the full compiler command line including "cc"? This does not look related to the change described in the commit message. I've applied the change without that hunk: Clang-Tidy: copy stdout to sterr; ignore original stderr https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=04d74a7f 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
[cmake-developers] [CMake 0016085]: No Android Studio Generator
The following issue has been SUBMITTED. == https://cmake.org/Bug/view.php?id=16085 == Reported By:nguillot Assigned To: == Project:CMake Issue ID: 16085 Category: Modules Reproducibility:always Severity: feature Priority: high Status: new == Date Submitted: 2016-04-27 08:02 EDT Last Modified: 2016-04-27 08:02 EDT == Summary:No Android Studio Generator Description: With the Android Experimental Gradle plugin (http://tools.android.com/tech-docs/new-build-system/gradle-experimental) you enable the Android Studio C/C++ debug support. You can use either the "com.android.model.application" (Android application with Java and C/C++ sources code) , either "com.android.model.library" (Android Library with java and C/C++ sources) or "com.android.model.native" (only C/C++ sources) plugin to do that. As explain in the "Other Build Options" section the Gradle "ndk" section describe the compilation and linking options. The "NDK Dependencies" section of this page explain how to manage the dependency between the libraries. Additional Information: You can start with project that I published on Github to make your own experiment: https://github.com/nguillot/HelloCPP. Or use the official samples: https://github.com/googlesamples/android-ndk. == Issue History Date ModifiedUsername FieldChange == 2016-04-27 08:02 nguillot New Issue == -- 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] [CMake 0016084]: try_compile incorrect behavior for iOS universal build (device + simulator) with CMAKE_IOS_INSTALL_COMBINED
The following issue has been SUBMITTED. == https://cmake.org/Bug/view.php?id=16084 == Reported By:ranjak Assigned To: == Project:CMake Issue ID: 16084 Category: CMake Reproducibility:always Severity: major Priority: normal Status: new == Date Submitted: 2016-04-27 06:41 EDT Last Modified: 2016-04-27 06:41 EDT == Summary:try_compile incorrect behavior for iOS universal build (device + simulator) with CMAKE_IOS_INSTALL_COMBINED Description: When configuring an iOS Xcode project using CMAKE_IOS_INSTALL_COMBINED (introduced in CMake 3.5) to produce universal binaries that contain code for both iPhone (ARM) and simulator (x86) code, I would like try_compile to compile for both the device and the simulator. However, currently, try_compile only compiles for the device. This causes projects that rely on try_compile to be possibly misconfigured for the simulator build (which can obviously lead to build failures and/or incorrect/non-existent values for architecture-dependent parameters set at configuration time). This problem also arises without CMAKE_IOS_INSTALL_COMBINED, if you want to use Xcode to build for both device(s) and simulator(s) without re-running CMake every time you switch between the two. Try_compile should instead call xcodebuild twice, one time with -sdk iphoneos and the other with -sdk iphonesimulator. Steps to Reproduce: Configure a project with IOS_INSTALL_COMBINED set to TRUE, and use try_compile in this project. == Issue History Date ModifiedUsername FieldChange == 2016-04-27 06:41 ranjak New Issue == -- 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] CMake API for warnings
On 26-Apr-16 01:58, Brad King wrote: On 04/23/2016 12:11 AM, Ruslan Baratov wrote: It means ignoring directory properties. So by default we will inherit settings. [snip] To disable inheriting we need to add extra argument (?) to *_compile_warnings: add_compile_warnings(DISABLE warn-A) target_compile_warnings(foo DISABLE warn-B IGNORE DIRECTORY) We don't have such a feature for any of the other build settings so there is no precedent for how to represent this or its exact semantics. Okay, fair enough, let's skip it. Ruslo -- 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