Commit Graph

109 Commits

Author SHA1 Message Date
Daniele E. Domenichelli 73d28d2177 CheckStructHasMember: Add support for C++
Previously if headers required to check if a struct has a member can be
compiled with C++ compiler only, the check would fail because the C
compiler fails.  As a consequence, the result variable would be set to
false, even if the struct has that particular member.

Teach CHECK_STRUCT_HAS_MEMBER to accept a new optional argument LANGUAGE
that allows one to explicitly set the compiler to use.  The new
signature is therefore:

  CHECK_STRUCT_HAS_MEMBER (<struct> <member> <header> <variable>
                           [LANGUAGE <language>])
2013-10-08 09:43:06 -04:00
Stephen Kelly fe732264e9 Add the INTERFACE_LIBRARY target type.
This target type only contains INTERFACE_* properties, so it can be
used as a structural node. The target-specific commands enforce
that they may only be used with the INTERFACE keyword when used
with INTERFACE_LIBRARY targets. The old-style target properties
matching LINK_INTERFACE_LIBRARIES_<CONFIG> are always ignored for
this target type.

The name of the INTERFACE_LIBRARY must match a validity generator
expression. The validity is similar to that of an ALIAS target,
but with the additional restriction that it may not contain
double colons. Double colons will carry the meaning of IMPORTED
or ALIAS targets in CMake 2.8.13.

An ALIAS target may be created for an INTERFACE library.

At this point it can not be exported and does not appear in the
buildsystem and project files are not created for them. That may
be added as a feature in a later commit.

The generators need some changes to handle the INTERFACE_LIBRARY
targets returned by cmComputeLinkInterface::GetItems. The Ninja
generator does not use that API, so it doesn't require changes
related to that.
2013-10-07 19:56:31 -04:00
Brad King f3155cd62a Add RunCMake.Syntax test to cover argument parsing
Test basic unquoted and quoted argument parsing cases including failure
on an unterminated string and an unterminated command invocation.  Also
cover arguments not separated by any spaces, which is accidentally
allowed by the current parser.
2013-08-08 13:26:26 -04:00
Stephen Kelly 370bf55415 Add the ALIAS target concept for libraries and executables.
* The ALIAS name must match a validity regex.
* Executables and libraries may be aliased.
* An ALIAS acts immutable. It can not be used as the lhs
  of target_link_libraries or other commands.
* An ALIAS can be used with add_custom_command, add_custom_target,
  and add_test in the same way regular targets can.
* The target of an ALIAS can be retrieved with the ALIASED_TARGET
  target property.
* An ALIAS does not appear in the generated buildsystem. It
  is kept separate from cmMakefile::Targets for that reason.
* A target may have multiple aliases.
* An ALIAS target may not itself have an alias.
* An IMPORTED target may not have an alias.
* An ALIAS may not be exported or imported.
2013-08-02 15:21:00 +02:00
Brad King 10e54cd6c9 Merge topic 'dev/export-target-without-language'
5837f19 export: Error when exporting a target without a language
2013-07-25 08:47:49 -04:00
Brad King 17fb435b21 Merge topic 'doc-RunCMake-strips-expected'
c80a4f9 Tests/RunCMake: Document stripping of expected output
2013-07-25 08:47:17 -04:00
Ben Boeckel 5837f19690 export: Error when exporting a target without a language
First, it prevents a NULL dereference and second it reiterates that
targets without languages are not supported by CMake.

Add a RunCMake.ExportWithoutLanguage test exporting a library without a
languages.
2013-07-25 08:44:57 -04:00
Ben Boeckel c80a4f92ce Tests/RunCMake: Document stripping of expected output
Document that trailing newlines are stripped from the -stdout.txt
and -stderr.txt content before using as a regular expression.
2013-07-25 08:38:53 -04:00
Stephen Kelly b655865bbf target_link_libraries: Add PUBLIC/PRIVATE/INTERFACE keyword signature
Add a new signature to help populate INTERFACE_LINK_LIBRARIES and
LINK_LIBRARIES cleanly in a single call.  Add policy CMP0023 to control
whether the keyword signatures can be mixed with uses of the plain
signatures on the same target.
2013-07-24 11:52:44 -04:00
Brad King 9c119b829d Merge topic 'obsolete-qt4-macros'
cb7f32f Mark qt4_use_modules and qt4_automoc as obsolete.
2013-07-16 13:59:22 -04:00
Brad King fa6106ec56 Merge topic 'target-policies'
484bb88 Genex: Make CMP0021 and CMP0022 usable with TARGET_POLICY
2013-07-15 09:33:47 -04:00
Brad King b6e0972262 Merge topic 'INTERFACE_LINK_LIBRARIES-prop'
3e30d9e TLL: Don't populate old link interface if CMP0022 is NEW.
574fec9 Export: Generate INTERFACE_LINK_LIBRARIES property on targets.
d0a76ea Introduce the INTERFACE_LINK_LIBRARIES property.
ddde61c Introduce the LINK_ONLY generator expression.
5aa9731 GenexEval: Add abstracted access to link interface for a target.
2013-07-15 09:33:42 -04:00
Stephen Kelly cb7f32f5b8 Mark qt4_use_modules and qt4_automoc as obsolete.
The QT_QMAKE_EXECUTABLE has to be passed through the cmake calls because
the executable may not be in the PATH.
2013-07-14 10:05:04 +02:00
Stephen Kelly 484bb888a0 Genex: Make CMP0021 and CMP0022 usable with TARGET_POLICY
Use preprocessor loops and add a unit test for the appropriate
policies. All policies whose value is recorded at target creation
time should be part of this list.
2013-07-11 11:56:14 +02:00
Brad King 18e1bfbb3c cmake: On configure error suggest looking at CMake*.log files
When CMake reports failure to configure a project, especially when the
toolchain does not initialize properly, the true reason may be clear
from reading the CMakeFiles/CMake(Output|Error).log files.  Advise users
to look at these files if they exist when configuration fails.

Add RunCMake.Configure test to check that the log files are mentioned
when configuration fails.
2013-07-09 15:00:39 -04:00
Stephen Kelly d0a76ea07c Introduce the INTERFACE_LINK_LIBRARIES property.
This property replaces the properties which
match (IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?, and is enabled
for IMPORTED targets, and for non-IMPORTED targets only with a policy.

For static libraries, the INTERFACE_LINK_LIBRARIES property is
also used as the source of transitive usage requirements content.
Static libraries still require users to link to all entries in
their LINK_LIBRARIES, but usage requirements such as INCLUDE_DIRECTORIES
COMPILE_DEFINITIONS and COMPILE_OPTIONS can be restricted to only
certain interface libraries.

Because the INTERFACE_LINK_LIBRARIES property is populated unconditionally,
we need to compare the evaluated result of it with the link implementation
to determine whether to issue the policy warning for static libraries. For
shared libraries, the policy warning is issued if the contents of
the INTERFACE_LINK_LIBRARIES property differs from the contents of the
relevant config-specific old LINK_INTERFACE_LIBRARIES property.
2013-07-08 22:39:09 +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
Brad King c63d30048b variable_watch: Add test for MODIFIED_ACCESS report
Add a RunCMake.variable_watch watch test to cover the basic use case.
2013-06-03 10:20:31 -04: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 b680824a5f try_compile: Add test for bad call error cases
Add a RunCMake.try_compile test to cover cases of bad invocation of the
try_compile command.
2013-05-31 10:00:42 -04:00
Brad King 585cfa51de Merge topic 'fix-FileIsDirectory-SEGV'
7378792 if: Add test for IS_DIRECTORY
4ab10e0 Merge branch 'master' into fix-FileIsDirectory-SEGV
045d6ae KWSys: Fix SystemTools::FileIsDirectory with long paths (#14176)
2013-05-30 08:57:42 -04:00
Brad King 7378792b49 if: Add test for IS_DIRECTORY
Add a RunCMake.if test to cover if() command behavior.  Start with a
test for IS_DIRECTORY cases with an existing directory and a long path,
both with a trailing slash.
2013-05-28 11:35:32 -04:00
Brad King be85fa4a89 Merge topic 'genex-generate-file'
b983a58 file: Add GENERATE command to produce files at generate time
2013-05-28 10:42:18 -04:00
Stephen Kelly b983a58bdf file: Add GENERATE command to produce files at generate time
The idea is to write to a temp file which contains generator
expressions, and at generate time, evaluate the generator expressions,
and write the result to a file.

Because executables on Windows are limited in the length of command line
it is possible to use, it is common to write command line arguments to a
file instead and specify the file as a source of arguments.

This new FILE(GENERATE) subcommand allows the use of generator
expressions to create such files so that they can be used with
add_custom_command for example.
2013-05-24 09:02:45 -04:00
Brad King ec1ba9b0ae get_filename_component: Add explicit unit tests
Add test RunCMake.get_filename_component to cover cases of the command.
Remove redundant coverage of these cases from the "complex" tests.
2013-04-16 09:35:29 -04:00
Brad King de13d68d11 add_dependencies: Distinguish target v. file dependencies in error (#14050)
When called with a non-existent LHS target name the user may be trying
to add file-level dependencies.  Clarify the error message to explain
the difference between target-level and file-level dependencies.  Point
the reader at the commands and options needed for the latter.
2013-03-29 15:00:33 -04:00
Stephen Kelly 535e53c7cc Fix the Qt 5 version required to run the IncompatibleQt test.
The commit to add the INTERFACE_QT_MAJOR_VERSION in qtbase.git
is 14054d45 (Set the INTERFACE_QT_MAJOR_VERSION to 5., 2013-03-16)
which will be part of Qt 5.1.0.

If there is a Qt 5.0.3 release, there is no guarantee it will
contain that commit. Make sure such a Qt version does not fail
with this test if not.
2013-03-27 00:15:08 +01:00
Stephen Kelly 4aa10cd6d6 FindQt4: Set the INTERFACE_QT_MAJOR_VERSION for Qt4::QtCore
With a similar commit in Qt 5, this will error at CMake time if
an attempt is made to use

 target_link_libraries(foo Qt4::QtCore Qt5::Core)
2013-03-18 09:31:33 -04:00
Brad King d90f49b894 CTest: Fail early without PROJECT_BINARY_DIR (#14005)
Do not use PROJECT_BINARY_DIR before it is defined.  If it is not
defined when needed, fail with an error message suggesting that the
project() command be invoked first.
2013-03-12 18:20:44 -04:00
Brad King f17711c546 FPHSA: Convert FOUND_VAR failure test to RunCMake
Move the Tests/FPHSA_InvalidFOUND_VAR test case over to a new
RunCMake.FPHSA test with a BadFoundVar case.  The RunCMake tests are
built to cover failure cases easily and robustly.
2013-02-22 08:57:11 -05:00
Brad King e83e6a1c8c Test Unix Makefiles generator support for changing compilers
Add RunCMake.CompilerChange test to cover use of -DCMAKE_C_COMPILER=cc
to change the compiler of an existing build tree.  Also test for proper
failure with -DCMAKE_C_COMPILER="" and no CC in the environment.
2013-02-20 08:01:06 -05:00
Brad King 56ca8d4e63 Tests: Add generator toolset support
Propagate CMAKE_GENERATOR_TOOLSET through the test hierarchy so that all
tests can build with the selected generator toolset, if any.
2013-02-07 11:09:56 -05:00
Brad King c0debb1f89 Merge branch 'master' into generator-toolset
We need the latest Tests/CMakeLists.txt so we can refactor all tests.
2013-02-07 11:09:01 -05:00
Brad King f980a80495 Xcode: Implement generator toolset selection (#9831, #13802)
Implement generator toolset selection (cmake -T) for Xcode > 2.0 by
adding the GCC_VERSION build setting to project files.
2013-02-07 11:07:48 -05:00
Brad King 4fd5342956 CMake: Add -T option to choose a generator toolset
Reject the option by default.  It will be implemented on a per-generator
basis.  Pass the setting into try_compile project generation.  Add cache
entry CMAKE_GENERATOR_TOOLSET and associated variable documentation to
hold the value persistently.

Add a RunCMake.GeneratorToolset test to cover basic "-T" option cases.
Verify that CMAKE_GENERATOR_TOOLSET is empty without -T, that -T is
rejected when the generator doesn't support it, and that two -T options
are always rejected.
2013-02-07 10:53:19 -05:00
Brad King 4befecc77c ExternalData: Add tests covering interfaces and errors
Add a Module.ExternalData test to verify data retrieval and test
argument DATA{} references.

Add a RunCMake.ExternalData test to verify error handling and automatic
transformation of a raw data to a content link and staged object.
2013-01-30 10:04:54 -05:00
Brad King a37b0e3ebf Merge topic 'qt4-autolink-qtmain'
e3b5eb6 Automatically link to the qtmain library when linking to QtCore.
6c8d8af Add the $<TARGET_POLICY> expression
2013-01-23 15:11:24 -05:00
Stephen Kelly e98799105b Make INTERFACE determined properties readable in generator expressions.
The properties are evaluated as link-dependent interface properties when
evaluating the generator expressions.
2013-01-20 17:06:47 +01:00
Stephen Kelly 6c8d8afe34 Add the $<TARGET_POLICY> expression
This new expression allows checking how a policy was set when a target
was created.  That information is only recorded for a subset of policies,
so a whitelist is used.
2013-01-17 17:20:17 +01:00
Stephen Kelly 3581b96caa Process the INTERFACE_PIC property from linked dependencies
This allows a dependee to inform a target that it should have its
POSITION_INDEPENDENT_CODE property set to ON, or OFF. The value of
the POSITION_INDEPENDENT_CODE property, if set, must be consistent
with any INTERFACE_POSITION_INDEPENDENT_CODE properties on dependees.

Add a test covering the consistency checks on platforms where they run.
2013-01-10 09:54:52 -05:00
Brad King af770bc27e Merge topic 'deprecate-load_command'
09a0da7 Revert "load_command: Deprecate and document pending removal"
2013-01-08 14:31:57 -05:00
Brad King 09a0da7789 Revert "load_command: Deprecate and document pending removal"
This reverts commit d2d43986e7.
We will add a policy to remove the command more gracefully.
2013-01-07 10:31:07 -05:00
Brad King 711b63f7e0 Add policy CMP0019 to skip include/link variable re-expansion
Historically CMake has always expanded ${} variable references in the
values given to include_directories(), link_directories(), and
link_libraries().  This has been unnecessary since general ${}
evaluation syntax was added to the language a LONG time ago, but has
remained for compatibility with VERY early CMake versions.

For a long time the re-expansion was a lightweight operation because it
was only processed once at the directory level and the fast-path of
cmMakefile::ExpandVariablesInString was usually taken because values did
not have any '$' in them.  Then commit d899eb71 (Call
ExpandVariablesInString for each target's INCLUDE_DIRECTORIES,
2012-02-22) made the operation a bit heavier because the expansion is
now needed on a per-target basis.  In the future we will support
generator expressions in INCLUDE_DIRECTORIES with $<> syntax, so the
fast-path in cmMakefile::ExpandVariablesInString will no longer be taken
and re-expansion will be very expensive.

Add policy CMP0019 to skip the re-expansion altogether in NEW behavior.
In OLD behavior perform the expansion but improve the fast-path
heuristic to match ${} but not $<>.  If the policy is not set then warn
if expansion actually does anything.  We expect this to be encountered
very rarely in practice.
2012-12-07 09:51:19 -05:00
Petr Kmoch 57cadc179c Add tests for VS_SOLUTION_GLOBAL_SECTIONS
Add tests for correct appliation of directory properties
VS_SOLUTION_GLOBAL_SECTIONS_*
2012-11-16 08:16:10 -05:00
Brad King 70b176e276 Merge topic 'deprecate-load_command'
d2d4398 load_command: Deprecate and document pending removal
2012-11-13 14:31:19 -05:00
Brad King d2d43986e7 load_command: Deprecate and document pending removal
This command works only when building projects using the same
architecture as the running CMake binary.  Since it was introduced
CMake has learned macro() and function() to add commands, and the
execute_process() command to launch advanced external computations.

Add a RunCMake.load_command test to verify the warning appears.
2012-11-07 09:24:05 -05:00
Stephen Kelly 79edd00235 GenEx: Fix reporting about not-found include directories and libraries.
This fixes a regression introduced in commit 290e92ad (Move
GetIncludeDirectories to cmGeneratorTarget, 2012-09-16) which loops over
cmGeneratorTargets before they get created, so the container is empty.
2012-10-17 16:23:32 -04:00
Stephen Kelly 08cb4fa4c0 Process generator expressions in the INCLUDE_DIRECTORIES property.
This use of generator expressions, like all others to come which operate
on target properties, must initalize the dag checker.
2012-09-28 08:50:10 -04:00
Brad King ebf05abda1 Add boolean generator expressions
Add generator expressions that combine and use boolean test results:

 $<0:...>         = empty string (ignores "...")
 $<1:...>         = content of "..."
 $<AND:?[,?]...>  = '1' if all '?' are '1', else '0'
 $<OR:?[,?]...>   = '0' if all '?' are '0', else '1'
 $<NOT:?>         = '0' if '?' is '1', else '1'

These will be useful to evaluate (future) boolean query expressions and
condition content on the results.  Include tests and documentation.
2012-08-15 11:44:49 -04:00
Brad King 2e99949ccb include: Ignore empty string as file name (#13388)
Previously CMake silently accepted the empty string and added a bogus
dependency on the current directory.  Instead warn about the empty file
name and ignore it.  We cannot make this an error because there may be
existing projects that accidentally depend on the old behavior.

Add a RunCMake.include test to cover this case.
2012-07-10 11:05:04 -04:00
Brad King 56148fd2bc Do not crash on SHARED library without language (#13324)
Since commit e1409ac5 (Support building shared libraries or modules
without soname, 2012-04-22) CMake crashes on the code

 add_library(foo SHARED foo.nolang)

because the logic to lookup the language's soname flag was moved from
cmTarget::GetLibraryNames to cmMakefile::GetSONameFlag without its check
for a NULL language.  Restore the check for NULL.

Add RunCMake.Languages test to cover language error cases like this one.
2012-06-20 11:26:05 -04:00
Brad King 8787f946b7 Merge branch 'list-empty-error' into enhance-include_external_msproject
Resolve conflict in Tests/RunCMake/CMakeLists.txt by adding both tests.
2012-04-19 09:33:29 -04:00
Brad King 4a30258d91 include_external_msproject: Test TYPE, GUID, PLATFORM options (#13120)
Add "RunCMake.include_external_msproject" test to use the TYPE, GUID, and
PLATFORM options to include_external_msproject.  Since projects with
custom types and platforms cannot be loaded without special VS plugins
validate the results by directly parsing the generated solution (.sln).

Co-Author: Leonid Yurchenko <nocturne@qarea.com>
2012-04-19 08:35:55 -04:00
Brad King 38c3943b6f Teach RunCMake tests to allow custom checks
Look for a <SubTest>-check.cmake script and load it to check side
effects of the sub test.  Provide it with the test source and build tree
paths in variables.  Check for a failure message in a result variable.
2012-04-19 08:32:57 -04:00
Brad King 05604eb9cb list: Handle errors on empty lists more gracefully (#13138)
Since commit ed1ea24c (Fix INSERT to allow inserting to empty list,
2006-05-15) the list command allows insertion into an empty list at
index 0.  Fix rejection of insertion at non-zero (negative) indices to
present an error message instead of crashing.

While at it, fix the error message of the GET and REMOVE_AT operations
when the list is empty to not present a bogus allowed range.

Add a "RunCMake.list" test to cover failure cases on empty lists.
2012-04-17 11:07:07 -04:00
Brad King 5683101669 Test OBJECT library failure cases
Add "RunCMake.ObjectLibrary" test to verify that unsupported use cases
are rejected with errors:

* An OBJECT library may not reference another object library
* An OBJECT library may not be referenced in target_link_libraries
* An OBJECT library may not contain non-compiling sources
* An OBJECT library may not have pre/post build/link commands
* An OBJECT library may not be installed, exported, or imported

Also verify that invalid $<TARGET_OBJECTS:...> expressions are
diagnosed.
2012-03-16 10:12:30 -04:00
Brad King 55b2aa884c Use generalized RunCMake test infrastrucure for build_command test
The CMakeCommands.build_command test performs output/error checking
so move it over to RunCMake to re-use the generalized infrastrucure.
This is the only test left using Tests/CMakeCommands/CMakeLists.txt
so remove it.
2012-03-12 09:33:21 -04:00
Brad King eb33000d75 Use generalized RunCMake test infrastrucure for find_package test 2012-03-12 09:33:21 -04:00
Brad King 42a81e7119 Add stronger infrastructure for CMake-only tests
The CMakeOnly directory added by commit 9a20abf0 (Add infrastructure for
CMake-only tests, 2012-01-11) was sufficient only for tests that always
run CMake to successfully configure a project.  Later commit eeaaffcb
(find_package: Test error and warning messages in failure cases,
2012-02-28) added a sample test that covers failure cases.

Generalize the above to create new "RunCMake" test infrastructure that
can run CMake multiple times for a single project with different
variations and check for expected result/stdout/stderr.  Allow for both
successful and failing CMake project configuration cases.  This will be
useful to test error messages and failure behavior.
2012-03-12 09:33:21 -04:00