Commit Graph

39 Commits

Author SHA1 Message Date
Zsolt Parragi
d625dfcdf9 Avoid compiling CMake itself as C++17 with Clang's MSVC ABI
GUID functions in ATL cause compilation errors with this compiler.
Add the offending case to our check for C++17 support so that it
is not used by default when it does not work.
2019-02-11 15:04:19 +01:00
Brad King
2ca89b5a69 C++ feature checks: Filter out libstdc++ sprintf warnings
On OpenBSD linking to `libstdc++` with GCC 6.4 always warns:

    warning: sprintf() is often misused, please use snprintf()

These do not affect the availability of C++ features we're checking,
so filter them out.

Fixes: #18602
2018-11-20 12:50:45 -05:00
Brad King
3a2c736b41 Extend C++17/C++14 feature checks to require unique_ptr
When testing compiler modes higher than C++11 for constructs we need,
include a check for using `unique_ptr` in that mode.  The PGI 18.4
compiler in some environments supports `unique_ptr` in C++11 mode
but is broken for C++14 and C++17.  Check that `unique_ptr` works
in these modes before using one.
2018-08-01 14:03:43 -04:00
Gregor Jasny
057ecb8f6f C++ feature checks: Ignore Xcode warnings 2018-06-19 10:56:50 -04:00
luz.paz
be28106880 Fix misc. typos
Found via `codespell` and `grep`
2018-06-04 10:32:49 -04:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2018-06-01 09:53:42 -04:00
Brad King
ddff7aebbc Merge topic 'cxx-checks-tolerate-more-warnings'
2254b72061 C++ feature checks: Filter out warnings caused by local configuration

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2019
2018-04-30 09:21:16 -04:00
Brad King
2254b72061 C++ feature checks: Filter out warnings caused by local configuration
In some environments the linker produces warnings like

    warning: directory not found for option
    warning: object file compiled with -mlong-branch ...

These do not affect the availability of C++ features we're checking,
so filter them out.

Fixes: #17850, #17947
2018-04-30 09:18:15 -04:00
Brad King
99bf77f49c ccmake: Check for curses more robustly before enabling
Compute a default for `BUILD_CursesDialog` by building a small test
project that uses curses.  Disable `ccmake` by default if it fails,
and do not search for Curses as part of the main build.  This avoids
creating FindCurses cache entries when we are not considering ccmake.

If `BUILD_CursesDialog` is enabled (e.g. by the user) then warn if
curses cannot be found.
2018-03-21 13:57:45 -04:00
Brad King
31d59ff3b1 Compile CMake as C++17 if supported by the compiler
Add a check that a simple source file can compile as C++17 that uses
some of the features we need.  Do this only when hosted by CMake 3.8
or above because those versions are aware of C++17.

Check for unordered_map as we do in bootstrap since commit 375eca7881
(bootstrap: Check support for unordered_map from compiler mode,
2017-11-30).  Also maintain the existing C++14 cstdio check.
2017-12-22 09:05:54 -05:00
Brad King
31c6b9adbf Generalize check for C++14 constructs
The check for C++14 and cstdio is a special case of the more general
problem of checking that the compiler's C++14 mode supports everything
we need.  Rename the checks accordingly.
2017-12-22 09:05:54 -05:00
Brad King
b2f612a0fa Simplify CM_FALLTHROUGH implementation
Use the macro now provided by KWSys instead of using `try_compile`
checks.  It will no longer consider the `__attribute__((fallthrough))`
variant, but compilers that don't have one of the modern attributes
shouldn't warn about not using one anyway.
2017-11-30 09:50:39 -05:00
Brad King
b8018135b5 Use C++11 '= delete' instead of CM_EQ_DELETE
We now require C++11 support including `= delete`.  Drop use of
the old compatibility macro.
2017-09-28 09:50:18 -04:00
Brad King
9e0362caa1 Remove checks for auto_ptr that we no longer need
We no longer use `auto_ptr` at all, so drop the checks for it.
2017-09-27 09:04:31 -04:00
Brad King
71b65abca2 C++ feature checks: Filter out warnings caused by user flags
Filter out `-Winvalid-command-line-argument` warnings from Clang (that
can be caused by user-specified flags) so that they do not break our
checks for C++ feature availability.
2017-09-19 09:25:30 -04:00
Brad King
eb3abf8b2b C++ feature checks: Prepare for multiple check output filters 2017-09-19 09:22:54 -04:00
Brad King
4e14498f4f Drop now-unused definition of CM_OVERRIDE 2017-09-15 10:06:41 -04:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Daniel Pfeifer
ac6660b671 Merge topic 'cxx11-unordered'
cbcfb79f Use C++11 unordered containers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1174
2017-08-23 05:11:40 -04:00
Daniel Pfeifer
cbcfb79f9c Use C++11 unordered containers 2017-08-22 23:05:27 +02:00
Brad King
e4aafbf596 Fix CM_FALLTHROUGH with -Wunused-parameter
Fix the test code that we `try_compile` to avoid unused parameter
warnings that cause the check to fail.
2017-08-22 08:13:30 -04:00
Brad King
f44d9bcc8f C++ feature checks: Improve exclusion of "0 Warning(s)"
Simply matching "0 Warning" may match "10 Warning(s)".  Instead remove
the entire `    0 Warning(s)` content from the MSBuild output before
searching it for warnings.

Issue: #16942
2017-06-08 09:22:09 -04:00
Walter Gray
f4ce396254 C++ feature checks: Do not match "0 Warning(s)" as a warning
The change in commit v3.9.0-rc1~6^2~1 (C++ feature checks: check output
for '[Ww]arning', 2017-06-03) accidentally matches `0 Warning(s)` in the
output and always thinks a warning exists, thus failing all checks in
Visual Studio builds.

Fixes: #16942
2017-06-06 08:55:43 -04:00
Daniel Pfeifer
8d7b3ef5d4 Provide and use CM_FALLTHROUGH 2017-06-03 08:38:51 +02:00
Daniel Pfeifer
0068224fdd C++ feature checks: check output for '[Ww]arning' 2017-06-03 08:38:51 +02:00
Brad King
f74f01fe69 Check C++ features even without CMAKE_CXX_STANDARD for CMake itself
When using `CMake_NO_CXX_STANDARD` a user may still provide `-std=c++11`
or similar flags in `CMAKE_CXX_FLAGS`, so we should still check for the
available C++ features.
2017-05-19 09:22:38 -04:00
Daniel Pfeifer
5d1671324b cmConfigure: provide macros CM_EQ_DELETE and CM_DISABLE_COPY 2017-04-22 10:09:41 +02:00
Daniel Pfeifer
67480c05e3 Add a feature check to test availability of auto_ptr 2016-09-26 09:03:46 -04:00
Brad King
aa50cdac43 Check for availability of unique_ptr and make_unique when building CMake
Some code paths may find these useful if available.
2016-09-16 13:22:10 -04:00
Daniel Pfeifer
3f77655d06 CM_OVERRIDE: fix feature test for clang
Clang refuses to default initialize an instance of a class that does not
have a default constructor.  Fix the check by adding default
constructors.  Don't use brace initialization like it is proposed in the
error message.  We want to test the override support independent from
the support for brace initialization.
2016-06-29 11:33:38 +02:00
Daniel Pfeifer
b4b73f56a2 cxx features: add check for nullptr 2016-06-27 23:24:39 +02:00
Daniel Pfeifer
9e2d6f0c4d CM_OVERRIDE: mark destructor overridden in the feature test.
This is important for two reasons:

1. A compiler might warn about a class that has a virtual member
function but no virtual destructor.  We don't want to treat the feature
as incomplete in this case.

2. MSVC10 supports the override identifier except on destructors.  In
this case, the feature really is incomplete and we want to detect it as
such.
2016-06-27 23:24:09 +02:00
Daniel Pfeifer
5286110d6f cxx features: add check for override 2016-06-27 10:37:41 -04:00
Daniel Pfeifer
09aa2c9418 Use <unordered_set> where available 2016-06-27 10:37:40 -04:00
Daniel Pfeifer
ea5477e43d Make C++ feature checks extensible
Turn the feature check for cxx11_unordered_map into a function such that
we can use it for other features as well.  Drop the 11 suffix, as we may
want to check features from other standards.
2016-06-27 10:37:40 -04:00
Kitware Robot
d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2016-05-16 16:05:19 -04:00
Raphael Kubo da Costa
ffa6f057b4 Avoid using C11 to build CMake if _Thread_local support is broken
Support for C11's _Thread_local was introduced in GCC in the 4.9 series,
even though we make the C11 compiler flags available in CMake with GCC
>= 4.6.

FreeBSD's runetype.h uses _Thread_local, which causes CMake's own build
to fail when using GCC < 4.9 and -std=gnu11:

  /usr/include/runetype.h:92:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'const'
   extern _Thread_local const _RuneLocale *_ThreadRuneLocale;

Add a test for _Thread_local support and only build CMake itself with
C11 support if it works.

Bug: http://www.cmake.org/Bug/view.php?id=15741
2015-09-15 10:51:54 -04:00
Stephen Kelly
d7923b82ad Use std::unordered_map instead of hash_map where available. 2015-05-19 00:07:02 +02:00
Brad King
3307e10fc4 Avoid using C++14 to build CMake if cstdio breaks
The GNU 4.8 standard library's cstdio header is not aware that C++14
honors C11's removal of "gets" from stdio.h and results in an error:

  /.../include/c++/4.8/cstdio:120:11: error: no member named 'gets' in the global namespace

Detect this problematic case and default to using C++11 instead of
C++14 for building CMake itself.
2015-05-08 11:04:21 -04:00