Version: 4.0.60 (using KDevPlatform 1.0.60) (using 4.4.3 (KDE 4.4.3), Debian packages) OS: Linux (x86_64) release 2.6.32-3-amd64 I spent a long time reading the CMake parser code trying to figure out where the per-directory variable map was stored, only to find (by testing) that it isn't. Here is a testcase that shows the wrong behavior: # CMakeLists.txt: set(foo "asd") add_subdirectory(sub) add_subdirectory(sub2) message(STATUS "result: ${foo}") # sub/CMakeLists.txt: message(STATUS "this is sub1: ${foo}") set(foo "one") message(STATUS "changed to: ${foo}") # sub2/CMakeLists.txt: message(STATUS "this is sub2: ${foo}") set(foo "two") message(STATUS "changed to: ${foo}") CMake 2.8.1 output: -- this is sub1: asd -- changed to: one -- this is sub2: asd -- changed to: two -- result: asd KDevelop 4.0 output: message: ("result: asd") message: ("this is sub1: asd") message: ("changed to: one") message: ("this is sub2: one") message: ("changed to: two") It prints "result: asd" first instead of last due to bug REPLACEHERE; that's a different issue. The problem here is that sub2 sees foo set to "one" instead of "asd". Currently the variable map is per project, and it's modified directly when processing each directory. To fix this, we would need a *stack* of variable maps.
And I'm an idiot and forgot to replace REPLACEME with "bug 238456" before submitting -.-
CMake functions (not macros) have their own variable scope too: function(sub) message(STATUS "this is sub: ${foo}") set(foo "one") message(STATUS "changed to: ${foo}") endfunction(sub) set(foo "asd") sub() message(STATUS "result: ${foo}") CMake 2.8.1: -- this is sub1: asd -- changed to: one -- result: asd KDevelop 4.0: message: ("this is sub1: asd") message: ("changed to: one") message: ("result: one")
Changing severity and importance as this can cause KDevelop to eat all memory because variable contents grow beyond all limits.
Can't have it as VHI
It's not a crash either
it can crash, see Andreas' comment.
Git commit a06e144523f56358f1921e06e175228f01c5d5ad by Aleix Pol. Committed on 19/12/2011 at 03:25. Pushed by apol into branch 'master'. Support scopes in CMake support Only implemented for functions for the moment. CCBUG: 238455 M +27 -21 projectmanagers/cmake/parser/cmakeprojectvisitor.cpp M +3 -1 projectmanagers/cmake/parser/cmakeprojectvisitor.h M +52 -2 projectmanagers/cmake/parser/variablemap.cpp M +15 -2 projectmanagers/cmake/parser/variablemap.h M +37 -5 projectmanagers/cmake/tests/cmake_cmakeprojectvisitor_test.cpp http://commits.kde.org/kdevelop/a06e144523f56358f1921e06e175228f01c5d5ad
Since last commit, this can't lead to recursively eating all memory in function, so it's not a crash anymore.
*** Bug 309830 has been marked as a duplicate of this bug. ***
Git commit df00d058fcce0d4026704aeffbb6802dd9582433 by Aleix Pol. Committed on 15/11/2012 at 03:48. Pushed by apol into branch 'master'. Fix subdirectory scoping in cmake projects Don't pop the scope until all the subdirectories have been processed. Thanks to Daniel Calviño Sánchez for such a helpful bug report :) Related: bug 309687 M +6 -3 projectmanagers/cmake/cmakemanager.cpp M +27 -0 projectmanagers/cmake/tests/cmakemanagertest.cpp M +1 -0 projectmanagers/cmake/tests/cmakemanagertest.h http://commits.kde.org/kdevelop/df00d058fcce0d4026704aeffbb6802dd9582433
Thank you for the bug report. As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists. If this bug is no longer persisting or relevant please change the status to resolved.