Commit Graph

951 Commits

Author SHA1 Message Date
Brad King 943fe6e3b4 Revert "try_compile: Honor CMAKE_<LANG>_FLAGS_<CONFIG> changes"
Revert commit v3.6.0-rc1~160^2 (try_compile: Honor
CMAKE_<LANG>_FLAGS_<CONFIG> changes, 2016-04-11).  The behavior it
introduced can break projects that depend on the lack of such behavior.
We will have to introduce a policy or other mechanism to enable the
behavior in a compatible way.  Simply revert it for now.

See issue #16174.
2016-06-28 15:03:45 -04:00
Domen Vrankar 6107fab467 CPack/Deb: Fix test to actually test the preinst script
The test regex variable name was invalid and did not test preinst
script.

Reported-by: Patrick <mail6543210@yahoo.com.tw>
2016-06-20 09:29:11 -04:00
Domen Vrankar 302391bae6 CPack/Deb: Fix tests for SELinux-enabled systems
Suggested-by: Patrick <mail6543210@yahoo.com.tw>
2016-06-20 09:29:11 -04:00
Brad King f500a784d0 Fix crash on $<TARGET_PROPERTY:...,LOCATION> genex (#16134)
Policy CMP0026 deprecated the LOCATION property, and we have long
provided a $<TARGET_FILE:...> generator expression.  However, if
a project tries to use $<TARGET_PROPERTY:...,LOCATION> we should
at least not crash.

The compatibility implementation of the LOCATION property uses
cmGlobalGenerator::CreateGenerationObjects to create the structures
needed to evaluate the property before generation starts.  The
implementation assumed that accessing the property could only be done
during configuration (via the typical get_property command use case).
The $<TARGET_PROPERTY:...,LOCATION> genex causes the LOCATION property
to be accessed during generation.  Calling CreateGenerationObjects
during generation blows away all the objects currently being used for
generation and is not safe.  Add a condition to call it only when
configuration is not finished.
2016-06-02 10:58:38 -04:00
Brad King d256ba078a try_compile: Optionally forward custom platform variables to test project
Add a `CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable to specify a list
of custom variables to be forwarded to a `try_compile` test project.
This will be useful for platform information modules or toolchain files
to forward some platform-specific set of variables from the host project
(perhaps set in its cache) to the test project so that it can build the
same way.
2016-05-25 09:36:19 -04:00
Domen Vrankar adbd3985f8 CPack/Deb possibility to change package name
This patch preserves backward compatibility of
deb package names with previous CMake versions
but similarly to CPack/RPM allows to change
package name format and supports DEB-DEFAULT
setting that produces proper Debian package names.
2016-05-23 19:55:46 +02:00
Brad King e0da6c3b56 Merge topic 'ninja-output-path-prefix'
eb076692 Tests: Select RunCMake.Ninja test cases based on ninja version
8a862a4d Ninja: Support embedding of CMake as subninja project
038e7716 Ninja: Pass all build paths through a central method
7c26a6a2 Ninja: Fix path to soname-d target file
ac3cdd9a Ninja: Convert object file names to ninja paths earlier
d4381cb1 Ninja: Convert link library file names like all other output paths
0397c92a Ninja: Pre-compute "CMakeCache.txt" build target name
3b3ecdfa Ninja: Pre-compute "all" build target name
5ca72750 Ninja: Simplify generation of custom target logical path
2016-05-19 10:41:27 -04:00
Brad King eb07669245 Tests: Select RunCMake.Ninja test cases based on ninja version
Some test cases need features not available in Ninja < 1.6, so check the
version before running them.
2016-05-18 09:24:54 -04:00
Reiner Herrmann edcccde7d6 file: Sort GLOB results to make it deterministic (#14491)
Even though the `file(GLOB)` documentation specifically warns against
using it to collect a list of source files, projects often do it anyway.
Since it uses `readdir()`, the list of files will be unsorted.
This list is often passed directly to add_executable / add_library.
Linking binaries with an unsorted list will make it unreproducible,
which means that the produced binary will differ depending on the
unpredictable `readdir()` order.

To solve those reproducibility issues in a lot of programs (which don't
explicitly `list(SORT)` the list manually), sort the resulting list of
the `file(GLOB)` command.

A more detailed rationale about reproducible builds is available
[here](https://reproducible-builds.org/).
2016-05-17 10:12:11 -04:00
Nicolas Despres 8a862a4d4b Ninja: Support embedding of CMake as subninja project
Add a `CMAKE_NINJA_OUTPUT_PATH_PREFIX` variable.  When it is set, CMake
generates a `build.ninja` file suitable for embedding into another ninja
project potentially generated by an alien generator.
2016-05-17 09:34:12 -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
Brad King 856804f9a9 Merge topic 'findpkgconfig-target'
df97b979 FindPkgConfig: optionally create imported target for the found libraries
2016-05-16 10:11:38 -04:00
Brad King d3db070e9e Merge topic 'cpack-rpm-adding-dist-to-release-tag'
f5089cfc CPack/RPM adding dist to release tag test
f7003a60 CPack/RPM release dist tag support
2016-05-16 10:11:35 -04:00
Brad King bc7598fde0 Merge topic 'cpack-rpm-different-package-names'
44ee2d71 CPack/RPM different package names
2016-05-16 10:11:32 -04:00
Brad King 2b25174da6 Merge topic 'cpack-deb-improvements'
4461e8bb CPack/Deb cpack-deb-improvements release notes
7e940bf7 CPack/Deb test changes due to breaking changes
3b648894 CPack/Deb package release number in file name
316dd613 CPack/Deb proper package file naming
271e03f0 CPack/Deb per-component package architecture
23baaf8d CPack/Deb inter package dependencies
3a55a0e7 CPack/Deb proper component packages file naming
c7f388e7 CPack/Deb generation of postinst and postrm ldconfig files
2d589653 CPack/Deb generation of DEBIAN/shlibs control file
2016-05-16 10:11:30 -04:00
Domen Vrankar 44ee2d717a CPack/RPM different package names
Packagers may now set their own rpm package
file names or request that rpmbuild tool
chooses one for them. It also supports handing
of situations where one spec file may produce
multiple rpm packages.
2016-05-15 03:01:34 +02:00
Domen Vrankar f5089cfccd CPack/RPM adding dist to release tag test
Tests and release notes
2016-05-14 20:21:32 +02:00
Rolf Eike Beer df97b9793f FindPkgConfig: optionally create imported target for the found libraries 2016-05-14 09:31:41 +02:00
Domen Vrankar 7e940bf74a CPack/Deb test changes due to breaking changes
New CPack/Deb tests and changes to old tests
as package file names and inter component dependency
detection was changed.
2016-05-13 10:46:05 -04:00
Brad King b30b32a493 Drop find_(library|file|path) prefixes from PATH on non-Windows
Since commit v3.3.0-rc1~430^2 (Teach find_(library|file|path) to get
prefixes from PATH, 2015-02-18) we search in <prefix>/include and
<prefix>/lib directories for prefixes with bin directories in the PATH
environment variable.  The motivation was to support MSYS, MinGW and
similar Windows platforms in their default environments automatically.
At the time this behavior was thought to be worthwhile in general.

Suggested-by: Chuck Atkins <chuck.atkins@kitware.com>
2016-05-09 12:58:08 -04:00
Jean-Christophe Fillion-Robin 8c2cedc624 CustomCommandGenerator: Add support for CROSSCOMPILING_EMULATOR
Teach the `add_custom_command` and `add_custom_target' commands to
substitute argv0 with the crosscompiling emulator if it is a target with
the `CROSSCOMPILING_EMULATOR` property set.
2016-05-09 08:56:27 -04:00
Jean-Christophe Fillion-Robin eccfc0d185 Tests: Improve source file name in RunCMake.CrosscompilingEmulator
The test executable returns with an error, so indicate this in the
source name.
2016-05-03 10:42:21 -04:00
Jean-Christophe Fillion-Robin 8de778118b Tests: Cover genex behavior in CROSSCOMPILING_EMULATOR test case
A `$<TARGET_FILE:tgt>` generator expression does not cause insertion of
the emulator.  Add a test covering this.  While at it, extend the test
case to cover executables in a subdirectory.  Also make the test
matching expressions more robust to support multiple add_test calls
without mixing them while matching.
2016-05-03 10:41:52 -04:00
Brad King 845cb217a7 CMP0059: Fix typo in policy description 2016-05-02 15:16:07 -04:00
Brad King 24b2a36778 Merge topic 'test-watcom-workaround'
47c29885 Tests: Fix RunCMake.BuildDepends filesystem delay for Watcom WMake
26790ad9 Tests: Add workaround to Wrapping test for Watcom failure
2016-05-02 09:24:23 -04:00
Brad King 067b21b675 Merge topic 'clang-format-include-order'
e1c77472 Format include directive blocks and ordering with clang-format
180538c7 Source: Stabilize include order
0e7bca92 Utilities/Release: Stabilize include order in WiX custom action
eb817be0 Tests: Stabilize include order in MFC, VSXaml, and VSWinStorePhone
eda313b4 Tests: Stabilize include order in StringFileTest
7110b754 CursesDialog: add missing cmState include
d7a5f255 Modules: Remove unused CMakeTestWatcomVersion.c file
2016-05-02 09:24:21 -04:00
Brad King e1c7747253 Format include directive blocks and ordering with clang-format
Sort include directives within each block (separated by a blank line) in
lexicographic order (except to prioritize `sys/types.h` first).  First
run `clang-format` with the config file:

    ---
    SortIncludes: false
    ...

Commit the result temporarily.  Then run `clang-format` again with:

    ---
    SortIncludes: true
    IncludeCategories:
      - Regex:    'sys/types.h'
        Priority: -1
    ...

Commit the result temporarily.  Start a new branch and cherry-pick the
second commit.  Manually resolve conflicts to preserve indentation of
re-ordered includes.  This cleans up the include ordering without
changing any other style.

Use the following command to run `clang-format`:

    $ git ls-files -z -- \
        '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
      egrep -z -v '(Lexer|Parser|ParserHelper)\.' |
      egrep -z -v '^Source/cm_sha2' |
      egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
      egrep -z -v '^Utilities/(KW|cm).*/' |
      egrep -z -v '^Tests/Module/GenerateExportHeader' |
      egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
      xargs -0 clang-format -i

This selects source files that do not come from a third-party.

Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2016-04-29 13:58:54 -04:00
Brad King 47c298851b Tests: Fix RunCMake.BuildDepends filesystem delay for Watcom WMake
Our 1.125s delay does not seem to be long enough to be reliable with
the Watcom `wmake` tool.  Use a longer delay for Watcom.
2016-04-29 11:47:35 -04:00
Brad King ce82e0a53f Deprecate Visual Studio 7 .NET 2003 generator
Update documentation to mark the generator deprecated.  Add a warning at
the end of generation plus an option to turn off the warning.
2016-04-28 10:09:20 -04:00
Brad King 6a501b6519 Tests: Drop test for VS 7.0 generator deprecation warnings
We removed this generator but forgot to remove this now-unused test
case.
2016-04-28 10:04:09 -04:00
Brad King 7c36d2067b cmListFileBacktrace: Refactor storage to provide efficient value semantics
Since commit v3.4.0-rc1~321^2~2 (Genex: Store a backtrace, not a pointer
to one, 2015-07-08) we treat cmListFileBacktrace instances as
lightweight values.  This was true at the time only because the
backtrace information was kept in the cmState snapshot hierarchy.
However, that forced us to accumulate a lot of otherwise short-lived
snapshots just to have the backtrace fields available for reference by
cmListFileBacktrace instances.  Recent refactoring made backtrace
instances independent of the snapshot hierarchy to avoid accumulating
short-lived snapshots.  This came at the cost of making backtrace values
heavy again, leading to lots of string coying and slower execution.

Fix this by refactoring cmListFileBacktrace to provide value semantics
with efficient shared storage underneath.  Teach cmMakefile to maintain
its call stack using an instance of cmListFileBacktrace.  This approach
allows the current backtrace to be efficiently saved whenever it is
needed.

Also teach cmListFileBacktrace the notion of a file-level scope.  This
is useful for messages about the whole file (e.g. during parsing) that
are not specific to any line within it.  Push the CMakeLists.txt scope
for each directory and never pop it.  This ensures that we always have
some context information and simplifies cmMakefile::IssueMessage.
Push/pop a file-level scope as each included file is processed.  This
supersedes cmParseFileScope and improves diagnostic message context
information in a few places.  Fix the corresponding test cases to expect
the improved output.
2016-04-18 09:21:19 -04:00
Brad King eae4cee0b5 Merge topic 'try_compile-config-flags'
bd581a37 try_compile: Honor CMAKE_<LANG>_FLAGS_<CONFIG> changes (#16054)
82ef90fc cmCoreTryCompile: Factor out config lookup for re-use
2016-04-13 09:58:18 -04:00
Daniel Pfeifer 5e62444cff Add options to run clang-tidy with the compiler
Create a <LANG>_CLANG_TIDY target property (initialized by a
CMAKE_<LANG>_CLANG_TIDY variable) to specify a clang-tidy command line
to be run along with the compiler.
2016-04-13 09:56:10 -04:00
Brad King bd581a3733 try_compile: Honor CMAKE_<LANG>_FLAGS_<CONFIG> changes (#16054)
In the `try_compile` source file signature we propagate the caller's
value of `CMAKE_<LANG>_FLAGS` into the test project.  Extend this to
propagate `CMAKE_<LANG>_FLAGS_<CONFIG>` too instead of always using the
default value in the test project.  This will be useful, for example, to
allow the MSVC runtime library to be changed (e.g. `-MDd` => `-MTd`).
2016-04-11 11:25:08 -04:00
Brad King 9ac11bc25d Merge topic 'test-RunCMake.BuildDepends-filesystem-workaround'
f5e79004 Tests: Work around filesystem timestamp bugs in RunCMake.BuildDepends
2016-04-11 09:39:00 -04:00
Brad King f5e79004e2 Tests: Work around filesystem timestamp bugs in RunCMake.BuildDepends
The Custom-Symbolic-and-Byproduct case fails strangely on some
filesystems used by our nightly testing.  Somehow on the first build the
`use-byproduct` output ends up with a timestamp older than
`gen-byproduct-stamp` even though the build log clearly shows them build
in the correct order (and must according to build system dependencies).
Work around this problem by adding an extra delay before building
`use-byproduct`.

Tested-by: Gerhard Grimm <gerhard.grimm@detec.com>
2016-04-08 10:51:01 -04:00
Brad King f6c5958047 Merge topic 'ninja-restat-custom-command-byproducts'
add7abc8 Ninja: Restat custom command byproducts even with a SYMBOLIC output (#16049)
ff805113 Ninja: Fix detection of custom command symbolic outputs
2016-04-08 09:03:59 -04:00
Brad King add7abc835 Ninja: Restat custom command byproducts even with a SYMBOLIC output (#16049)
The change in commit v3.5.0-rc1~198^2 (Ninja: Always re-run custom
commands that have symbolic dependencies, 2015-11-19) broke the
byproducts feature added by commit v3.2.0-rc1~340^2~2 (Add an option for
explicit BYPRODUCTS of custom commands, 2014-11-13) when SYMBOLIC
outputs also appear.  This case occurs with AUTORCC-generated custom
targets because the output is SYMBOLIC (to always run) and the generated
file is a byproduct (for restat so dependents do not run unnecessarily).

The two use cases conflict because Ninja does not support per-output
restat.  Favor restat whenever byproducts are present because it is
required for byproducts to work correctly.  In use cases where we want
an always-run chain we simply will not be able to also use byproducts.
2016-04-05 16:20:28 -04:00
Brad King 917d49ed93 Merge topic 'cmake-depend-in-project-only'
b06e17da Help: Add notes for topic 'cmake-depend-in-project-only'
52540245 Tests: Add test for CMAKE_DEPENDS_IN_PROJECT_ONLY variable
b1e1aa1e Makefile: Optionally scan only source and build trees for dependencies
2016-03-24 08:49:43 -04:00
Brad King 5b2acf6c1c Merge topic 'vs-startup-project'
ad140c6e VS: Put ALL_BUILD in the PREDEFINED_TARGETS_FOLDER
f069be05 VS: Fix default target support for targets nested inside a folder
c05ea485 VS: Improve unit test macros
78ec0461 VS: Add option to choose the `.sln` startup project (#15578)
2016-03-24 08:49:41 -04:00
Brad King 525402450a Tests: Add test for CMAKE_DEPENDS_IN_PROJECT_ONLY variable 2016-03-23 14:03:01 -04:00
Taylor Braun-Jones f069be0548 VS: Fix default target support for targets nested inside a folder
It's not actually the first target in a `.sln` file that is treated as
the default startup project, but rather the first fully defined target.
2016-03-23 13:22:15 -04:00
Brad King 6201c1a6ce Merge topic 'timeout_after_match'
de7afd29 Help: Add notes for topic 'timeout_after_match'
993e48d0 CTest: Optionally use a secondary test timeout after matching output
2016-03-22 16:09:28 -04:00
Brad King 208524b822 Merge topic 'test-rename-VSSolution'
5c1f4da8 Tests: Rename RunCMake.{SolutionGlobalSections => VSSolution}
2016-03-22 13:04:24 -04:00
Taylor Braun-Jones c05ea48545 VS: Improve unit test macros
Change `getFirstProject` macro to more flexible version
`getProjectNames`
2016-03-22 12:41:30 -04:00
Zack Galbreath 993e48d045 CTest: Optionally use a secondary test timeout after matching output
Allow a test N seconds to complete after we detect a matching line in
its output.  Activate this behavior with a new TIMEOUT_AFTER_MATCH test
property.
2016-03-22 11:17:55 -04:00
Brad King 2f9e6551c0 Merge topic 'ninja-directory-targets'
9ead71df Help: Add notes for topic 'ninja-directory-targets'
e9bf8ec8 Ninja: Add test for `$subdir/all` targets
ca575fe9 Ninja: Add `$subdir/all` targets
2016-03-22 11:15:38 -04:00
Brad King 86eb327cda Merge topic 'fix-repeat-pkg-config'
6f4f9054 FindPkgConfig: set correctly named variables in cache (#15903)
2016-03-22 11:15:33 -04:00
Brad King e9bf8ec849 Ninja: Add test for `$subdir/all` targets 2016-03-22 08:01:14 -04:00
Davy Durham 78ec046130 VS: Add option to choose the `.sln` startup project (#15578)
Add a `VS_STARTUP_PROJECT` directory property to specify the project
that should be placed first in the `.sln` file so that it will be
selected as the default startup project.

Co-Author: Taylor Braun-Jones <taylor.braunjones@avigilon.com>
2016-03-22 07:57:00 -04:00