summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
Commit message (Collapse)AuthorAgeFilesLines
* fix a batch of include-what-you-use violationsDaniel Pfeifer2016-08-231-10/+16
|
* CMake: don't use else after returnDaniel Pfeifer2016-08-181-85/+82
|
* Use better KWSys SystemTools::GetEnv and HasEnv signaturesDāvis Mosāns2016-07-181-1/+4
|
* Avoid using KWSys auto_ptr by adopting it ourselvesBrad King2016-06-291-10/+9
| | | | | | | | | | | | Replace use of cmsys::auto_ptr with a CM_AUTO_PTR macro that maps to our own implementation adopted from the KWSys auto_ptr implementation. Later we may be able to map CM_AUTO_PTR to std::auto_ptr on compilers that do not warn about it. Automate the client site conversions: git grep -l auto_ptr -- Source/ | grep -v Source/kwsys/ | xargs sed -i \ 's|cmsys::auto_ptr|CM_AUTO_PTR|;s|cmsys/auto_ptr.hxx|cm_auto_ptr.hxx|'
* use CM_NULLPTRDaniel Pfeifer2016-06-281-29/+30
|
* cmake: Add an option to control what files needs to be tracedAlex Turbov2016-06-171-1/+23
| | | | | | | | | | Even in relatively small projects using `--trace` (and `--trace-expand`) may produce a lot of output. When developing a custom module usually one is interested in output of only a few particular modules. Add a `--trace-source=<file>` option to enable tracing only a subset of source files. The final output would be only from requested modules, ignoring anything else not matched to given filename(s).
* Merge topic 'cleanup-streams'Brad King2016-06-161-1/+1
|\ | | | | | | | | | | | | | | ed5fa48d cmXMLWriter: use ifstream from KWSys 24ab29b8 Prefer istringstream and ostringstream over stringstream. ab8b77dd Remove redundant arguments from fstream constructors eb79fa72 Access std::ios_base with std::ios
| * Access std::ios_base with std::iosDaniel Pfeifer2016-06-141-1/+1
| | | | | | | | Just because it is shorter.
* | Merge topic 'clean-up-cmMakefile-IssueMessage'Brad King2016-06-161-3/+4
|\ \ | | | | | | | | | | | | | | | 5bbcf758 cmIfCommand: Don't rely on NestedError logic to issue messages 262ce91e cmMakefile: Extract invoke result variables
| * | cmMakefile: Extract invoke result variablesStephen Kelly2016-06-131-3/+4
| |/ | | | | | | Make it more clear what is happening here.
* | Parser: Out-of-line conditional code to cmMakefileStephen Kelly2016-06-131-4/+75
|/ | | | Simplify parser API.
* Merge topic 'fix-cmake-ISP-violation'Brad King2016-06-131-3/+3
|\ | | | | | | | | | | 23f87e81 cmake: Remove force from IssueMessage API 54c65d5f cmake: Extract DisplayMessage API.
| * cmake: Remove force from IssueMessage APIStephen Kelly2016-06-121-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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."
* | Merge topic 'avoid-cmMakefile-IssueMessage-after-configure'Brad King2016-06-131-14/+38
|\ \ | | | | | | | | | | | | | | | | | | | | | ea5324cd cmMakefile: Port messages for compile features to cmake df8c3130 cmGlobalGenerator: Don't use cmMakefile::IssueMessage after configure 946d1e50 cmMakefile: Avoid IssueMessage after configure is finished 096c7754 cmLocalGenerator: Store Backtrace for the directory
| * | cmMakefile: Port messages for compile features to cmakeStephen Kelly2016-06-121-9/+29
| | |
| * | cmMakefile: Avoid IssueMessage after configure is finishedStephen Kelly2016-06-121-5/+9
| |/
* | Merge topic 'find-lib32'Brad King2016-06-131-0/+8
|\ \ | | | | | | | | | | | | 896ad251 Teach find_library and find_package to search lib32 paths (#11260)
| * | Teach find_library and find_package to search lib32 paths (#11260)Daniel Scharrer2016-06-101-0/+8
| |/ | | | | | | | | | | | | 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``.
* | Add missing braces around statements.Daniel Pfeifer2016-06-101-1/+2
|/ | | | | Apply fixits of clang-tidy's readability-braces-around-statements checker.
* Remove c_str() calls from stream arguments.Daniel Pfeifer2016-06-061-1/+1
| | | | | | Mostly automated: git grep -l '.c_str() <<' | xargs sed -i 's|\.c_str() <<| <<|g'
* 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
| | |