Commit Graph

636 Commits

Author SHA1 Message Date
Brad King ad25a968b9 Merge branch 'ImprovedDotSupport2' into dev/strict-mode
Conflicts:
	Source/cmake.cxx
2010-12-17 10:32:01 -05:00
Brad King c128abe383 Merge branch 'AddCMAKE_CURRENT_LIST_DIR' into dev/strict-mode
Conflicts:
	Source/cmMakefile.cxx
2010-12-17 10:31:41 -05:00
Brad King 9bcaff02ff Merge branch 'cmake-guiRememberAdvancedCheckbox' into dev/strict-mode
Conflicts:
	Source/QtDialog/CMakeSetupDialog.cxx
2010-12-17 10:31:19 -05:00
Brad King bfb7288f81 Record backtrace in cmCustomCommand
This will be used to report custom command errors to the user with a
backtrace pointing at the add_custom_command or add_custom_target call.
2010-12-15 14:53:24 -05:00
Brad King 999ce0aa9c Document target_link_libraries target scope (#11058)
The target_link_libraries command requires its first argument to be a
target in the current directory.  Document this and update the error
message to be more specific.  While at it, format the error message with
a call stack.
2010-12-15 12:18:59 -05:00
Brad King 0621362668 Fix dependency tracing of INSTALL and PACKAGE (#11598)
Commit e01cce28 (Allow add_dependencies() on imported targets,
2010-11-19) started using cmMakefile::FindTargetToUse to follow
dependencies, including those of GLOBAL_TARGETs like INSTALL and
PACKAGE.  Since global targets exist in every directory, dependencies
between them must be traced within each directory too.

Teach FindTargetToUse to check the current directory before checking
globally.  For global targets this will find the local copy.  For for
normal targets this will be a no-op because they are globally unique.
2010-12-13 12:56:47 -05:00
Ben Boeckel 8e8c9e4924 Don't check at destruction for usage 2010-12-07 16:38:37 -05:00
Ben Boeckel 668e005db5 Use cmake::IssueMessage for warnings 2010-12-07 16:38:25 -05:00
Ben Boeckel 88cd4c1e92 Use 'CMake Warning' versus 'warning' for CDash 2010-12-07 14:40:21 -05:00
Ben Boeckel 3c3b98ddd3 Initialize the class before setting warn flags
Since Initialize sets variables that we don't want to warn about, don't
leak the original class' settings.
2010-12-03 12:52:36 -05:00
Ben Boeckel cf8b15a5c1 Ignore files under the CMakeFiles directory 2010-12-03 12:49:37 -05:00
Ben Boeckel fd50f06b21 Don't check for unused vars at configure time
The generate step should catch all of them.
2010-12-02 16:57:30 -05:00
Ben Boeckel c18c977ce8 When checking for variables, specify a reason
Allow reasons to begiven for checking for unused variables.
2010-11-15 10:32:15 -05:00
David Cole b0fb2ad3e1 Merge topic 'AddCMAKE_CURRENT_LIST_DIR'
b011840 Use absolute path to FindPackageHandleStandardArgs.cmake everywhere
41e4f1a Add automatic variable CMAKE_CURRENT_LIST_DIR(dir of CMAKE_CURRENT_LIST_FILE)
f9fc79c Remove trailing whitespace
2010-10-19 15:53:16 -04:00
Ben Boeckel 3f1121f722 Use a long int since Line is a long as well 2010-10-08 13:49:39 -04:00
Ben Boeckel 8dbb2090a2 Wrong boolean value for CLI warnings 2010-10-07 12:28:25 -04:00
Ben Boeckel d4ee998b61 Hard-code the --no-warn-unused-cli flag 2010-10-07 12:22:00 -04:00
Ben Boeckel 82ed104dcb Flag that the directories have been set 2010-10-05 13:45:34 -04:00
Ben Boeckel 367e5c37bb Revert "Revert "When calling CMake, set the args and the cache""
This reverts commit ab5d4e43d9.
2010-10-05 12:27:37 -04:00
Ben Boeckel ab5d4e43d9 Revert "When calling CMake, set the args and the cache"
This reverts commit 9b90040edb.
2010-10-01 16:52:16 -04:00
Ben Boeckel 9b90040edb When calling CMake, set the args and the cache 2010-10-01 13:44:55 -04:00
Bill Hoffman 3d68dd230d Fix for bug #11274, VS10 custom commands that create files in INTDIR fix. 2010-09-29 17:02:04 -04:00
Alex Neundorf 41e4f1a210 Add automatic variable CMAKE_CURRENT_LIST_DIR(dir of CMAKE_CURRENT_LIST_FILE)
Comes with a simple test and docs.

Alex
2010-09-28 22:10:47 +02:00
Alex Neundorf f9fc79cac5 Remove trailing whitespace
Alex
2010-09-28 21:44:22 +02:00
Ben Boeckel 535253f385 Initialize the warning variables earlier 2010-09-22 12:46:15 -04:00
Ben Boeckel cbb286c0b2 Fix the path detection to work for top-level 2010-09-22 12:46:15 -04:00
Ben Boeckel 62be1f78ae Initialize the usage stack earlier 2010-09-22 12:46:15 -04:00
Ben Boeckel c6e7fabc0f Factor out the checks for unused variables 2010-09-22 12:46:15 -04:00
Ben Boeckel 5e41ba8e4a When using the API, check for Add vs. Remove 2010-09-17 10:13:19 -04:00
Ben Boeckel 2c82f2b759 Exempt CMAKE(CURRENT|PARENT)_LIST_FILE from usage 2010-09-16 17:50:07 -04:00
Ben Boeckel bef3aeebab Use the API so that warnings can be tracked 2010-09-16 16:06:16 -04:00
Ben Boeckel 05cb0f4daf Check for unused variables in the dtor 2010-09-16 16:05:59 -04:00
Ben Boeckel ca90f673a0 Fix detection of unused variables when setting 2010-09-16 13:53:41 -04:00
Ben Boeckel 995cfb0e2a Don't warn if the variable wasn't defined 2010-09-16 13:52:17 -04:00
Ben Boeckel a8e97f8a08 Remove VarRemoved code since it's been superceded 2010-09-16 13:50:39 -04:00
Ben Boeckel 59463ef1a3 Rework CheckVariableForUnused usage 2010-09-16 11:50:57 -04:00
Ben Boeckel f117423336 Fix line lengths to be no more than 78 2010-09-16 11:49:58 -04:00
Ben Boeckel e49a935c20 Improve unused warning logic
Only warn when changing the definition of an initialized variable.
2010-09-15 11:41:27 -04:00
Ben Boeckel 02a114dfe8 Add method to allow variables to be marked as used 2010-09-15 11:34:35 -04:00
Ben Boeckel ae3eff35b4 Fix the path used for ignoring system warnings 2010-09-14 17:14:25 -04:00
Ben Boeckel 056b44113f Fix missing case for usage of a variable 2010-09-14 17:10:22 -04:00
Ben Boeckel 980e048a7d Factor out checks for unused variables 2010-09-14 17:10:04 -04:00
Brad King b06fb16684 No CMAKE_CONFIGURATION_TYPES in single-config generators (#10202)
Factor out reading of CMAKE_CONFIGURATION_TYPES and CMAKE_BUILD_TYPE
into cmMakefile::GetConfigurations.  Read the former only in
multi-config generators.
2010-09-08 14:54:49 -04:00
Ben Boeckel 3801463c9f Use built-ins for readability and maintainability 2010-09-08 12:03:42 -04:00
Ben Boeckel 8b520158c3 Push the initialize and unused states when copying 2010-09-07 15:12:15 -04:00
Ben Boeckel 300fc15779 Fix detection of system files
Instead of looking to see if the file is under CMAKE_ROOT, check to see
if it is instead under the source or binary directories in use.
2010-09-02 11:33:34 -04:00
Ben Boeckel d784e6af4d Run the unused variables check on the final pass 2010-09-02 11:29:05 -04:00
Ben Boeckel 74997000c8 Add a flag to warn about system files 2010-09-01 13:09:08 -04:00
Ben Boeckel fff9f6d6f7 Rename flags again and use variablewatch for cli 2010-09-01 13:09:08 -04:00
Ben Boeckel 636e6c4ef7 Default to marking things as used
If we don't then:

    cmake --warn-unused --warn-unused-all

acts differently than:

    cmake --warn-unused-all --warn-unused
2010-09-01 13:08:15 -04:00
Ben Boeckel 4ff03402fc Rename find-unused to warn-unused 2010-09-01 13:08:14 -04:00
Ben Boeckel e141bc950a Detect unused variables 2010-09-01 13:08:14 -04:00
Ben Boeckel f332e14ff2 Complete strict-mode checks for uninitialized vars 2010-09-01 13:08:14 -04:00
Bill Hoffman 48b5b85593 Add a warning when variables are used uninitialized. 2010-09-01 13:08:13 -04:00
Brad King 3ebb41d58a Merge branch 'version' 2010-05-17 13:34:29 -04:00
Brad King 6e1b510319 Remove unused cmData and cmMakefile::DataMap
These were implementation details of the unused methods

  cmMakefile::RegisterData
  cmMakefile::LookupData

We simply remove the methods, members, and class cmData.
2010-04-26 14:22:51 -04:00
Brad King 5bfffd6f29 New version scheme to support branchy workflow
Prepare to switch to the workflow described by "git help workflows".  In
this workflow, the "master" branch is always used to integrate topics
ready for release.  Brand new work merges into a "next" branch instead.
We need a new versioning scheme to work this way because the version on
"master" must always increase.

We no longer use an even/odd minor number to distinguish releases from
development versions.  Since we still support cvs checkout of our source
tree we cannot depend on "git describe" to compute a version number
based on the history graph.  We can use the CCYYMMDD nightly date stamp
to get a monotonically increasing version component.

The new version format is "major.minor.patch.(tweak|date)".  Releases
use a tweak level in the half-open range [0,20000000), which is smaller
than any current or future date.  For tweak=0 we do not show the tweak
component, leaving the format "major.minor.patch" for most releases.
Development versions use date=CCYYMMDD for the tweak level.  The
major.minor.patch part of development versions on "master" always
matches the most recent release.

For example, a first-parent traversal of "master" might see

        v2.8.1      2.8.1.20100422    v2.8.2
           |              |              |
  ----o----o----o----o----o----o----o----o----

Since the date appears in the tweak component, the next release can
increment the patch level (or any more significant component) to be
greater than any version leading to it.  Topic branches not ready for
release are published only on "next" so we know that all versions on
master lead between two releases.
2010-04-23 09:44:23 -04:00
Brad King 59f6f383e9 Warn on set(PARENT_SCOPE) at top scope
Previously we silently ignored such calls and set nothing.  The commit
"Initialize directory scope with closure of parent" inroduced a bad test
for the top scope.  This commit fixes the test to avoid dereferencing a
null pointer, and adds a warning when the case is encountered.
2009-11-02 11:56:17 -05:00
Brad King 9a77f65da7 Remove CMake Policy CMP0015 until it is revised
We revert commit "Create CMake Policy CMP0015 to fix set(CACHE)" because
the NEW behavior of the policy breaks a valid use case:

  # CMakeLists.txt
  option(BUILD_SHARED_LIBS "..." ON)
  add_library(mylib ...)
  set(BUILD_SHARED_LIBS OFF) # we want only mylib to be shared
  add_subdirectory(ThirdParty)

  # ThirdParty/CMakeLists.txt
  option(BUILD_SHARED_LIBS "..." ON)
  # uh, oh, with NEW behavior this dir uses shared libs!!!

We'll re-introduce the policy later with a different change in behavior
to resolve the motivating case, which was more subtle but less common.

See issue #9008.
2009-10-08 14:56:15 -04:00
Brad King 1b5a986a42 Do not collapse path of NOTFOUND values
In cmMakefile::AddCacheDefinition we collapse paths specified in PATH or
FILEPATH cache entries originally specified on the command line with
UNINITALIZED type.  This commit fixes the logic to avoid collapsing
<var>-NOTFOUND and other false values.  The change allows other CMake
code to force a NOTFOUND value on an entry with UNINITALIZED type.
2009-10-07 14:37:19 -04:00
Brad King 78f0811628 Create explicit cmTarget::FinishConfigure step
This method is called during ConfigureFinalPass on every target.  It
gives each target a chance to do some final processing after it is known
that no more commands will affect it.  Currently we just call the old
AnalyzeLibDependencies that used to be called directly.
2009-10-05 09:06:29 -04:00
Brad King c513962701 Create INTERPROCEDURAL_OPTIMIZATION build feature
This commit creates target and directory properties to enable the Intel
interprocedural optimization support on Linux.  Enabling it adds the
compiler option '-ipo' and uses 'xiar' to create archives.

See issue #9615.
2009-10-02 13:52:13 -04:00
Brad King 1e48243591 Introduce "build feature" lookup framework
This creates cmTarget::GetFeature and cmMakefile::GetFeature methods to
query "build feature" properties.  These methods handle local-to-global
scope and per-configuration property lookup.  Specific build features
will be defined later.
2009-10-02 13:52:01 -04:00
Brad King 56d1a1780d Create cmMakefile::PlatformIs64Bit helper method
This method centralizes tests for whether CMAKE_SIZEOF_VOID_P is 8.
2009-09-30 13:45:14 -04:00
Brad King 96afb12087 Convert CMake to OSI-approved BSD License
This converts the CMake license to a pure 3-clause OSI-approved BSD
License.  We drop the previous license clause requiring modified
versions to be plainly marked.  We also update the CMake copyright to
cover the full development time range.
2009-09-28 11:43:28 -04:00
Brad King ef8434284f Remove old check for duplicate subdirectories
In cmMakefile::AddSubDirectory we were checking for addition of the same
source directory multiple times.  However, the check code was incorrect
because it compared pointers instetad of pointed-to strings.  Since the
check was written, a better check was added right after it to enforce
unique binary directories (in which case duplicate sources are fine).
This commit simply removes the old-style check code.
2009-09-17 08:25:33 -04:00
Brad King 24861459b5 Initialize directory scope with closure of parent
The commit "Improve dynamic variable scope implementation" optimized
function scopes using an efficient parent scope pointer.  However, the
parent scope used to initialize a new directory might not exist later
(like add_subdirectory called inside a function of the parent scope).
This caused CMake to crash when following the dangling pointer to the
original parent scope.

We fix the problem in this commit by always computing the closure of the
parent scope at directory initialization time so that no parent scope
pointer is needed.  See issue #9538.
2009-09-16 09:51:47 -04:00
Brad King ee2b446c95 Create CMake Policy CMP0015 to fix set(CACHE)
The set(CACHE) and option() commands should always expose the cache
value.  Previously we failed to expose the value when it was already set
if a local variable definition hid it.  When set to NEW, this policy
tells the commands to always remove the local variable definition to
expose the cache value.  See issue #9008.
2009-09-10 16:59:45 -04:00
Brad King afbe088309 Remove barely-used cmMakefile::AddCacheDefinition
The boolean overload of this method was used only to implement option().
We re-implement option() in terms of the main method and removes the
now-unused signature.  This removes some duplicate code that had already
fallen behind on changes (it was not removing the local definition
instead of setting it).
2009-09-10 16:59:36 -04:00
Brad King 0bc050677f Record backtrace for every add_test command
We teach cmTest to hold a backtrace for the add_test command that
created it.  This will be used later to report context for errors at
generate time.
2009-08-11 09:07:28 -04:00
Brad King 80c947b397 No /fast targets in try_compile project mode
The try_compile command builds the cmTryCompileExec executable using the
cmTryCompileExec/fast target with Makefile generators in order to save
time since dependencies are not needed.  However, in project mode the
command builds an entire source tree that may have dependencies.
Therefore we can use the /fast target approach only in one-source mode.
2009-08-04 14:37:46 -04:00
Brad King 71c0e1417b ENH: Keep only FinalPass commands in memory
In cmMakefile we save all invoked commands so that FinalPass can be
called on them later.  Most commands have no final pass, so we should
keep only the few that do.
2009-07-24 13:31:34 -04:00
Brad King fd10589995 ENH: Improve dynamic variable scope implementation
Previously each new variable scope (subdirectory or function call) in
the CMake language created a complete copy of the key->value definition
map.  This avoids the copy using transitive lookups up the scope stack.
Results of queries answered by parents are stored locally to maintain
locality of reference.

The class cmDefinitions replaces cmMakefile::DefinitionsMap, and is
aware of its enclosing scope.  Each scope stores only the definitions
set (or unset!) inside it relative to the enclosing scope.
2009-07-22 14:22:45 -04:00
Bill Hoffman 300514fd25 ENH: make sure GUIDs for filters are cached 2009-07-17 10:05:54 -04:00
Bill Hoffman 28b1912aa3 ENH: add group support and fix borland error 2009-07-11 00:05:20 -04:00
Bill Hoffman 7491f52992 ENH: first pass at VS 10, can bootstrap CMake, but many tests still fail 2009-06-25 16:41:57 -04:00
Brad King f74b876a58 ENH: Clarify COMPILE_DEFINITIONS separator in docs
The COMPILE_DEFINITIONS properties are semicolon-separated lists.
Make this clear in the documentation.  See issue #9199.
2009-06-24 09:36:29 -04:00
Brad King c790b1fabb ENH: Create CMP0013 to disallow duplicate dirs
In CMake 2.6.3 and below we silently accepted duplicate build
directories whose build files would then conflict.  At first this was
considured purely a bug that confused beginners but would not be used in
a real project.  In CMake 2.6.4 we explicitly made it an error.

However, some real projects took advantage of this as a "feature" and
got lucky that the subtle build errors it can cause did not occur.
Therefore we need a policy to deal with the case more gracefully.
See issue #9173.
2009-06-17 13:40:09 -04:00
Brad King 708d1cf1ee ENH: Support more preprocessor values in VS6
Previously we rejected all preprocessor definition values containing
spaces for the VS6 IDE generator.  In fact VS6 does support spaces but
not in combination with '"', '$', or ';', and only if we use the sytnax
'-DNAME="value with spaces"' instead of '-D"NAME=value with spaces"'.
Now we support all definition values that do not have one of these
invalid pairs.  See issue #8779.
2009-04-24 11:18:06 -04:00
Brad King 4085454658 ENH: Support preprocessor def values in VS6
The add_definitions() command and COMPILE_DEFINITIONS dir/tgt/src
properties support preprocessor definitions with values.  Previously
values were not supported in the VS6 generator even though the native
tool supports them.  It is only values with spaces that VS6 does not
support.  This enables support and instead complains only for values
with spaces.  See issue #8779.
2009-03-23 14:48:09 -04:00
Brad King 66d69f864a ENH: Refactor generation of CTestTestfile content
This moves code which generates ADD_TEST and SET_TESTS_PROPERTIES calls
into CTestTestfile.cmake files out of cmLocalGenerator and into a
cmTestGenerator class.  This will allow more advanced generation without
cluttering cmLocalGenerator.  The cmTestGenerator class derives from
cmScriptGenerator to get support for per-configuration script
generation (not yet enabled).
2009-03-16 10:40:46 -04:00
Brad King 1d3308156e ENH: Enforce unique binary directories
The second argument of add_subdirectory must name a unique binary
directory or the build files will clobber each other.  This enforces
uniqueness with an error message.
2009-02-27 11:23:14 -05:00
Brad King b604b98c56 ENH: Define RULE_LAUNCH_* properties
This defines global, directory, and target properties
RULE_LAUNCH_COMPILE, RULE_LAUNCH_LINK, and RULE_LAUNCH_CUSTOM.  Their
values specify 'launcher' command lines which are prefixed to compile,
link, and custom build rules by Makefile generators.
2009-02-10 08:51:15 -05:00
Brad King 7d6a5e097f ENH: More robust property lookup
This teaches cmMakefile::GetProperty and cmake::GetProperty methods to
return NULL when the property name is NULL, making them more robust and
consistent with the behavior of cmTarget::GetProperty.
2009-02-02 13:27:30 -05:00
Brad King c332e0bf3c ENH: Isolate policy changes in included scripts
Isolation of policy changes inside scripts is important for protecting
the including context.  This teaches include() and find_package() to
imply a cmake_policy(PUSH) and cmake_policy(POP) around the scripts they
load, with a NO_POLICY_SCOPE option to disable the behavior.  This also
creates CMake Policy CMP0011 to provide compatibility.  See issue #8192.
2009-01-22 13:18:40 -05:00
Brad King 3028ca756c ENH: Better policies for functions and macros
This teaches functions and macros to use policies recorded at creation
time when they are invoked.  It restores the policies as a weak policy
stack entry so that any policies set by a function escape to its caller
as before.
2009-01-22 13:16:47 -05:00
Brad King 26bf8b2cda ENH: Create notion of a 'weak' policy stack entry
A 'weak' poilcy stack entry responds normally to queries.  However,
setting a policy in a weak entry will recursively set the policy in the
next entry too.  This also gives the internal interface to create a weak
entry the option to provide an initial PolicyMap for it.
2009-01-22 13:16:27 -05:00
Brad King dfc181a1dc ENH: Create policy scope barriers
This creates a barrier mechanism to prevent user code from using
cmake_policy(POP) to pop a scope it didn't push with cmake_policy(PUSH).
2009-01-22 10:57:16 -05:00
Brad King a01eb6b27b ENH: Create automatic policy push/pop helper
This creates cmMakefile::PolicyPushPop to push and pop policy scope
automatically.  It also enforces balanced push/pop pairs inside the
scope it handles.
2009-01-22 10:56:50 -05:00
Brad King 8997f4760a ENH: Refactor policy stack representation
This defines PolicyMap as a public member of cmPolicies.  Its previous
role as a policy stack entry is now called PolicyStackEntry and
represented as a class to which more information can be added later.
2009-01-22 10:56:39 -05:00
Brad King 1dcc5b4558 ENH: Better handling of mismatched blocks
If a logical block terminates with mismatching arguments we previously
failed to remove the function blocker but replayed the commands anyway,
which led to cases in which we failed to report the mismatch (return
shortly after the ending command).  The recent refactoring of function
blocker deletion changed this behavior to produce an error on the ending
line by not blocking the command.  Furthermore, the function blocker
would stay in place and complain at the end of every equal-level block
of the same type.

This teaches CMake to treat the begin/end commands (if/endif, etc.) as
correct and just warns when the arguments mismatch.  The change allows
cases in which CMake 2.6.2 silently ignored a mismatch to run as before
but with a warning.
2009-01-21 09:49:00 -05:00
Brad King bca1026250 ENH: Better error message for unclosed blocks
This centralizes construction of the error message for an unclosed
logical block (if, foreach, etc.).  We record the line at which each
block is opened so it can be reported in the error message.
2009-01-21 09:48:20 -05:00
Brad King b8f5a934ec ENH: Refactor logical block enforcement
This uses a stack of 'barriers' to efficiently divide function blockers
into groups corresponding to each input file.  It simplifies detection
of missing block close commands and factors it out of ReadListFile.
2009-01-21 09:48:00 -05:00
Brad King 2c81e5fb5c ENH: Refactor function blocker deletion
When a function blocker decides to remove itself we previously removed
it at every return point from the C++ scope in which its removal is
needed.  This teaches function blockers to transfer ownership of
themselves from cmMakefile to an automatic variable for deletion on
return.  Since this removes blockers before they replay their commands,
we no longer need to avoid running blockers on their own commands.
2009-01-20 14:36:18 -05:00
Brad King a541cac325 ENH: Improve response to bad if or elseif
Previously bad arguments to an if() or elseif() would cause some
subsequent statements in the corresponding block to execute.  This
teaches CMake to stop processing commands with a fatal error.  It also
provides context to bad elseif() error messages.
2009-01-20 14:35:22 -05:00
Bill Hoffman e4048118de BUG: fix crash with empty properties 2009-01-18 12:05:45 -05:00
Brad King d602a3db85 BUG: Enforce matching policy PUSH/POP in all files
The documentation of cmake_policy PUSH and POP states that they must
always match.  Previously we enforced this only for the top scope of
each CMakeLists.txt file.  This enforces the requirement for all files.
2009-01-15 14:37:14 -05:00
Brad King 35e391c93b ENH: Provide variable CMAKE_VERSION
This creates the variable CMAKE_VERSION containing the full version of
cmake in "major.minor.patch" format.  It is particularly useful with the
component-wise version comparison provided by the if() command.
2009-01-15 08:57:44 -05:00
Brad King ed3bb743f4 ENH: Improve test property speed with a map
Previously we stored a vector of tests to preserve their order.
Property set/get operations would do a linear search for matching tests.
This uses a map to efficiently look up tests while keeping the original
order with a vector for test file generation.
2009-01-05 15:00:57 -05:00
Bill Hoffman 0c24570ee4 BUG: fix issue with -D and cache force 2008-11-21 16:32:39 -05:00