Commit Graph

105 Commits

Author SHA1 Message Date
Brad King f9973166e8 ExternalData: Tolerate files duplicated across multiple targets
If multiple ExternalData_Target_Add calls generate the same output file
then we need to avoid calling add_custom_command multiple times with
that output.  This was already done within a single target by setting a
variable in the local function scope.  This will not be visible in other
calls though so we need to use a directory property instead to prevent
adding a custom command multiple times for one output in a directory.

Normally it is not safe to have multiple custom commands that produce
the same output file across multiple independent targets, but since we
use atomic replacement of outputs the resulting races should not be a
problem.  For the convenience of projects, tolerate this instead of
diagnosing it.  In particular, we previously allowed up to two copies
of the custom command in one directory because CMake has a fallback
from MAIN_DEPENDENCY to an `<output>.rule` file.

While at it, add a note to the documentation that typically only one
external data target should be needed for a project.

Reported-by: David Manthey <david.manthey@kitware.com>
2016-09-07 15:17:33 -04:00
Brad King fc3dab0ea9 Tests: Port GenerateExportHeader test to RunCMake infrastructure
This will allow build failure cases to be added later.
2016-09-05 09:45:42 -04:00
Daniel Pfeifer 7a649111cd Use string(APPEND) in Tests
Automate with:

find Tests -type f -print0 | xargs -0 perl -i -0pe \
's/set\(([a-zA-Z0-9_]+)(\s+)"\$\{\1\}([^"])/string(APPEND \1\2"\3/g'
2016-07-28 00:43:04 +02:00
Brad King a9252441b3 Tests: Run clang-format on GenerateExportHeader code 2016-06-29 09:09:54 -04:00
Brad King 843402b04a GenerateExportHeader: Add option to specify custom content 2016-06-28 09:43:52 -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
Robert Maynard 15a6c9502d WCDH: Add Intel to list of supported compilers 2016-04-28 09:16:36 -04:00
Andreas Schuh be5a8973c3 GenerateExportHeader: Do not define DEFINE_NO_DEPRECATED (#16022)
Previously we allowed this definition to persist outside our header.
This would cause conflicts across multiple such headers because the name
was always the same.  Fix this by avoiding the definition altogether.
2016-03-17 10:40:24 -04:00
Mariusz Pluciński ada3736c78 Tests: fix Module.GenerateExportHeader building on Clang/C2 2016-03-10 09:11:41 -05:00
Ben Boeckel 326ad9949f Tests: fix GenerateExportHeader directory definitions
There's no need to stringify the values, but instead just pass in
strings. The core problem is that the path may have tokens which are
replaced by the preprocessor which causes an invalid path to be used.
2016-02-12 13:50:32 -05:00
James Johnston d5eb7d8565 GenerateExportHeader: Work around buggy std::getline behavior in BCB5. 2015-12-31 17:45:34 +00:00
Brad King 340d0897fa Revert topic 'compiler-features-solaris'
Revert commit v3.4.0-rc1~10^2~2 (Features: Disable support for Oracle
SolarisStudio on non-Linux, 2015-09-29) and two follow-up commits.
The support of compile features and language standards on Orcale
SolarisStudio needs more investigation so for CMake 3.4 we should
just act as 3.3 did.
2015-10-08 13:18:39 -04:00
Brad King 5fdf759478 Tests: Suppress WriteCompilerDetectionHeader failure on SunPro
We do support SunPro 5.13 compiler features, but only on Linux.
Suppress the portion of the test that fails on Solaris until
the larger problem can be addressed.
2015-09-30 09:53:52 -04:00
Tony Kelman 3e2865b467 GenerateExportHeader: Use dllexport/dllimport on Cygwin
Cygwin sits on top of Windows and so can use explicit symbol
export and import markup too.

Co-Author: Yaakov Selkowitz <yselkowitz@cygwin.com>
2015-08-27 10:08:34 -04:00
Brad King 0de47b05f7 ExternalData: Add option to disable use of symlinks
Add an ExternalData_NO_SYMLINKS to enable use of copies instead of
symlinks to populate the real data files behind a DATA{} reference.
This will be useful on UNIX-like systems when the underlying filesystem
does not actually support symbolic links.

Suggested-by: Matt McCormick <matt.mccormick@kitware.com>
2015-05-22 09:21:47 -04:00
Brad King 230f2d6e70 ExternalData: Add option to recursively match under directories
Extend the ``DATA{Dir/,...}`` syntax with a new ``RECURSE:`` option
to enable recursive matching of associated files.  This will allow
an entire directory tree of data to be referenced at once.
2015-03-27 14:44:54 -04:00
Brad King f7f4ca55bd ExternalData: Add support for custom algorithm-to-URL mapping
Allow URL templates to contain a %(algo:<key>) placeholder that is
replaced by mapping the canonical hash algorithm name through a map
defined by the <key>.

Extend the Module.ExternalData test to cover the behavior.
Extend the RunCMake.ExternalData test to cover error cases.
2015-02-25 08:28:05 -05:00
Stephen Kelly fb3487a997 Features: Fix C90 feature detection.
This bug caused c_function_prototypes to not be recorded at configure
time when compiling with -std=gnu99 or similar. In the case of feature
recording, that was not a problem, because the logic in
CMakeDetermineCompileFeatures.cmake currently assumes that a feature
present for an earlier standard is present for a later standard.

However, the detection strings are also used in WriteCompilerDetectionHeader,
so the feature macro has been defined to '0' when using a later language
dialect.

Fix that by not checking the existence of the __STDC_VERSION__ macro at
all when detecting C90 features.
2015-02-04 18:38:21 -05:00
Robert Maynard d3489bdb0b Features: Record for MSVC 2010-2015
Also, in WCDH add MSVC Compatibility for cxx_align{of,as}.

Co-Author: Stephen Kelly <steveire@gmail.com>
Co-Author: Brad King <brad.king@kitware.com>
2015-01-30 09:57:33 -05:00
Stephen Kelly 3c0996c135 WCDH: Test that no C compiler features are defined for CXX compiler.
This amends commit 54156d72 (WCDH: Generate per-language files
in multi-file mode., 2015-01-17).
2015-01-19 20:03:23 +01:00
Stephen Kelly 8dc0c97666 WCDH: Fix the C_STANDARD property in the tests.
The CXX_STANDARD property validates the values allowed for it,
and '90' is not a valid value for it.  However, the validation is only
done for languages enabled for the target, and as C_undefined has no
CXX files, that language is not enabled for it.

This amends commit v3.1.0-rc3~23^2 (WCDH: Make the header -Wundef
safe for the C language., 2014-11-24).
2015-01-19 19:57:54 +01:00
Brad King 813ace90e4 Merge topic 'GNU-4.4-compile-features'
004e1540 Features: Record for GNU 4.4.
2a5ca650 Features: Wrap failure-test in UNIX condition.
1ae2c6b2 Features: Blacklist cxx_constexpr test for GNU 4.5.
c66e3317 Features: Use a more-common feature in cycle-test.
c43a6dc5 Features: Update comment in test to match the code.
78259135 Features: Test presence of cxx_auto_type with genex.
7b9fc88b Features: Remove outdated comment.
2015-01-19 13:55:31 -05:00
Stephen Kelly 2a5ca650c9 Features: Wrap failure-test in UNIX condition.
The use of GNU on non-UNIX for 'compile features' is not
tested and is not well defined.
2015-01-18 15:01:14 +01:00
Stephen Kelly bcb04783f7 Features: Record for SolarisStudio 12.4.
It has similar C++11 capabilities compared to GCC 4.8.
2015-01-17 14:48:28 +01:00
Brad King 0fe4d8bb3b ExternalData: Add support for custom download scripts
Add support for a special URL template to map the fetch operation
to a project-specified .cmake script insead of using file(DOWNLOAD).

Extend the Module.ExternalData test to cover the behavior.
Extend the RunCMake.ExternalData test to cover error cases.
2015-01-15 10:48:09 -05:00
Brad King 0b7e7e277c Revert topic 'feature_record_msvc'
Revert commits:

 2d738ce3 Help: Add notes for topic 'feature_record_msvc'
 f73718c9 Features: Enable writing of MSVC compiler feature header.
 64c30bdc Features: Record for MSVC C++ 2015 and MSVC C 2010-2015.
 225c0ef8 Features: Record for MSVC 2010-2013.

This topic was merged to master prematurely, so remove it.
2015-01-14 13:35:58 -05:00
Robert Maynard f73718c9b8 Features: Enable writing of MSVC compiler feature header.
Notes:
VS2015 and above are the only MSVC versions to support cxx_final, so remove
usages from the tests, and instead only test for cxx_override.

VS2012 and above to conform to cxx_decltype_incomplete_return_types
proposal, but without support for auto return types the dcl.type.simple
example in the proposal doesn't compile.

VS2013 and above to conform to the updated cxx_contextual_conversions proposal,
but VS2010 and above pass the test.

Compilers such as MSVC have no explicit flags to enable C++11 mode,
it just is always on. So only run the link tests with compilers that require
a flag to specify the language version.
2015-01-11 11:32:36 -05:00
Robert Maynard a15675efc3 Features: Quote all compiler names when comparing with COMPILER_ID
In preparation of adding MSVC support we need to quote all compiler names,
as MSVC is also a CMake variable.
2015-01-11 16:47:58 +01:00
Stephen Kelly bd6b42c186 Features: Record for AppleClang 5.1
Apple's Clang 5.1 already supports most of the C and C++ features CMake
enumerates.
2014-12-22 10:44:41 -05:00
Brad King 6b93953615 Merge topic 'WCDH-multi-file'
4cf5179c WCDH: Make it possible to generate multiple files.
2014-11-26 10:37:49 -05:00
Stephen Kelly d0af0faefb WCDH: Make the header -Wundef safe for the C language.
The __STDC_VERSION__ macro may be defined or not depending on the
implementation dialect of C.  Test that it is defined before testing
its value.

The CXX tests do not need such a change because they define __cplusplus
in all dialects.
2014-11-25 14:44:21 +01:00
Stephen Kelly 4cf5179c77 WCDH: Make it possible to generate multiple files.
Extend the write_compiler_detection_header interface to allow
specifying a location for supplementary files, and getting the
list of resulting files as a variable.
2014-11-24 21:54:41 +01:00
Stephen Kelly ddec418a8f Features: Add compiler version support to WriteCompilerDetectionHeader. 2014-06-09 23:42:20 +02:00
Stephen Kelly cda233194f Features: Record for Clang 3.4
Clang 3.4 supports all features currently known to CMake.
2014-05-20 16:03:48 +02:00
Stephen Kelly e0890d03a4 Features: Extend concept to C language.
Add properties and variables corresponding to CXX equivalents.

Add features for c_function_prototypes (C90), c_restrict (C99),
c_variadic_macros (C99) and c_static_assert (C11). This feature
set can be extended later.

Add a <PREFIX>_RESTRICT symbol define to WriteCompilerDetectionHeader
to conditionally represent the c_restrict feature.
2014-05-15 00:15:18 +02:00
Stephen Kelly 62a4a67dc5 Add the WriteCompilerDetectionHeader module.
Provide a function to write a portable header to detect compiler
features.  Generate a preprocessor #error for unknown compilers
and compiler versions whose features are not yet recorded.  This
error condition might be relaxed in the future, but for now it
is useful for verification of expectations.
2014-05-14 13:57:30 -04:00
Brad King 9add7071a5 Merge topic 'hp-cpp98-tests'
b0f277db HP aCC: record compiler flag for Ansi C++98 support for version 3.80 onwards
2014-05-08 11:27:55 -04:00
Rolf Eike Beer b0f277db38 HP aCC: record compiler flag for Ansi C++98 support for version 3.80 onwards
Old versions of aCC need a special compiler flag to get full C++98 template
support as e.g. CMake itself or the Complex and ComplexOneConfig tests need.
The same versions need a special flag to get a proper C++ library, too.
2014-04-25 17:59:57 +02:00
Brad King ccd29b9af8 ExternalData: Warn on missing file instead of failing
When the primary source tree path named by a DATA{} reference does not
exist, produce an AUTHOR_WARNING instead of a FATAL_ERROR.  This is
useful when writing a new DATA{} reference to a test reference output
that has not been created yet.  This way the developer can run the test,
manually verify the output, and then copy it into place to provide the
reference and eliminate the warning.

If the named source tree path is expected to be a file but exists as a
directory, we still need to produce a FATAL_ERROR.
2014-04-17 09:45:09 -04:00
Stephen Kelly 45abfb0c4d find_dependency: Extend the tests for use of EXACT macro parameter. 2014-03-10 09:07:38 +01:00
Stephen Kelly 0bba365ff5 Add test for find_dependency macro. 2014-02-26 22:21:03 +01:00
Stephen Kelly 2410b912fe Merge some GenerateExportHeader subtests. 2013-12-15 11:22:19 +01:00
Stephen Kelly 4017db13aa Speed up the GenerateExportHeader unit test (#14453).
Instead of running many small tests with many cmake projects, simply
compare the generated export header against a reference.

Remove the helper macros and the try_compiles which are duplicates
of the library build tests.
2013-12-15 11:22:19 +01:00
Brad King 8eb20eeabe ExternalData: Allow local stores without any URL templates
Allow ExternalData_URL_TEMPLATES to be empty if a value for
ExternalData_OBJECT_STORES is provided.  Assume in this use case that
the object stores will already contain all needed objects.  Extend the
Module.ExternalData test to cover this case (all objects in stores).
Extend the RunCMake.ExternalData test to cover the non-failure message
case when stores are provided without URL templates.
2013-11-13 10:03:36 -05:00
Daniele E. Domenichelli e6cec64820 CheckTypeSize: Add unit tests 2013-10-21 16:39:04 +02:00
Brad King ff8917fdd2 Merge topic 'VISIBILITY_PRESET-property'
cd1fa53 Add a COMPILE_OPTION for a VISIBILITY_INLINES_HIDDEN target property.
0e9f4bc Introduce target property <LANG>_VISIBILITY_PRESET
2013-06-05 09:38:59 -04:00
Stephen Kelly cd1fa537a0 Add a COMPILE_OPTION for a VISIBILITY_INLINES_HIDDEN target property.
This corresponds to the g++ and clang++
option -fvisibility-inlines-hidden on linux. On Windows with MinGW,
this corresponds to -fno-keep-inline-dllexport. That option is
not supported by clang currently.
2013-06-02 12:00:51 +02:00
Stephen Kelly 0e9f4bc00c Introduce target property <LANG>_VISIBILITY_PRESET
This is initialized by CMAKE_<LANG>_VISIBILITY_PRESET. The target
property is used as the operand to the -fvisibility= compile option
with GNU compilers and clang.
2013-06-02 12:00:51 +02:00
Brad King 6aba976427 Merge topic 'geh-cleanup-identifiers'
7e24997 GenerateExportHeader: Generate only C identifiers as defines
2013-05-24 09:20:20 -04:00
Brad King dc85291c57 Merge topic 'geh-add-missing-test'
74f24b2 Tests/Module/GenerateExportHeader: Test exported free-function
2013-05-24 09:19:43 -04:00