67 Commits

Author SHA1 Message Date
Sebastian Holtermann
e91bfe440c cmMakefile: Let AddDefinition accept a value as cm::string_view
This changes `cmMakefile::AddDefinition` to take a `cm::string_view` as value
argument instead of a `const char *`.

Benefits are:
- `std::string` can be passed to `cmMakefile::AddDefinition` directly without
  the `c_str()` plus string length recomputation fallback.
- Lengths of literals passed to `cmMakefile::AddDefinition` can be computed at
  compile time.

In various sources uses of `cmMakefile::AddDefinition` are adapted to avoid
`std::string::c_str` calls and the `std::string` is passed directly.
Uses of `cmMakefile::AddDefinition`, where a `nullptr` `const char*` might
be passed to `cmMakefile::AddDefinition` are extended with `nullptr` checks.
2019-07-24 11:11:25 +02:00
Fred Baksik
3b415c60c1 GHS: Update ExternalProject for GHS tools
-- When using default values for the external project forward GHS platform
   variables so that the external project builds with the same tools as
   the original project.

-- Fix issue with bad top level project when GHS_PRIMARY_TARGET is set but has
   no value.  In this case treat it as unset and use default value.
2019-04-11 13:15:51 -04:00
Fred Baksik
83c47ef5b8 GHS: Update project layout to accommodate gbuild inconsistencies
-- Do not use reference projects, use build hierarchy instead.
   gbuild has three parallel levels:
   * low -- Parallelizes compiling source files within a single project (.gpj)
     file when safe to do so.
   * medium -- Parallelizes processing files within a single linked output when
     safe to do so.
   * high [default] -- Parallelizes processing files whenever safe to do so,
     including linking task.

   Testing showed that for some combinations of gbuild / MULTI there are issues
   with building a project that uses references to target project files along with
   using {nobuild} option.

   Sometimes the archiving of a library and linking of an executable were
   happening in parallel and the build would fail when linking because the
   archive wasn't complete.

   This behavior was also inconsistent when running the build from MULTI and
   from the command line with gbuild. In some cases MULTI did not parallelize
   archiving and linking, but gbuild performed these actions in parallel.

   The parallel build issue was not seen when using a build hierarchy where the
   project listed the project files normally instead of using a reference link.

   The other option was to add the -parallel_level=medium to the command line
   when using "cmake --build" but this wouldn't fix the issue if gbuild itself
   was used to and the user might not be aware of the extra option used by cmake.
2019-04-11 13:15:51 -04:00
Fred Baksik
5d2e1404bd GHS: Update project layout to build targets correctly
-- Restructure projects and files to support proper building of targets
   Build order is determined by hierarchy of project files and folders
   Custom targets may have been run multiple times in the original file / folder structure
-- Default to build targets that are part of ALL target
-- List all known targets for this project
   Includes global targets for ALL_BUILD and INSTALL
-- Compute build order for building targets
2019-04-11 13:15:50 -04:00
Fred Baksik
b6bfa7eeb2 GHS: Support add_dependencies() command
-- use references to list target dependencies
2019-04-11 13:15:50 -04:00
Fred Baksik
39ee9718d9 GHS: Support add_custom_target() command
-- add new project type that runs shell scripts in proper order
2019-04-11 13:15:50 -04:00
Fred Baksik
8d3dad9a76 GHS: Support add_custom_command( OUTPUT ) signature
-- add new file type to run a shell script
-- gbuild does not compute interfile dependencies like other build tools.
   Therefore calculate the required build order of custom commands and
   list all of them in the CMake Rules subproject.
2019-04-11 13:15:50 -04:00
Fred Baksik
a1e6b414b9 GHS: Update GHS_BSP_NAME processing
-- Set name earlier so that the initial project() compiler checks
   run correctly when GHS_BSP_NAME is not specified on command line.
2019-03-29 12:38:34 -04:00
Fred Baksik
266dadf868 GHS: Print status message regarding GHS_OS_DIR
-- Rename platform script so it runs before initial try_compile() in
   project() command.
-- Fix incorrect variable name GHS_OS_DIR_OPTION
-- Remove unnecessary ".*" from REGEX expression for GHS_CANDIDATE_OS_DIRS
-- Forward GHS_OS_DIR_OPTION to try_compile() and preserve trailing
   whitespace of the variable.
2019-03-29 12:38:12 -04:00
Brad King
89abbdd8c8 Merge topic 'ghs-linux'
2c43fb5be3 FindThreads: Fix pthread library check in GHS Multi Generator
0404efe786 GHS: Add support for GHS Multi Generator in Linux
2060a1445c Tests: Fix file name case in GHS object library test
ddad70c8a4 Tests: Run GHS tests in a separate ctest process
f7dca1fc97 GHS: Fix include-what-you-use and clang-tidy diagnostics

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3006
2019-03-22 09:22:44 -04:00
Naren Manimohan
0404efe786 GHS: Add support for GHS Multi Generator in Linux 2019-03-21 12:57:40 -04:00
Brad King
f7dca1fc97 GHS: Fix include-what-you-use and clang-tidy diagnostics
We will soon build GHS sources on Linux where we run these lints.
2019-03-20 09:48:29 -04:00
Brad King
a13a5c948e Replace use of CollapseCombinedPath with CollapseFullPath
`CollapseCombinedPath` was introduced by commit 551d3343cd (cmDependsC:
Collapse relative include paths, 2013-06-19, v2.8.12~237^2) where the
existing `CollapseFullPath` should have been used instead.  Then its use
proliferated slightly.  Since `CollapseCombinedPath` is less widely used
and less robust (see issue #19049), use `CollapseFullPath` everywhere
instead.

Issue: #19050
2019-03-19 09:57:23 -04:00
Bartosz Kosiorek
324d18bb34 cmake: Teach --build mode to support multiple targets
Fixes: #16136
2019-03-05 08:55:28 -05:00
Bartosz Kosiorek
fdeb364a84 cmGlobalGenerator: Change case of methods from GeneratedMakeCommand struct 2019-03-04 10:44:14 +01:00
Artur Ryt
01b2d6ab74 Modernize: Use ranged for-loops when possible
Replaced most manual `const_iterator`-based loops and some
reverse-iterator loops with range loops.

Fixes: #18858
2019-02-07 22:39:05 +01:00
Brad King
9620cb935a Merge topic 'add_consistent_verbose_build_flag'
66801f4d40 cmake: Add tests for verbose output to --build mode
439fe2e253 cmake: Add options for verbose output to --build mode
638667efa2 cmake: cmcmd.cxx fix "The arguments are" comments
3ca4402966 ctest: Fix --build-and-test without --build-target on Xcode
cb6c233ecc cmake: Add -hideShellScriptEnvironment xcodebuild option
1a45266cb5 cmGlobalGenerator: Add a class that represent the build command

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2708
2019-01-29 09:19:39 -05:00
Brad King
60c06620a6 Merge topic 'cmoutputconverter-simplify'
b6a957c969 cmOutputConverter: move ConvertToRelativePath to cmStateDirectory.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2831
2019-01-29 09:18:42 -05:00
Vitaly Stakhovsky
186d9b083d cmSystemTools::Message: Add overload accepting std::string 2019-01-28 09:35:51 -05:00
Bruno Manganelli
b6a957c969 cmOutputConverter: move ConvertToRelativePath to cmStateDirectory. 2019-01-27 15:48:57 +00: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
Vitaly Stakhovsky
99337d345b cmSystemTools::Error(): new overload accepting std::string 2019-01-23 10:19:30 -05:00
Fred Baksik
72e0c115b7 GHS: Add Compiler ID detection
-- Detect GHS compiler and version
   Detect ARCHITECTURE_ID for PPC / ARM / 86 targets
   Detect PLATFORM_ID for Integrity and Integrity178 platforms
   Using defines specified in the documents for the compilers: 201416 PPC / 201754 ARM / 201714 86
-- Fallback C/CXX compiler ID to GHS if not otherwise detected and using GHS MULTI generator
   Works around issue with some GHS compilers not setting __ghs__ compiler define
-- Tweak Compiler ID checking so major id of 002017 is not replaced with 217
-- Prefer try_compile() library targets when testing for working GHS compilers
-- Avoid CMake errors if reading past end of file for checking if file is PE executable
2019-01-16 10:42:04 -05:00
Fred Baksik
436cc5e991 GHS: try_compile() now uses GHS platform variables
-- Forward GHS platform variables to try_compile()
   CMAKE_TRY_COMPILE_PLATFORM_VARIABLES only worked for source signature try_compile()
-- Update tests to no longer add GHS platform variables to try_compile()
-- Avoid linker error in GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt by building library
2019-01-16 10:42:00 -05:00
Fred Baksik
4a1ec0de3d GHS: Fix toolset selection
-- Allow -T to accept full or partial paths
-- Use "C:/ghs" if GHS_TOOLSET_ROOT is empty string
-- Put more information in error messages
2019-01-16 10:41:56 -05:00
Fred Baksik
1a66acdef2 GHS: Append ".gpj" to target name when generating build command
-- Add test demonstrating issue
-- In the case of executable targets the target name is usually the same as used in "-o filename"
   But for static libraries the target name is usually "-o libname.a"
   "gbuild.exe target" will build whatever target matches against even the output from the compiler or linker
   But the targets in "cmake --build . --target name" should be target names in CMakeLists.txt not the actual filenames
   So change the "name" to "name.gpj" so it matches the target name in CMakeLists.txt.

Fixes #15975
2019-01-16 10:41:53 -05:00
Fred Baksik
0c9e47d7cd GHS: Integrity Application updates
-- Check the property "ghs_integrity_app" on executables to set [INTEGRITY Application]
   If the property is not set then check if an integrate file is one of the source files (.int file).
   Dynamic Downloads that do not have an integrate file can use this property along with setting
   the compiler flag "-dynamic".

-- Remove parsing for -dynamic flag; it is only used to print a comment
   The MULTI GUI will show if it is a Monolith or Dynamic Download application

-- Use project references to specify which executables are part of the Integrity Application
   Usually Implicit Dependency Analysis will ensure that executable targets
   become part of the application.  This does not work for Dynamic Download without integrate files.
   Use `add_dependencies(dd vas)` to mark that the vas target is part of dd target.

-- Update file locations in the Integrate files.
2019-01-16 10:41:49 -05:00
Fred Baksik
14f3ba2059 GHS: EXCLUDE_FROM_ALL updates
-- Excluded targets should be generated but not included in build ALL
-- Use the correct source list for this configuration when writing sources
2019-01-16 10:41:38 -05:00
Fred Baksik
b2a72ec72d GHS: Cleanup unused file handling functions and file output updates
-- File handling cleanup
-- Rename some functions to clarify what they do
-- Update to source file path conversion; only perform conversion when using windows
2019-01-16 10:41:31 -05:00
Fred Baksik
2ed2d6b46f GHS: Place build system outputs per target output directives
-- Set output and object file locations
-- Suffixes are no longer being forced but will now follow the target properties
   By default GHS tools have no suffix for executable files so
   CMAKE_EXECUTABLE_SUFFIX was changed to meet this behavior
-- Remove #if 0 blocked out code; it has been replaced.
   Forcing the -relprog option has been removed from non-kernel executable targets.
   The default value of this option (if it is even available) is determined by the
   tool-chain for the specified target and platform (Some tool-chains default to
   -locatedprogram).  The use of -relprog can have unexpected results as it cannot
   always produce a fully relocated executable.
-- Clarify use of CMAKE_BUILD_TYPE to control build configuration
2019-01-16 10:41:24 -05:00
Fred Baksik
ead7117afd GHS: Update the top-level project generation
-- Sort targets by name
-- Generate a top-level project for each project command named as project.top.gpj
   Use the target set for the current project instead of assuming all targets
-- Add support for building projects not in binary root
-- Directly create files and pass ostream
-- Do no generate project files for UTILITY targets; this was never supported
-- Do no generate project files for OBJECT, SHARED, or MODULE libraries; this was never supported
-- Update GHS tags to support project types
   NOTE: The default tag is changed to "" because "[ ]" is an invalid token in project file
2019-01-16 10:41:20 -05:00
Fred Baksik
6436080996 GHS: Have the top-level project name follow the specified project name 2019-01-16 10:41:07 -05:00
Fred Baksik
a42e40e78d GHS: Only print bsp and os directives if specified by user
-- standalone platforms will not build if bsp/os is specified in project file
-- integrity platforms will always print these directives because they are required
-- cleanup -os_dir setting
   allow customization of the actual setting because it is determined by tool-set customization files
   remove variable that was set but never used
-- add message when using default values
2019-01-16 10:40:59 -05:00
Bruno Manganelli
cc2a5261f8 Factor out enum MessageType into dedicated header
Reduce the number of files relying on `cmake.h`.
2019-01-16 08:16:31 -05:00
Fred Baksik
281c601024 GHS: Update default BSP name
-- Use default value of sim<arch> if not user defined
-- Also no reason to trim quotes or changes slashes; it is just a name not a path
2018-07-11 08:48:23 -04:00
Fred Baksik
bb77dc0cee GHS: Set primary target using arch/platform values (or user specified value) 2018-07-11 08:44:49 -04:00
Fred Baksik
f80692cf60 GHS: Add platform selection support 2018-07-11 08:33:21 -04:00
Fred Baksik
a37a4a00c8 GHS: Add toolset selection support
-- Use the specified toolset located within GHS_TOOLSET_ROOT
-- Update how the latest toolset is determined; scan the location GHS_TOOLSET_ROOT and sort it
   No longer use registry settings looking for installations
     The registry values are assigned in installation order for Green Hills tools not version order
-- Update to use gbuild.exe from the proper toolset
-- Clarify that CMAKE_MAKE_PROGRAM should not be set by user.
-- Detect some toolset changes when regenerating project files
   This could occur if GHS_TOOLSET_ROOT was changed by user after the initial project generation
   This could occur if CMAKE_MAKE_PROGRAM was changed at the command line
-- Use placeholder values for CMAKE_<LANG>_COMPILER
   The MULTI build system only uses gbuild to build a project
     gbuild uses the project file to determine which set of compilers to use based on target platform and architecture
     because compiler detection is skipped, placeholder values are used so that CMake does not complain
2018-07-11 08:28:36 -04:00
Fred Baksik
5d40d2b44f GHS: Support ARM, PPC, 86 architectures
-- Update -A option to choose target architecture.
-- Update commentary about which variables are used to control toolset and target settings
-- Remove setting CMAKE_SYSTEM_PROCESSOR because the value is overwritten to be "" by subsequent CMAKE processing
2018-07-07 07:27:21 -04:00
Brad King
b41b30f16e Update use of KWSys SystemTools::SplitString for new signature 2018-06-22 13:38:18 -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
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
Aaron Orenstein
7bc6577017 Performance: Fix a few more unnecessary vector copies missed in af3fd6f 2017-08-18 07:59:52 -07: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
d0c14dfb36 avoid including cmStandardIncludes.h 2016-11-28 14:06:41 -05: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
Gregor Jasny
3b6f1587be Factor IDE folder name retrieval out into helper method
Add a `cmGeneratorTarget::GetEffectiveFolderName` helper to abstract
lookup of the `FOLDER` property in combination with checking for
generator support of folders.
2016-10-17 10:06:18 -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
Daniel Pfeifer
efed6468ed fix a load of include-what-you-use violations 2016-09-03 08:04:56 -04:00