[CMake] Re: Out of source build and KDevelop

Bill Hoffman bill.hoffman at kitware.com
Tue Oct 19 16:26:35 EDT 2004


At 04:14 PM 10/19/2004, Alexander Neundorf wrote:

>>  
>> For each PROJECT(foo) command you get a project in kdevelop or visual 
>> studio. It should not be based on whether or not there is a target in  
>> the directory. I am doing this now for visual studio and it does what  
>> you want.  You can load sub-projects and not build the entire thing  
>> each time.  The project map directly to what the users specified in the 
>> CMakeLists.txt files. 
>>  
>> So, you might have to change your CMakeLists files to contain PROJECT() 
>> commands to force a sub project, but that is the way it should work.   
> 
>That's no problem (you know, it's cmake, it's easy :-) 
>I thought PROJECT(whatever) should be specified only once in a cmake 
>directory hierarchy ? Doesn't it have any side effects ? 
>Is Project_SOURCE_DIR (and BINARY_DIR) then in all CMakeLists.txt the one 
>from the most top level CMakeLists.txt or always the one from the "most 
>local" CMakeLists.txt ? 
> 

The PROJECT_SOURCE_DIR is the most local.   If you want to refer
to a specific project source dir then, you use its name CMake_SOURCE_DIR.
But PROJECT_SOURCE_DIR is always the closest one.  CMake supports combining
projects.  For example, in CMake we have a curl project.   In some future
version of cmake it will support out of source source.  So you can SUBDIR(/full/path/)
to another project and build it as part of the current project.  So, the
PROJECT command can and should show up more than once in a project.
Most of our projects including CMake do this type of thing.  CMake has the following
sub-projects:
 
PROJECT(CMake)  
Source/CTest/Curl/PROJECT(LIBCURL)  
Source/CursesDialog/form/PROJECT(CMAKE_FORM)  
Source/kwsys/PROJECT(cmsys)  
Utilities/cmexpat/PROJECT(CMEXPAT)


You can also disconnect a sub-project from the root project so that it is not
built as part of the top project.   This would allow you to in one pass configure
100's of examples for a project, but not pollute the IDE project file or makefiles
with all of the examples.  The users would have to cd example; make or run kdevelop
or msdev on the example project. That is done with an option to the SUBDIR command.

>Otherwise it doesn't matter in any way to me whether it's in the local or 
>the global generator (as long as it works as it does now), it's just that 
>I found my way into the local generator and did it there. 

So, it would not work exactly like it does now.  It would require the PROJECT()
in each subdir to generate a sub-project.   

-Bill 




More information about the CMake mailing list