[cmake-developers] Bug introduced in generate-time target checking code

Stephen Kelly steveire at gmail.com
Sun Oct 14 12:24:41 EDT 2012


Stephen Kelly wrote:

> 
> Hi there,
> 
> I just noticed that I probably introduced a bug in commit
> 290e92ada86c5b74669be48ee901494ae8e48ee3. I don't have time to fix it or
> even test it right now, but in that commit I changed a call to GetTargets
> into GetGeneratorTargets in cmGlobalGenerator::CheckLocalGenerators. The
> problem is that CheckLocalGenerators is called at configure time, so the
> GeneratorTargets is still empty.
> 
> Can CheckLocalGenerators be invoked at generate time instead? It calls
> GetOriginalLinkLibraries, which I also need to call only at generate-time
> as it will need to be moved to cmGeneratorTarget and use generator
> expressions.

I have now tested and confirmed the issue.

This CMakeLists file no longer produces a configure-time error in master, 
though it does with the stable version:

  cmake_minimum_required(VERSION 2.8)
  include_directories(SOMETHING_INCLUDE_DIRS-NOTFOUND)


CMake Error: The following variables are used in this project, but they are 
set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake 
files:
SOMETHING_INCLUDE_DIRS
   used as include directory in directory 
/home/stephen/dev/src/playground/cmake

-- Configuring incomplete, errors occurred!


Similarly, the Qt and curses guis No longer flag the NOTFOUND include 
directories after selecting the 'configure' action, but fail at compile time 
instead.

The reason for this is as I described above. The code now loops over 
cmGeneratorTargets - a container which is not populated at configure-time.

Part of the problem is that the include directories could be determined only 
at generate-time, not at configure-time. A similar issue will arise with 
processing linked libraries (which is how I noticed it). 

This means that the cmake-gui workflow of pressing the configure button 
until there is no more red, then generating will no longer be valid. As 
dependencies can be determined to be NOTFOUND at generate-time, hitting the 
'Generate' button could generate new red entries in the view.

Additionally, all CONFIGURATIONS will need to be iterated over and tested 
whether they produce any NOTFOUND content.

This also raises the larger issue of generate-time errors. If an error 
occurs at configure-time, the generate step is not executed, and the build-
system is not generated - make does nothing. If an error occured at 
generate-time, generation does not abort, and although a 'fatal' error can 
be reported, make can still execute, and depending on the nature of the 
error, may succeed or fail.

It might make sense to generate no top-level makefile or a top-level 
makefile which only reports the same error that was reported at generate-
time if that is something that has an equivalent with all generators. Eg, 
something like:

all:
	${CMAKE_COMMAND} -E echo "SOMETHING_INCLUDE_DIRS used in this 
project, but set to NOTFOUND"


I think that's one of the options for fixing this.

Given that we're in RC mode and expecting to release final in two weeks, one 
other option is to revert part of the branch adding the feature. Then we'd 
still have to solve the problems for the next release anyway, but with more 
time to research and prepare.

Thoughts?

Thanks,

Steve.






More information about the cmake-developers mailing list