MantisBT - CMake
View Issue Details
0014195CMakeDocumentationpublic2013-06-04 06:162016-06-10 14:31
Yichao Yu 
Kitware Robot 
normalfeaturealways
closedmoved 
LinuxArch Linux
CMake 2.8.11 
 
0014195: Document behavior of variable_watch on some built-in variables.
1, They are not mentioned anywhere, although it is really easy to tryout for a specific version, it would be really nice to document the behaviors as well as adding tests for them so that people can rely on them.

2, The specific variable I am interested in is CMAKE_PARENT_LIST_FILE (as well as CMAKE_CURRENT_LIST_DIR, but this is introduced only in a recent version so it is less interesting). This(These) variable(s) seems to be modified whenever current list files changes (which makes sense) as well as when the main list file is finished processing (which is the behavior that I cannot find a documentation anywhere). The second behavior makes it a LOOOT easy to hook into the end of configure stage in order to do sth that depends on the information collected from the whole project, e.g. generate a command to extract doc/po from all files in the project, or looks for "header files" that is generated within the whole project for other languages (e.g. cython). I think it is a useful feature (I've found emails asking how to do such thing...) and it will be really nice to keep it as long as it is not so hard not to break it.

THX
No tags attached.
patch 0001-Add-test-for-end-of-configure-hook.patch (3,894) 2013-09-08 22:44
https://public.kitware.com/Bug/file/4873/0001-Add-test-for-end-of-configure-hook.patch
Issue History
2013-06-04 06:16Yichao YuNew Issue
2013-06-04 08:31Brad KingNote Added: 0033224
2013-06-04 08:31Brad KingStatusnew => backlog
2013-09-08 22:44Yichao YuFile Added: 0001-Add-test-for-end-of-configure-hook.patch
2013-09-08 22:50Yichao YuNote Added: 0033790
2013-09-09 10:50Brad KingNote Added: 0033792
2016-06-10 14:29Kitware RobotNote Added: 0042295
2016-06-10 14:29Kitware RobotStatusbacklog => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0033224)
Brad King   
2013-06-04 08:31   
No specific behavior of variable_watch with respect to the "meta" variables was ever designed or intentionally implemented. The variable_watch command is meant as a debugging feature. While clever to use it as a hook like this I do not think we can guarantee such behavior. If you have time to investigate the current behavior, document it, and add tests, then at least we will know what it does.

You shouldn't need a hook like this. Just do the end-of-config steps at the bottom of the top-level CMakeLists.txt file. They will happen after all add_subdirectory commands have returned and therefore at the end of the configure step.
(0033790)
Yichao Yu   
2013-09-08 22:50   
Sorry for the delay, for some reason I didn't received a notification email from this thread. The point is being able to do that automatically from a module that can be used in any project with a simple include.

Do you mean if I make a test for it and document the behavior, it can possibly be kept?
I have uploaded a patch which add the test. I'm not sure if it is the best place to put it (actually I'm pretty sure it's not..) but it should demonstrate the behavior.

P.S. I haven't actually test it on any version earlier than 2.8.10. I did test from 2.8.10 to the newest git version. Also, according the the git log, the corresponding function in the version as early as 2.6 should have similar behavior (although the variable CMAKE_CURRENT_LIST_DIR was only introduced in 2.8.3).
(0033792)
Brad King   
2013-09-09 10:50   
Re 0014195:0033790: I meant that the current behavior can be documented and kept if a test is added. Your proposed patch is a good start. I think a better place for the test will be in the Tests/RunCMake/variable_watch infrastructure. Then you can print a message from the hook and check easily in the expected output that it appeared. Please also look at adding the documentation of the behavior for these variables to the variable_watch documentation as part of the patch.

However, I do not think we should encourage use in this way. The variable_watch command is intended for debugging only. If we want hooks to occur at specific times we should have a dedicated command or property to say so explicitly.
(0042295)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.