Bug 429605

Summary: Build loop in cmake
Product: [Applications] kdevelop Reporter: jon.gough
Component: Build tools: CMakeAssignee: kdevelop-bugs-null
Status: REOPENED ---    
Severity: normal CC: igorkuo, samu.voutilainen
Priority: NOR    
Version: 5.6.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Crash when CMake configuration was looping

Description jon.gough 2020-11-24 21:13:18 UTC
SUMMARY
The change "Reload project when non-{generated,external} CMake file becomes dirty" in commit "Commit 893b400b" appears to cause a cmake build loop.

STEPS TO REPRODUCE
1. Have project with variables in cmakecache
2. Change CMAKE_BUILD_TYPE to "Release"
3. Apply change

OBSERVED RESULT
Cmake process is run with the changed value. Then it runs at least once again with the unchanged value, i.e."Debug"

EXPECTED RESULT
Cmake runs once with the changed value

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Linux Mint 20
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
The projects being used are stored on a cifs network drive. The desktop is linux mint 20, the server is Ubuntu server 18.04. 
The project being build is opensource in git and can be found here:
https://github.com/jongough/testplugin_pi

For normal purposes the CMAKE_BUILD_TYPE is set to Debug, but for some testing the CMAKE_BUILD_TYPE needs to be set to "Release".

With KDevelop 5.5.2 this process worked, with 5.6.0 it does not
Comment 1 jon.gough 2020-11-24 21:32:30 UTC
Have reproduced the issue on a local drive so cifs is not involved.
Comment 2 Samu Voutilainen 2020-12-07 06:46:13 UTC
Happens for me too, but the default Debug CMAKE_BUILD_TYPE causes it also. The bug only seems to be affecting some of my projects, so I suppose this is related to CMakeLists.txt parsing. 

I’m on SUSE 15-SP2, with KDevelop 5.6.0.
Comment 3 Samu Voutilainen 2020-12-07 07:02:15 UTC
Created attachment 133910 [details]
Crash when CMake configuration was looping

This may be related, but when this configuration was looping, and (IIRC) I tried to close the project, this crash happened. 

FWIW, I’m not able to install KDevelop’s debug symbols at the moment, but I can provide a dump with them later.
Comment 4 jon.gough 2020-12-07 07:27:08 UTC
I can confirm that just clicking apply from Project/Open Configuration after changing from Debug to Release and back to Debug causes at least two runs of cmake.
Comment 5 Milian Wolff 2020-12-07 09:42:42 UTC
thanks for the report, I'll have a look now
Comment 6 Milian Wolff 2020-12-07 09:48:03 UTC
as a workaround for now, you should be able to change the build type by pressing "Show Advanced" and then set the "Build Type"
Comment 7 Milian Wolff 2020-12-07 10:20:20 UTC
Git commit 4887d28ec73db039b63a2609b92600e90721654a by Milian Wolff.
Committed on 07/12/2020 at 10:18.
Pushed by mwolff into branch '5.6'.

Run configure once to apply cmake preferences for CMake file api usage

When we use the cmake file API we have to run configure to reload the
model. In such a case, when we run configure to apply the new cmake
preferences, we can just run reloadModel directly. Otherwise, we'd
end up running configure twice.

M  +8    -0    plugins/cmake/settings/cmakepreferences.cpp

https://invent.kde.org/kdevelop/kdevelop/commit/4887d28ec73db039b63a2609b92600e90721654a
Comment 8 Milian Wolff 2020-12-07 10:20:29 UTC
Git commit fbb4b8d5ddb041e01f9c6d94d272374b9e6f75d9 by Milian Wolff.
Committed on 07/12/2020 at 10:18.
Pushed by mwolff into branch '5.6'.

Sync CMake build type between cache and kdevelop settings

We store the cmake build type also in the kdevelo project settings
in order to recreate the build dir on demand if it gets wiped.
But when the user now manually changes it through the cmake cache
value for an existing build dir, the values could get out of sync.
Prevent that by keeping the two values in sync, i.e. once in the
list of cache values and once in the project setting drop down.

M  +3    -1    plugins/cmake/settings/cmakecachemodel.cpp
M  +4    -1    plugins/cmake/settings/cmakecachemodel.h
M  +25   -7    plugins/cmake/settings/cmakepreferences.cpp
M  +2    -1    plugins/cmake/settings/cmakepreferences.h

https://invent.kde.org/kdevelop/kdevelop/commit/fbb4b8d5ddb041e01f9c6d94d272374b9e6f75d9
Comment 9 Igor Kushnir 2021-09-06 08:07:23 UTC
I had to revert part of the fix in https://commits.kde.org/kdevelop/52409f95531a2c52c19afcf5461022b5ff93bf43 because of a regression caused by that commit.