183 Commits

Author SHA1 Message Date
Sebastian Holtermann
735c6f39d9 Fix invalid ///! doxygen comment line starts
In various places `///!` was used to start a comment line.  This is not valid
Doygen syntax.  This patch replaces `///!` comment starts with `//!`.
2019-03-31 11:27:12 +02:00
Harry Mallon
413b71485a Xcode: Create Xcode schemes per target 2019-03-21 16:50:41 +00:00
Gregor Jasny
482d9ef9a8 cmGlobalXCodeGenerator: Prefer std::string over char* 2019-03-17 20:41:35 +01:00
Bartosz Kosiorek
324d18bb34 cmake: Teach --build mode to support multiple targets
Fixes: #16136
2019-03-05 08:55:28 -05:00
Brad King
eff9c69740 Xcode: Place object library artifacts outside Objects-normal directory
The `CONFIGURATION_BUILD_DIR` value in the Xcode project file specifies
where to place the library artifact.  For object libraries we've used
the `Objects-normal` directory to hide away the `.a` that we otherwise
cannot stop Xcode from producing.  The parent of this directory is also
specific to the target and does not vary with Xcode's sanitizer
features, so move the artifact there.

Issue: #16289
2019-01-30 10:28:05 -05:00
Robert Maynard
1a45266cb5 cmGlobalGenerator: Add a class that represent the build command
This refactors a std::vector<std::string> into a class so that
we can extend the features to represent things such as multiple
chained commands in the future.
2019-01-25 08:20:02 -05:00
Marc Chevrier
c4b4d8b3a6 POSITION_INDEPENDENT_CODE: Manage link flags for executables
Fixes: #14983, #16561
2018-11-11 17:34:09 +01:00
Brad King
39c91d0703 cmGlobalGenerator: Add IsXcode query
Make it easy to detect use of the Xcode generator.
2018-08-01 09:12:42 -04:00
Brad King
d0de296e50 Xcode: Factor target generation loop body into helper method 2018-07-19 13:20:28 -04:00
Brad King
30e27b4110 Xcode: Compute global order index for targets
Compute an index for each target in a global ordering such that no
target comes before its dependencies.
2018-07-19 13:20:28 -04:00
Gregor Jasny
985d3a162c Xcode: Use legacy build system
Closes: #18099
2018-06-19 10:56:50 -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
Florian Maushart
1ab3881ec9 cmake: Add options for parallel builds to --build mode
While we already support `cmake --build . -- -j`, the options after `--`
are specific to the native build tool.  Add new options `--parallel
[<N>]` and `-j [<N>]` to abstract this and map to the proper option
for the native build tool.
2018-05-25 09:42:20 -04:00
Brad King
8480c2afc0 Restore support for explicitly referenced CMakeLists.txt sources
Since commit v3.11.0-rc1~467^2 (VS,Xcode: Add CMakeLists.txt sources
without mutating targets, 2017-10-18) we do not add `CMakeLists.txt` to
target sources but instead generate references to them directly.  This
broke projects that explicitly specify their `CMakeLists.txt` file as a
source file because the explicit entry is no longer consolidated with
the generated one.

Teach the relevant generators to avoid duplicating `CMakeLists.txt`
source references and add test cases.

Fixes: #17828
2018-04-13 09:41:06 -04:00
Pavel Solodovnikov
653b894683 Reduce raw string pointers usage.
* Change some functions to take `std::string` instead of
  `const char*` in the following classes: `cmMakeFile`, `cmake`,
  `cmCoreTryCompile`, `cmSystemTools`,  `cmState`, `cmLocalGenerator`
  and a few others.
* Greatly reduce using of `const char*` overloads for
  `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`.
* Remove many redundant `c_str()` conversions throughout the code.
2018-01-31 18:23:03 +03:00
Marc Chevrier
3f935e690a LocalGenerator: refactoring
Introduce method AppendCompileOptions to support
future source file property COMPILE_OPTIONS.
2018-01-23 10:24:47 +01:00
Gregor Jasny
4017bf40de Darwin: Emit deployment target that matches the SDK
Closes: #17431
2017-12-22 21:56:53 +01:00
Gregor Jasny
5de37a4a64 cmake: Add --open option for IDE generators 2017-10-13 21:28:34 +02:00
Matthias Maennich
bb0ad1bea8 Fix some occurrences using string by value rather than by const&
Fix issues diagnosed by clang-tidy
 - performance-unnecessary-value-param
 - performance-unnecessary-copy-initialization

Signed-off-by: Matthias Maennich <matthias@maennich.net>
2017-09-28 07:23:40 -04:00
Brad King
0b33aee48b Use C++11 override instead of CM_OVERRIDE
We now require C++11 support including `override`.  Drop use of
the old compatibility macro.  Convert references as follows:

    git grep -l CM_OVERRIDE -- '*.h' '*.hxx' '*.cxx' |
      xargs sed -i 's/CM_OVERRIDE/override/g'
2017-09-15 10:06:41 -04:00
Daniel Pfeifer
ca2233e31f IWYU: Mark cmConfigure.h with pragma: keep
Also remove `#include "cmConfigure.h"` from most source files.
2017-08-26 07:41:04 +02:00
Gregor Jasny
c2a6df94ed Xcode: Use correct Object Library paths for cross-SDK builds
When calculating Object Library paths take a look at the
`XCODE_EMIT_EFFECTIVE_PLATFORM_NAME` property to enable builds with
different SDKs. Otherwise a hard-coded architecture could be chosen.

Fixes: #16040
2017-06-29 09:52:44 -04:00
Brad King
ef9c9c92f5 Merge topic 'remove-top-level-xcode-groups'
01cd88c0 Xcode: Remove the top-level Sources and Resources groups

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !779
2017-05-04 10:31:05 -04:00
Matt Stevens
01cd88c0e5 Xcode: Remove the top-level Sources and Resources groups
This addresses duplicate file reference warnings from xcodebuild caused
by the same file reference being a member of both the target's group and
the top-level Resources group. Since resources are already a member of
their associated target's group the top-level Resources group isn't
strictly necessary, and removing it results in a project structure
closer to that of a current Xcode project template.

Fixes: #15272
2017-05-03 11:05:42 -04:00
Ruslan Baratov
7e75568b00 Xcode: Support IPO (LTO) 2017-05-02 18:33:25 +03:00
Brad King
eaf53849ec Xcode: Compute version number earlier 2017-04-21 13:10:28 -04:00
Brad King
25f3f22a1a cmGlobalGenerator: Add method to check if object file location is known
Add a `HasKnownObjectFileLocation` method returning whether we know the
exact location of object files produced by the native build system.
This is true everywhere except on Xcode when an architecture placeholder
is used.
2017-04-18 09:03:33 -04:00
Brad King
8456ec833a Merge topic 'include-style'
1d829c86 Use quotes for non-system includes
26ee9e42 CPack: drop CPack prefix for includes
5afac50f cmConfigure: Ensure separate include block in headers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !691
2017-04-13 08:12:40 -04:00
Daniel Pfeifer
1d829c862c Use quotes for non-system includes
Automate with:

git grep -l '#include <cm_' -- Source \
  | xargs sed -i 's/#include <\(cm_.*\)>/#include "\1"/g'

git grep -l '#include <cmsys/' -- Source \
  | xargs sed -i 's/#include <\(cmsys\/.*\)>/#include "\1"/g'

git grep -l '#include <cm[A-Z]' -- Source \
  | xargs sed -i 's/#include <\(cm[A-Z].*\)>/#include "\1"/g'
2017-04-11 22:35:21 +02:00
Daniel Pfeifer
5afac50f68 cmConfigure: Ensure separate include block in headers
Make sure that `#include <cmConfigure.h>` is followed by an empty line
in header files.  This is necessary to make sure that changing <> to ""
does not affect the include ordering of clang-format.

Automate with:

git grep -l '#include <cmConfigure.h>' | grep -v '.cxx$' \
| xargs sed -i '/#include <cmConfigure.h>/ { N; N; s/\n\{1,2\}/\n\n/ }'
2017-04-11 22:35:20 +02:00
Brad King
8c346bbc6e Xcode: Compute a concrete object file arch dir if possible 2017-04-11 11:40:15 -04:00
Brad King
5f4e26dfc8 Xcode: Refactor object directory name computation
Factor out a helper function to compute the object directory name
architecture component.
2017-04-11 11:40:15 -04:00
Brad King
5b29fd6d4d Xcode: Refactor internal architecture list construction
Factor population of the `Architectures` member out into a helper to
avoid duplication.
2017-04-11 11:40:15 -04:00
Gregor Jasny
c51c2cfac6 Apple: Fix Resources location for all generators
Issue: #16680
2017-03-23 16:43:55 +01:00
Gregor Jasny
7202db5db4 Xcode: Fix schema container location calculation 2017-02-28 22:38:29 +01:00
Gregor Jasny
5995082101 Xcode: Do not autocreate schemes 2017-02-28 22:38:29 +01:00
Gusts Kaksis
ffb8817b37 Xcode: Write shared schemes based on the default files generated by Xcode
Issue: #15441
2017-02-28 09:21:54 -05:00
Gregor Jasny
10c9c73d58 Xcode: Control emission of EFFECTIVE_PLATFORM_NAME
When building with multiple SDKs within one project Xcode requires
the usage of ${EFFECTIVE_PLATFORM_NAME} to put temporary and build
outout into separate directories. For example an iOS device and
simulator build use two different SDKs (iphoneos and iphonesimulator).

In the past cmake tries to detect embedded toolchains that could
possibly use simulators and emitted EFFECTIVE_PLATFORM_NAME (EPN)
at the proper locations. In #16253 Mark noticed that if he
uses macosx and iphoneos in combination the necessary EPN is not
emitted. This is because CMake by default assumes macosx SDK which
does not trigger EPN emission.

The fist naive approach - enabling EPN unconditionally revealed that
then the EPN leaks into generator expressions like $<TARGET_FILE:xxx>
which might be a regression and thus is unacceptable.

The next approach was to add an CMake property to enable EPN emission
unconditionally. This solved the reported problem.

But the EPN leakage also happened for the embedded toolchains already
without anyone noticing. So the control property was turned into a
tri-state one:

 * No definition: EPN is activated for embedded toolchains like before
 * ON: EPN is always emitted
 * OFF: EPN is never emitted

That approach gives the user the chance to disable EPN for embedded
toolchains and restores generator expression functionality for those.

Closes: #16253
2017-01-20 13:51:48 -05:00
Daniel Pfeifer
aeff60e44c iwyu: Fix OSX specific issues 2016-11-23 00:41:44 +01:00
Gregor Jasny
c0e223cd2a Xcode: Add override keyword to suppress warnings 2016-11-17 22:39:46 +01:00
Brad King
2d3aa94225 cmGlobalGenerator: Allow FindMakeProgram to fail
Revise its signature to return `bool` so that it can fail and abort
configuration early.
2016-10-20 10:37:27 -04:00
Brad King
86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Stephen Kelly
4f68b2070f Xcode: Remove unused member
It is unused since commit v3.4.0-rc1~492^2~3 (Remove
CMAKE_USE_RELATIVE_PATHS variable., 2015-06-01).
2016-09-19 21:24:00 +02:00
Gregor Jasny
df32e564ae Xcode: Add targets marked as EXCLUDE_FROM_ALL to project (#16101) 2016-08-31 09:16:44 -04:00
Tobias Hunger
2175e5bfa5 cmGlobalGenerator: Make IsMultiConfig() const 2016-06-01 11:12:58 -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
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
180538c706 Source: Stabilize include order
Each source file has a logical first include file.  Include it in an
isolated block so that tools that sort includes do not move them.
2016-04-29 13:58:31 -04:00
Rolf Eike Beer
2b25ce30ca make cmGlobalXCodeGenerator::XCodeEscapePath() take a std::string&
All callers already have one, and it was immediately converted to one
internally. Just keep the old one around, and only modify it when needed.
2016-04-20 23:35:01 +02:00
Brad King
070f09f91e Merge topic 'xcode-global-attribute-variant'
d8bc26a0 Xcode: Parse variant and genex for CMAKE_XCODE_ATTRIBUTE (#14947)
dc0ddb9e Xcode: Store configuration name along with XcodeObject (#14947)
28f98cee Xcode: Make CMAKE_XCODE_ATTRIBUTE calculation last step (#14947)
28db2268 Xcode: Factor out XCODE_ATTRIBUTE_ variant filter (#14947)
2016-01-07 13:28:28 -05:00