95 Commits

Author SHA1 Message Date
Brad King
c09efe074d Merge topic 'gitlab-ci-lint'
4318e8ed35 gitlab-ci: add iwyu job
0866b9253b gitlab-ci: add initial clang-tidy build
0a5bcf97b9 gitlab-ci: add scripts for use by CI
960158b90d ci: add scripts to download build tools
6af91c7c4d ci: add an image for Debian 10
68903ae238 ci: add a Docker container for building CMake
3ac24a8a6e cmFunctionBlocker: include missing header
b745b8fd36 IWYU: mark includes needed for assert statements as needed
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4643
2020-04-30 10:00:02 -04:00
Ben Boeckel
a58457a6c2 IWYU: mark cmLinkLineComputer as necessary
IWYU is not seeing that the full declaration is necessary for
`std::unique_ptr<cmLinkLineComputer>`.
2020-04-29 11:16:44 -04:00
Vitaly Stakhovsky
36aba01223 cmGeneratorTarget::GetProperty: return cmProp 2020-04-29 10:59:39 -04:00
Vitaly Stakhovsky
e64fa5f1b6 cmSourceFile::GetProperty: return cmProp 2020-04-14 10:57:17 -04:00
Alex Turbov
8e3a65d963
Refactor: Avoid std::endl where it's not necessary (part 3)
The `std::endl` manipulator, except inserting `\n` character, also
performs `os.flush()`, which may lead to undesired effects (like
disk I/O in the middle of forming data strings). For the
`std::stringstream` it also has no meaning.

* replace multiple `operator<<` calls on a string literal w/
  the only call and the only (bigger) string literal;
* replace one character string literal used in `operator<<`
  w/ a char literal.
2020-03-24 21:33:33 +08:00
Brad King
c7c6e103d1 Merge topic 'loops-improve'
cbbca9ee2a Convert more loops to range-based for-loops
9296cd0551 GHS: Name range-based for-loop variable types explicitly
db17de2438 GHS: Use cm::erase in place of loop

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4446
2020-03-11 09:27:24 -04:00
Vitaly Stakhovsky
9296cd0551 GHS: Name range-based for-loop variable types explicitly
In general we avoid using `auto` except in cases of hard-to-name types
like iterators.
2020-03-10 14:25:53 -04:00
Vitaly Stakhovsky
a6cd48ac41 Source: use std::string overloads 2020-03-10 10:55:09 -04:00
Marc Chevrier
5444a8095d cmGlobalGenerator: modernize memrory managemenbt 2019-12-30 16:55:39 +01:00
Vitaly Stakhovsky
c34b4497f8 cmTarget: add std::string overloads 2019-12-14 09:30:28 -05:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Regina Pfeifer
d25a5a7ec9 clang-tidy: modernize-use-auto
Set the MinTypeNameLength option to an impossibly high value in order
to limit the diagnostics to iterators.  Leave new expressions and cast
expressions for later.
2019-09-10 22:21:41 +02:00
Daniel Eiband
2d888e3390 cmSourceFile: Rename mutating GetFullPath() overload
Rename mutating GetFullPath() overload to ResolveFullPath().
2019-08-29 22:51:58 +02:00
Sebastian Holtermann
aaf59120bf Source sweep: Replace cmExpandList with the shorter cmExpandedList
This replaces the code pattern
```
std::vector<std::string> args;
cmExpandList(valueStr, args, ...)
```
with
```
std::vector<std::string> args = cmExpandedList(valueStr, ...)
```
2019-08-23 17:07:49 +02:00
Sebastian Holtermann
9b334397f5 Source sweep: Use cmStrCat for string concatenation
This patch is generated by a python script that uses regular expressions to
search for string concatenation patterns of the kind

```
std::string str = <ARG0>;
str += <ARG1>;
str += <ARG2>;
...
```

and replaces them with a single `cmStrCat` call

```
std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...);
```

If any `<ARGX>` is itself a concatenated string of the kind

```
a + b + c + ...;
```

then `<ARGX>` is split into multiple arguments for the `cmStrCat` call.

If there's a sequence of literals in the `<ARGX>`, then all literals in the
sequence are concatenated and merged into a single literal argument for
the `cmStrCat` call.

Single character strings are converted to single char arguments for
the `cmStrCat` call.

`std::to_string(...)` wrappings are removed from `cmStrCat` arguments,
because it supports numeric types as well as string types.

`arg.substr(x)` arguments to `cmStrCat` are replaced with
`cm::string_view(arg).substr(x)`
2019-08-22 16:38:10 +02:00
Sebastian Holtermann
20e580be01 Source sweep: Use cmIsOn instead of cmSystemTools::IsOn
This replaces invocations of

- `cmSystemTools::IsInternallyOn` with `cmIsInternallyOn`
- `cmSystemTools::IsNOTFOUND` with `cmIsNOTFOUND`
- `cmSystemTools::IsOn` with `cmIsOn`
- `cmSystemTools::IsOff` with `cmIsOff`
2019-08-17 12:14:14 +02:00
Sebastian Holtermann
f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument 2019-08-14 16:33:20 +02:00
Sebastian Holtermann
18b0330b86 clang-tidy: Enable performance-inefficient-string-concatenation
Enables the clang-tidy test performance-inefficient-string-concatenation
and replaces all inefficient string concatenations with `cmStrCat`.

Closes: #19555
2019-08-05 17:21:00 +02:00
Brad King
71fbebd1dc IWYU: Fix handling of <memory> standard header
An old workaround for `std::allocator_traits<>::value_type` lints from
IWYU on `std::vector<>` usage breaks IWYU's handling of `<memory>`.
Convert the workaround to use the same approach we already use for a
workaround of `std::__decay_and_strip<>::::__type` lints.  Then update
the `<memory>` inclusions to follow the now-correct IWYU lints.
2019-07-10 11:48:56 -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
37acc9e229 GHS: Update custom command build events
-- Fixes issue where commands run out of order; Run commands as single script
   Do not allow build events to run in parallel
-- Use command generator to parse the commands
-- Support pre-link build events
-- Support more options: COMMENT, BYPRODUCTS, WORKING_DIRECTORY
2019-04-10 11:54:56 -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
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
Vitaly Stakhovsky
4e315e9449 cmSystemTools: More functions accept std::string params 2019-02-20 14:53:39 -05:00
Saleem Abdulrasool
fc8b90af2c Create and use cmGeneratorTarget::Names
Rather than taking a number of out parameters for the various names,
create a structure that is reused for both `GetLibraryNames` and
`GetExecutableNames`.  Replace uses according to the new interface.
2019-02-11 10:44:24 -08:00
Brad King
4b37b4f1bb Merge topic 'modernize-for-loops'
01b2d6ab74 Modernize: Use ranged for-loops when possible
15bdbec017 cmAlgorithms: Make cmRange advance/retreat safe for rvalues

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
Merge-request: !2901
2019-02-11 08:08:22 -05:00
Fred Baksik
bcd99fac60 GHS: Document usage of GHS_NO_SOURCE_GROUP_FILE
-- Also change variable name to CMAKE_GHS_NO_SOURCE_GROUP_FILE
2019-02-08 13:07:00 -05: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
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
Fred Baksik
21ab58d3f8 GHS: Update test suite
-- Allow for testing default toolset settings
   If CMake_TEST_GreenHillsMULTI_config is not defined then
   just run the GHS tests using defaults.
-- Handle paths that contain spaces
-- Update test suite to use "-non_shared" linker option
   Fixes linking issue if GHS is not shipped with shared libraries
-- Other minor cleanup
2019-01-16 10:42:08 -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
8044318431 GHS: Add support for some of the source file properties
-- INCLUDE_DIRECTORIES, COMPILE_DEFINITIONS, and COMPILE_OPTIONS
2019-01-16 10:41:45 -05:00
Fred Baksik
73092b2213 GHS: Add support for object libraries 2019-01-16 10:41:42 -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
702121c5f3 GHS: Use the correct compiler flags for CMAKE_BUILD_TYPE
-- Do not use CMAKE_C_FLAGS_RELEASE flags when CMAKE_BUILD_TYPE is empty
   if CMAKE_BUILD_TYPE was not set the generator would use Release settings
   this does not match the documented behavior of CMAKE_BUILD_TYPE

-- CMAKE_C_FLAGS_<CONFIG> not used when -kernel is present
   Fixes issue where CMAKE_C_FLAGS_<CONFIG> is ignored when -kernel option is present as a compiler option
   When the -kernel option is added to an executable it uses a different set of language flags
   This does not occur -kernel=<type> is used or if it is added as part of a link flag
   The variables CMAKE_<LANG>_GHS_KERNEL_FLAGS_<CONFIG> are removed
   NOTE: By default this only added the flag -ldebug which links in the debugger library.

-- Separate compiler options by newlines
2019-01-16 10:41:35 -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
595932c4f0 GHS: Update the link line processing
-- add missing executable linker libs from:
   CMAKE_C_STANDARD_LIBRARIES
-- add missed transitive link libraries
-- add skipped library linker options
-- The linker expects -l../relative/path/to/lib.a to be relative to the top-level project
   Because there can be multiple top-level projects convert the path to an absolute path to target
2019-01-16 10:41:27 -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
e7825386e2 GHS: Cleanup how source files are listed
-- Sort the items of the project files, previously they were unsorted
   The layout is similar to Visual Studio projects
-- Do not make a make a tree of directories and projects files
   The main project file is in the binary folder
   The sub-project files are located in the project object directory
   This is similar to the Makefile generator
-- Allow the creation of a single project file
   If the variable or target property GHS_NO_SOURCE_GROUP_FILE is set
   then all sources will be listed in the main project file
2019-01-16 10:41:15 -05:00
Fred Baksik
447b57a267 GHS: Update binary structure so that install scripts work
GHS doesn't follow the binary structure that VS or Makefiles use
Also setting binary location outputs do not work

-- Update to act like Visual Studio Generator and use its project layout
-- Fix open/close issues where open() was used instead of Open()
   Now passes the file handle to all function that require it
-- Avoid triggering MULTI reloads; use SetCopyIfDifferent mode
2019-01-16 10:41:11 -05:00
Vitaly Stakhovsky
1cf9c754db Source: Modernize for loops, add const modifiers 2018-12-31 11:50:40 -05:00
Brad King
8f076acdb0 cmLocalGenerator: Remove AddCompileDefinitions method
This method offers the same definitions as `GetTargetDefines` except
that it excludes the "export" macro on shared libraries.  Update call
sites to use `GetTargetDefines` instead.  Some of them were incorrectly
excluding the export macro.
2018-10-10 09:34:12 -04:00