MantisBT - CMake
View Issue Details
0014279CMakeCMakepublic2013-07-08 10:562016-06-10 14:31
dbcfd 
Kitware Robot 
lowminoralways
closedmoved 
CMake 2.8.11.2 
 
0014279: cmake should diagnose when no project() is invoked in the top directory
If a top level CMakeLists.txt does not have a project() command, but it has a macro which includes a project() command that is never called, cmMakefile.cxx will see that as a project() command.

Behavior for the Visual Studio generator, without macro:
* Solution project.sln is created

Behavior for the Visual Studio generator, with macro, no project command:
* No solution file created
* No errors/warnings
* Only project file created

Behavior for the Visual Studio generator, with macro, project command in include()'d file
* Solution file generated with desired name
* Cache variables set appropriately so they can be set prior to project() command
* No errors/warnings
See attached file.
See 0014269 for more information (http://public.kitware.com/Bug/view.php?id=14269 [^]).

This is a result of line 650 in cmMakefile.cxx, which looks for any project() command in the top level file, even if that command is within a macro/function that is not called.
No tags attached.
related to 0014278closed  Adjust include() documentation to mirror changes to project() documentation 
zip Reproduce.zip (861) 2013-07-08 10:56
https://public.kitware.com/Bug/file/4814/Reproduce.zip
Issue History
2013-07-08 10:56dbcfdNew Issue
2013-07-08 10:56dbcfdFile Added: Reproduce.zip
2013-07-08 11:25Brad KingNote Added: 0033507
2013-07-08 11:28Brad KingNote Added: 0033508
2013-07-08 11:29Brad KingStatusnew => backlog
2013-07-08 11:29Brad KingSummaryProject() command is incorrectly seen in cmMakefile.cxx if command() is in macro => cmake should diagnose when no project() is invoked in the top directory
2013-07-08 11:32Brad KingRelationship addedrelated to 0014278
2013-07-08 17:46dbcfdNote Added: 0033513
2016-06-10 14:29Kitware RobotNote Added: 0042315
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
(0033507)
Brad King   
2013-07-08 11:25   
This is intentional. It can even be

    $ cat CMakeLists.txt
    if(0)
      project(Fake)
    endif()
    include(ModuleCallingProject)

The reason is that we want to support the hello-world use case of

    $ cat CMakeLists.txt
    add_executable(hello hello.c)

without requiring newcomers to learn the project() command so we insert one syntactically if there isn't a literal one. If we see project() anywhere then we assume the author knows about it.
(0033508)
Brad King   
2013-07-08 11:28   
The auto-insertion of project() at the top must be done before running the code because the inserted one must run first. Therefore this must be based on literal appearance of project().

What we can diagnose instead is that after configuration we have not seen any project() invocation in the top-level directory at all, included or otherwise.
(0033513)
dbcfd   
2013-07-08 17:46   
> What we can diagnose instead is that after configuration we have not seen any project() invocation in the top-level directory at all, included or otherwise.

The other two behaviors seem correct (based on previous conversations), but it does seem if there is no project() invocation, a warning or failure to configure should occur.
(0042315)
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.