summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
Commit message (Collapse)AuthorAgeFilesLines
* Simplify boolean expressionsDaniel Pfeifer2016-06-021-13/+4
| | | | | | 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.
* cmMakefile: Optimize AddSystemIncludeDirectories for empty setBrad King2016-05-241-0/+4
| | | | | Do not bother looping over all targets if we have no system include directories to add anyway.
* Revise C++ coding style using clang-formatKitware Robot2016-05-161-1937/+1289
| | | | | | | | | | | | | 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.
* Remove `//------...` horizontal separator commentsBrad King2016-05-091-69/+0
| | | | | | | | | | | | | | | | | | | | | | | | Modern editors provide plenty of ways to visually separate functions. Drop the explicit comments that previously served this purpose. Use the following command to automate the change: $ git ls-files -z -- \ "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" | egrep -z -v "^Source/cmCommandArgumentLexer\." | egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" | egrep -z -v "^Source/cmDependsJavaLexer\." | egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" | egrep -z -v "^Source/cmExprLexer\." | egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" | egrep -z -v "^Source/cmFortranLexer\." | egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" | egrep -z -v "^Source/cmListFileLexer\." | egrep -z -v "^Source/cm_sha2" | egrep -z -v "^Source/(kwsys|CursesDialog/form)/" | egrep -z -v "^Utilities/(KW|cm).*/" | xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}' This avoids modifying third-party sources and generated sources.
* Isolate formatted streaming blocks with clang-format off/onBrad King2016-05-061-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Format include directive blocks and ordering with clang-formatBrad King2016-04-291-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Source: Stabilize include orderBrad King2016-04-291-0/+1
| | | | | 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.
* cmMakefile::AddCacheDefinition: avoid conversions between char* and stringRolf Eike Beer2016-04-201-10/+11
| | | | | | | 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.
* cmListFileBacktrace: Refactor storage to provide efficient value semanticsBrad King2016-04-181-95/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Add call stack to unused/uninitialized variable warningsBrad King2016-04-151-17/+3
| | | | | | | | In commit v2.8.4~32^2~14 (Use cmake::IssueMessage for warnings, 2010-12-07) these warnings became formatted. It is more informative to give the full call stack with such warnings. Also it is easier to implement warnings with a full call stack because we do not have to construct a custom backtrace with only the top.
* cmMakefile: Move cmMakefileCall to .cxx fileBrad King2016-04-151-13/+20
|
* cmState: Rename CallStack snapshots to IncludeFileBrad King2016-04-121-1/+1
|
* Merge topic 'fix-target-alias-in-subdir'Brad King2016-04-051-14/+2
|\ | | | | | | | | | | 0e44f489 Rename local target lookup methods to clarify purpose bc30f8b5 Fix lookup of an ALIAS target outside aliased target's directory (#16044)
| * Rename local target lookup methods to clarify purposeBrad King2016-04-011-2/+2
| | | | | | | | | | | | | | | | | | | | Rename methods: * `cmMakefile::Find{ => LocalNonAlias}Target` * `cmLocalGenerator::Find{ => LocalNonAlias}GeneratorTarget` These names clarify that they are for directory-local target names and do not consider alias targets.
| * Fix lookup of an ALIAS target outside aliased target's directory (#16044)Brad King2016-04-011-14/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactoring in commit v3.5.0-rc1~272^2~11 (cmTarget: Implement ALIAS in terms of name mapping, 2015-10-25) accidentally introduced logic that assumes ALIAS targets always reference targets in their own directory. Fix this and add a test case. The configure-step fix is that `cmMakefile::FindTarget` should not consider aliases. The purpose of this method is just to look up targets local to a directory. Since ALIAS and normal targets share a namespace we know a locally defined target will never collide with an ALIAS target anyway. The method has 3 call sites, and this change is safe for all of them: * `cmInstallCommand::HandleTargetsMode`: Rejects aliases before the call. * `cmFLTKWrapUICommand::FinalPass`: Should never have considered aliases. * `cmMakefile::FindTargetToUse`: Falls back to a global lookup anyway. The generate-step fix is that `cmLocalGenerator::FindGeneratorTarget` should not consider aliases. This method is the generate-step equivalent to the above. The method has 2 call sites, and this change is safe for both of them: * `cmInstallTargetGenerator::Compute`: Never uses an alias target name. * `cmLocalGenerator::FindGeneratorTargetToUse`: Falls back to global lookup. Reported-by: Matteo Settenvini <matteo@member.fsf.org>
* | Merge topic 'fix-variable_watch-reallocation'Brad King2016-03-241-8/+15
|\ \ | |/ | | | | | | c6104028 Avoid occasional use-after-free when a variable watch is executed
| * Avoid occasional use-after-free when a variable watch is executedYves Frederix2016-03-231-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Re-lookup a variable value when an associated VariableWatch is executed in cmMakefile::GetDefinition. This fixes a problem with 'def' sometimes becoming invalid due to memory reallocation inside an std::vector. In this case, the problem was that if the call to VariableAccessed actually executed a callback function, the internal state of the makefile has changed due to the associated function scope being pushed. This in turn implies that a new cmDefinitions instance was pushed in cmMakefile::VarTree. As cmLinkedTree is based on an std::vector, this push can have triggered reallocation of its internal memory buffer. However, as the value of 'def', which was computed on method entry, actually points to a property of one of the cmDefinitions instances in cmMakefile::VarTree, reallocation can invalidate the value of 'def' so that it cannot simply be returned at the end of the function. The solution implemented here is to simply lookup the value of 'def' again.
* | Avoid depending on CMAKE_ROOT cache entry internally (#16015)Brad King2016-03-161-12/+8
| | | | | | | | | | | | Use cmSystemTools::GetCMakeRoot() which always knows the location of our resources. Do not depend on CMAKE_ROOT because the user could unset it from the cache.
* | Drop Visual Studio 6 generatorBrad King2016-03-091-28/+0
|/ | | | | | This generator has been deprecated since CMake 3.3. Remove it. Update documentation, modules, and tests to drop content specific to this generator.
* Fix internal target lookup performance regressionBrad King2016-02-081-0/+2
| | | | | | | | | | | Refactoring in commit v3.5.0-rc1~272^2~13 (cmGlobalGenerator: Remove direct storage of targets, 2015-10-25) replaced an efficient data structure mapping from target name to cmTarget instance with a linear search. Lookups through cmGlobalGenerator::FindTarget are done a lot. Restore the efficient mapping structure with a name indicating its purpose. Reported-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
* add_custom_command: Clarify error when TARGET is out of scope (#15681)Brad King2016-01-281-1/+18
| | | | | | | | The add_custom_command(TARGET) signature only works for targets defined in the current directory. Clarify this in the error message when the target exists but was defined elsewhere. Inspired-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
* Optimize cmMakefile::ExpandVariablesInStringNew.Milian Wolff2016-01-201-10/+9
| | | | | | | | | | | | We can remove the temporary allocations required for the default-constructed t_lookup passed into the openstack by refactoring the code slightly. Furthermore, we use a vector instead of a stack, since the latter is based on a deque which is not required for a heap / lifo structure. This patch removes ~215k allocations. This hotspot was found with heaptrack.
* Make message suppression more consistent.Michael Scott2015-11-301-3/+5
| | | | | | | | | | | | | | | | Make the message suppression more consistent, by adding a check for the message related CMake variables in cmake::IssueMessage, which allows callers of IssueMessage other than the message command to behave as expected. Also added a check for CMAKE_SUPPRESS_DEVELOPER_WARNINGS in the message command to mirror the deprecated message type behaviour. Added a 'force' flag to the cmake::IssueMessage method, to make the message suppression consistent, when setting the message related CMake variables directly in a CMake file. Expand message command tests to cover the AUTHOR_WARNING message type as well.
* Merge branch 'reduce-cmState-accumulation' into ↵Brad King2015-11-251-16/+12
|\ | | | | | | reduce-cmState-accumulation-for-master
| * cmState: Enforce policy scope balancing around variable scopesBrad King2015-11-251-6/+1
| | | | | | | | | | | | | | | | Everywhere we use cmMakefile::ScopePushPop to manage variable scopes also expects policy scopes to be balanced. There is no place that we use cmMakefile::PolicyPushPop without also using ScopePushPop. Relieve PolicyPushPop of responsibility for policy scope balance checks by moving it to ScopePushPop.
| * cmMakefile: Remove unused PolicyPushPop interfacesBrad King2015-11-251-5/+3
| | | | | | | | | | | | The PolicyPushPop constructor arguments and Quiet method were used to pass non-default arguments to PushPolicy and PopSnapshot, but no clients use them anymore.
| * cmMakefile: Clarify purpose of method that pops a scope snapshotBrad King2015-11-251-7/+10
| | | | | | | | | | | | | | The `PopPolicyBarrier` method is actually responsible for closing any scope opened by creating a snapshot. Rename it to `PopSnapshot` and add a comment explaining the purpose of the poilcy-scope-specific part of the method.
* | Merge topic 'minor-cleanups'Brad King2015-10-281-2/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 13a37f5f cmMakefile: Fix typo in comment 958508bb cmMakefile: Fix style 91a829c1 Makefiles: Remove unused variable e0213882 cmTarget: Remove obsolete member 0554c2c9 cmTarget: Fix style b22e5d0a Remove some obsolete declarations ce43ed2c Use LocalGenerator when possible d90c9738 Makefiles: Remove some unneeded casts 331023ae Export: Remove unused variable a03f3d0e cmFunctionBlocker: Constify method d50c4220 Xcode: Fix typo in comment 803f1901 Xcode: Remove trailing semicolon
| * | cmMakefile: Fix typo in commentStephen Kelly2015-10-271-1/+1
| | |
| * | cmMakefile: Fix styleStephen Kelly2015-10-271-1/+1
| | |
* | | cmMakefile: Add imported target accessorStephen Kelly2015-10-271-0/+12
| | |
* | | cmTarget: Implement ALIAS in terms of name mappingStephen Kelly2015-10-271-5/+8
| | | | | | | | | | | | Remove mapping to cmTarget.
* | | cmGlobalGenerator: Remove direct storage of targetsStephen Kelly2015-10-271-6/+1
| | | | | | | | | | | | Find the target by looping when needed.
* | | cmake: Store hardcoded lists of sources and headersStephen Kelly2015-10-271-25/+0
| | | | | | | | | | | | Don't duplicate this in each cmMakefile.
* | | cmTarget: Make compatbility API explicit.Stephen Kelly2015-10-271-5/+16
|/ /
* | Merge topic 'xcode-watch-and-tvos'Brad King2015-10-261-4/+17
|\ \ | | | | | | | | | | | | a91eebeb Xcode: Recognise Watch and TV OS as embedded platforms
| * | Xcode: Recognise Watch and TV OS as embedded platformsGregor Jasny2015-10-231-4/+17
| | |
* | | Merge topic 'fix-CMP0054-elseif-warning'Brad King2015-10-211-2/+3
|\ \ \ | |/ / |/| / | |/ | | d6a03b47 cmIfCommand: Issue CMP0054 warning with appropriate context. (#15802)
| * cmIfCommand: Issue CMP0054 warning with appropriate context. (#15802)Stephen Kelly2015-10-201-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit v3.4.0-rc1~494^2~4 (cmMakefile: Add API for elseif to create backtrace., 2015-05-29) removed the use of cmMakefileCall to push/pop execution context in favor of a new way to create backtraces. However, a call to cmMakefile::GetExecutionContext is still invoked to issue a contextual CMP0054 warning through cmConditionEvaluator. As the elseif is not part of the call stack, this resulted in trying to access an empty vector. Avoid the attempt at getting execution context when evaluating elseif by constructing a context and backtrace on behalf of the cmConditionEvaluator in all cases.
* | cmState: Move GetTargetTypeName from cmTarget.Stephen Kelly2015-10-141-1/+1
| |
* | cmState: Move TargetType enum from cmTarget.Stephen Kelly2015-10-141-29/+29
| | | | | | | | | | | | | | Mostly automated: values=( "EXECUTABLE" "STATIC_LIBRARY" "SHARED_LIBRARY" "MODULE_LIBRARY" "OBJECT_LIBRARY" "UTILITY" "GLOBAL_TARGET" "INTERFACE_LIBRARY" "UNKNOWN_LIBRARY" "TargetType") for i in "${values[@]}"; do git grep -l cmTarget::$i | xargs sed -i "s|cmTarget::$i|cmState::$i|g"; done
* | cmTarget: Move link type enum out.Stephen Kelly2015-10-141-3/+3
| | | | | | | | Remove a reason for generate time code to depend on the cmTarget header/type.
* | Merge topic 'genex-generator-objects'Brad King2015-10-141-17/+23
|\ \ | | | | | | | | | | | | | | | | | | | | | 2293d43d cmLocalGenerator: Store cmGeneratorTargets. 488723f5 cmMakefile: Store container of cmExportBuildFileGenerators. 15834405 cmGeneratorExpression: Port interface to cmGeneratorTarget. 11165525 cmGeneratorExpression: Port to cmLocalGenerator.
| * | cmLocalGenerator: Store cmGeneratorTargets.Stephen Kelly2015-10-141-17/+0
| | | | | | | | | | | | Relieve cmMakefile of this responsibility.
| * | cmMakefile: Store container of cmExportBuildFileGenerators.Stephen Kelly2015-10-141-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | Set a cmLocalGenerator on each instance at compute time. That will soon be needed to access cmGeneratorTarget instances. If a cmExportBuildFileGenerator is processed early during configure time as a result of CMP0024 it must be removed from the list to process later at generate time.
* | | Subdirs: Initialize from parent before configuring.Stephen Kelly2015-10-131-0/+1
| | | | | | | | | | | | | | | | | | | | | Add new API for the subdirs command to cmState. This fixes a regression introduced in commit f716460e (cmMakefile: Move invokation to initialize snapshot., 2015-10-06).
* | | cmState: Initialize properties immediately.Stephen Kelly2015-10-131-2/+0
| | | | | | | | | | | | Don't leave this as cmMakefile responsibility.
* | | cmState: Initialize default definitions immediately.Stephen Kelly2015-10-131-55/+0
| | | | | | | | | | | | Don't leave this as cmMakefile responsibility.
* | | cmState: Initialize current directories immediately.Stephen Kelly2015-10-131-26/+2
| | | | | | | | | | | | Don't leave this as cmMakefile responsibility.
* | | cmState: Initialize top level source directories immediately.Stephen Kelly2015-10-131-4/+0
| | | | | | | | | | | | Don't leave this as cmMakefile responsibility.