[CMake] Executable and library dependencies

Emmanuel Blot eblotml at free.fr
Tue May 5 15:51:16 EDT 2009


>>>> Doing in-source builds is generally considered a bad idea.  
>>>> Instead do
>>>> something like:
>>>>
>>>>    ADD_SUBDIRECTORY (${prj} ${prj}/build)
>>>
>>> Huh? That snippet above has absolutely nothing to do with in- 
>>> source vs.
>>> out-of-source builds. He simply accumulates all his subprojects in a
>>> variable instead of listing each with its own add_subdirectory call.
>>
>> I disagree. From the docs:
>>
>> add_subdirectory: Add a subdirectory to the build.
>
> Heh, didn't see the second argument :)

I always do out-of-source builds, believe me.

${prj} is a relative path, not an absolute path

in other words, I guess CMake interprets the command as

ADD_DIRECTORY (${CMAKE_CURRENT_SOURCE_DIR}/${prj} $ 
{CMAKE_CURRENT_BINARY_DIR}/${prj})

using ${prj}/build would be a bad idea, as every subproject would  
construct a build directory within the source tree.

all the subprojects are built into a build/ tree which is fully  
external from the source tree

Cheers,
Manu



More information about the CMake mailing list