Bug 349877 - CMake doesn't select proper generator after prune.
Summary: CMake doesn't select proper generator after prune.
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Build tools: CMake (other bugs)
Version First Reported In: git master
Platform: Compiled Sources Linux
: NOR minor
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-03 22:17 UTC by Gianni
Modified: 2017-02-14 11:57 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Proposed patch. (1.01 KB, patch)
2015-07-03 22:24 UTC, Gianni
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gianni 2015-07-03 22:17:37 UTC
I have some rules in CMake which cause the build dir to be non-empty after a prune.  Running a configure in the build dir, will then be missing the '-G Ninja'.

Reproducible: Always

Steps to Reproduce:
1. Prune
2. Configure


Actual Results:  
Unix Makefile (the default) is selected as the generator:

build> /.../cmake -DCMAKE_INSTALL_PREFIX=/usr/local /home/.../project


Expected Results:  
Have Ninja as the generator:

build> /.../cmake -DCMAKE_INSTALL_PREFIX=/usr/local -G Ninja /home/.../project

In projectbuilders/cmakebuilder/cmakejob.cpp

The command line for cmake is built with or without the '-G' option, if the build dir is detected to be empty (or inexistant):

//if we are creating a new build directory, we'll want to specify the generator
QDir builddir(CMake::currentBuildDir( m_project ).toLocalFile());
   if(!builddir.exists() || builddir.count()==2) {

However, in my case, the build dir is present and non-empty (some wierd reason why, not important for this issue), but make hasn't run yet.

I propose a better check, which is to see if the CMakeCache.txt file is present, which it should *always* be created if cmake hasn't run.  Even if it has, and this file is missing, cmake will run as if it is the first time.  Therefore, the presence of this file is a better check if the build dir is ready in cmake's eyes.
Comment 1 Gianni 2015-07-03 22:20:12 UTC
Sorry, steps to reproduce is missing a steop:

1. Prune
2. cd build; touch test
3. Configure
Comment 2 Gianni 2015-07-03 22:24:51 UTC
Created attachment 93474 [details]
Proposed patch.
Comment 3 Kevin Funk 2015-11-29 15:04:46 UTC
@Aleix: Patch looks sane to me. Can you double-check & commit?
Comment 4 Gianni 2017-02-03 13:24:35 UTC
So.  Almost 2 years.  Any chance of merging this?
Comment 5 Aleix Pol 2017-02-14 11:57:14 UTC
Git commit fdd6636711a9e5d58a7c18b2f520ee8ef7ec0285 by Aleix Pol, on behalf of Gianni from Bugzilla.
Committed on 14/02/2017 at 11:57.
Pushed by apol into branch '5.1'.

Specify generator whenever there's no CMakeCache.txt

M  +1    -1    projectbuilders/cmakebuilder/cmakejob.cpp

https://commits.kde.org/kdevelop/fdd6636711a9e5d58a7c18b2f520ee8ef7ec0285