f62ed322 cmLocalGenerator: Add GetTargetDefines to get all defines for a target
853b1bb4 cmLocalGenerator: Constify AppendDefines and AddCompileDefinitions
The force parameter is ugly and makes the method harder to reason about
(issues the message ... but maybe it doesn't ... but then again you can
force it). It is a violation of
https://en.wikipedia.org/wiki/Interface_segregation_principle
and is the kind of thing described in a recent blog here:
http://code.joejag.com/2016/anti-if-the-missing-patterns.html
"Any time you see this you actually have two methods bundled into one.
That boolean represents an opportunity to name a concept in your code."
The makefile is only used when called by the cmMessageCommand, so inline
the use of it there. It otherwise creates an undesirable dependency on
cmMakefile for issuing messages in the cmake instance, a violation of
the Interface Segregation Principle.
https://en.wikipedia.org/wiki/Interface_segregation_principle
This also makes it more explicit that the variable definitions only
affect the message() command. If an AUTHOR_WARNING is issued for any
other reason, it is not affected. To affect that, it is necessary to
set the cache variable instead of the regular variable.
This is an unfortunate interface quirk, but one which can't be fixed
easily now.
Add a ``FIND_LIBRARY_USE_LIB32_PATHS`` global property analogous to the
``FIND_LIBRARY_USE_LIB64_PATHS`` property. This helps find commands on
multilib systems that use ``lib32`` directories and either do not have
``lib`` symlinks or point ``lib`` to ``lib64``.
When we are on OSX and we are launching cmake-gui from a symlink, the
application will fail to launch as it can't find the qt.conf file which
tells it what the name of the plugin folder is. We need to add this path
BEFORE the application is constructed as that is what triggers the
searching for the platform plugins
CMakeFindBinUtils sets CMAKE_RANLIB to `:` if it is not available in
order to get a no-op. This does not work on a Windows host build
environment that runs commands in `cmd` instead of `sh`. Teach the
Ninja and Makefile generators to simply skip the command if it is `:`.
This this was already done by the Makefile generator since commit
v2.6.0~3161 (BUG: Do not write link script lines that use the ':',
2006-06-18), but only when using a link script.
Reported-by: Michael Jäntsch <Michael.Jaentsch@gmx.de>
After finding it in `foo.Framework/Headers/dir/header.h`, we should
report the `foo.Framework/Headers` directory, not
`foo.Framework/Headers/dir`, because the former is what actually
contains the path the caller wishes to include.
63e5eb5f Help: Add notes for 'productbuild' topic
2e3c67d1 productbuild: Add new productbuild cpack generator.
50a3d340 PackageMaker: factor out common code for creating pkg files.
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.
Use clang-tidy's readability-simplify-boolean-expr checker.
After applying the fix-its, revise all changes *very* carefully.
Be aware of false positives and invalid changes.
Use clang-tidy's performance-unnecessary-copy-initialization checker.
After applying the fix-its (which turns the copies into const&), revise
the changes and see whether the copies can be removed entirely by using
the original instead.
Use clang-tidy's performance-unnecessary-value-param checker to find
value parameter declarations of expensive to copy types that are not
modified inside the function. Ignore findings in kwsys.
After applying the fix-its, manually change `const T&` to `T const&`.
d256ba07 try_compile: Optionally forward custom platform variables to test project
fb4791b3 cmCoreTryCompile: Refactor forwarding of 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.
De-duplicate the logic that constructs the cmake `-D` flag used to pass
variables into the test project cache. Also subsume variables that were
propagated by generating `set()` commands in the project and pass them
as cache entries instead.
5784747d Improve string find: prefer character overloads.
5cec953e Use std::replace for replacing chars in strings.
2a1a2033 cmExtraEclipseCDT4Generator: use std::replace.
34bc6e1f cmCTestScriptHandler: don't call find repeatedly.
c1340827 Add a variable to specify language-wide system include directories
44199097 cmMakefile: Optimize AddSystemIncludeDirectories for empty set
a896043b GHS: Compute include directories consistently with other generators
Create a `CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES` variable to specify
system include directories for for `<LANG>` compiler command lines.
This plays a role for include directories as the existing
`CMAKE_<LANG>_STANDARD_LIBRARIES` variable does for link libraries.
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.
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
Manually extract the C++ portion of `cmListFileLexer.in.l` into a
temporary file, format it, and then move it back into the original file.
Manually format C++ code inside the lexer actions to match our style.
Then re-generate the lexer.
Revise the documented modifications we need to make to the
flex-generated source file according to the needs of the new version.
Update our own implementation to avoid warnings with flex types.
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/).
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.
In WriteObjectBuildStatement we pass object file names and directories
to several places that expect paths as Ninja sees them. Convert them to
Ninja paths before all such uses.
All paths generated on Ninja-invoked command lines should be passed
through ConvertToNinjaPath. Fix ConvertToLinkReference to call this
instead of partially duplicating its implementation.
In `AppendTargetOutputs` we generate a logical build target name for
each UTILITY command. Simplify the logic to avoid testing the result
of `ConvertToNinjaPath`.
d9fd2f54 Revise C++ coding style using clang-format
82df6dea Empty commit at end of history preceding clang-format style transition
6a13f43f CONTRIBUTING: Add a section on coding style
bf451d9f Add a script to run clang-format on the entire source tree
1e90d78f Configure clang-format for CMake source tree
da60adc3 Tell Git to use a distinct conflict marker size in `.rst` files
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.
The `IMPLEMENT_VISIT_IMPL` macro must preserve a space before the `>`
character in case the `DATATYPE` is a template type ending in `>`.
Manually format the macro layout as clang-format would except for this
space. Then add markup to tell clang-format not to format this macro.
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.
The empty string we add as a link item for an INTERFACE_LIBRARY target
is not a path, so do not mark it as such. The generators currently
tolerate it either way, but only by accident.
Set LC_NUMERIC = "C" at startup after Qt initializes the application
because Qt may have adopted the current locale from the environment.
CMake does not define behavior for non-C-locale numeric behavior.
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>
afca3735 Help clang-format wrap after braces on long initializer lists
85425a3e Move comments off of class access specifier lines
64b55203 Isolate formatted streaming blocks with clang-format off/on
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.
Add a long comment inside a few braced initializer lists in order to
convince clang-format to break after the opening brace and format the
list without indenting every value past the opening brace.
The clang-format tool may turn this:
public: // comment about access specifier
// unrelated comment indented with code
...
Into:
public: // comment about access specifier
// unrelated comment indented with code
...
Avoid this by moving comments off of access specifier lines.
The clang-format tool can do a good job formatting most code, but
well-organized streaming blocks are best left manually formatted.
Find blocks of the form
os <<
"...\n"
"...\n"
;
using the command
$ git ls-files -z -- Source |
egrep -v -z '^Source/kwsys/' |
xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
'<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}'
Find blocks of the form
os << "...\n"
<< "...\n"
<< "...\n";
using the command
$ git ls-files -z -- Source |
egrep -v -z '^Source/kwsys/' |
xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
'<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}'
Surround such blocks with the pair
/* clang-format off */
...
/* clang-format on */
in order to protect them from update by clang-format. Use the C-style
`/*...*/` comments instead of C++-style `//...` comments in order to
prevent them from ever being swallowed by re-formatting of surrounding
comments.
Add missing unset of scratch variables to generated export file for case
that the file was already included. We already unset these when parsing
the file normally, but the multiple inclusion case was leaving them
around.
5f948d2a Help: Add policy summaries to cmake-policies(7)
b74d73e5 Help: Organize cmake-policies(7) manual by version of introduction
de370656 cmRST: Parse toctree lines with Sphinx cross-reference syntax
845cb217 CMP0059: Fix typo in policy description
54f71cd7 Source: Sort includes the way clang-format would
7b6ffa59 Source: Sort includes of sys/types.h as clang-format would
be14fe48 Source: Stabilize include order of sys/types.h before sys/stat.h
5e871f70 Tests: Sort includes of sys/types.h as clang-format would
a20d7d48 Tests: Fix Plugin test 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
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>
Clang-Tidy writes the number of warnings, the number of suppressed
warnings, and instructions on how to suppress warnings to stderr. Since
each source file is checked individually, this repetitive information is
disturbing and should be suppressed.
The actual warning messages are written to stdout. Some IDEs (eg.
QtCreator) analyze only stderr for issues. Redirecting Clang-Tidy's
stdout to stderr makes sure the warnings are correctly displayed.
To avoid Race conditions with other processes writing to stdout/stderr compose
the whole message in a std::stringstream then submit the single complete message.
84946c73 Tests: QtAutogen: Same source name in different directories test
9c6fa684 Autogen: Generate qrc_NAME.cpp files in subdirectories
488ea8c7 Autogen: Generate not included moc files in subdirectories (#12873)
66caae45 Autogen: Check added for name collisions of generated qrc_NAME.cpp files
663d093d Autogen: Check added for name collisions of generated ui_NAME.h files
8295d437 Autogen: Check added for name collisions of generated moc files
d350308a Help: Improve AUTOMOC documentation layout
2263949b cmGlobalXCodeGenerator: do not pass char* to cmSystemTools::CollapseFullPath()
2b25ce30 make cmGlobalXCodeGenerator::XCodeEscapePath() take a std::string&
ffedf352 make cmGlobalXCodeGenerator::BuildObjectListOrString::Add() take a string&
6100bdff cmGlobalXCodeGenerator: directly call CreateString() with std::string
A qrc_NAME.cpp file generated from NAME.qrc in the directory
CMAKE_CURRENT_SOURCE_DIR/SUBDIR
will be generated in the directory
CMAKE_CURRENT_BINARY_DIR/TARGETNAME_automoc.dir/SUBDIR
Not included moc files generated from a source file in
CMAKE_CURRENT_SOURCE_DIR/SUBDIR
will be generated in the directory
CMAKE_CURRENT_BINARY_DIR/TARGETNAME_automoc.dir/SUBDIR/
Running the testsuite this function is entered more than 126,000 times. Reorder
the code flow so that a conversion from char* to std::string is only done when
the cache entry is a path one, which happens only ~50 times during the
testsuite.
840b830b Autogen: Qrc processing: Generate single map with final input / output names
bc4c7751 Autogen: Ui processing: Generate single map with final input / output names
47e60bc5 Autogen: Split out UI file generation code to dedicated method
cf679ea8 Autogen: Split out moc file generation code to dedicated method
3ea1d090 Autogen: Rename method GenerateQrc{ => Files}
8ced8bb9 Autogen: New logCommand method. It prints commands using std::cout.
95064a6d Autogen: Rename header extension Join method to JoinExts
7a73c404 Autogen: Use SystemTools string functions instead of rolling out own