[CMake] Executable and library dependencies

Andreas Pakulat apaku at gmx.de
Tue May 5 15:54:13 EDT 2009


On 05.05.09 21:51:16, Emmanuel Blot wrote:
>>>>> 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.

But then the second parameter is completely superflous, it just adds
noise and confusion. If you use just add_directory(foo) cmake will
automatically use <builddir>/foo as builddir for foo.

Andreas

-- 
You had some happiness once, but your parents moved away, and you had to
leave it behind.


More information about the CMake mailing list