[Cmake] AUX_SOURCE_DIRECTORY bug ?

hilary oliver hilary.oliver at paradise.net.nz
Sat, 07 Feb 2004 17:51:50 +1300


Brad King wrote:

> > Some directories in my source tree exist for cosmetic reasons,
> > essentially, so there's no good reason to build them all into separate
> > libraries.  From the CMake documentation it looks like 
> > AUX_SOURCE_DIRECTORY is used for building the source from multiple dirs
> > into a single library.
> 
> AUX_SOURCE_DIRECTORY is not meant for this purpose.  What documentation 
> led you to believe this?  It is meant for directories containing a whole 
> bunch of small source files used for explicit template instantiation so 
> that not every instantiation needs to be listed in the CMakeLists.txt file.

The official "Writing CMakeLists" page, under "Build Targets", says:
"The AUX_SOURCE_DIRECTORY is a directory where other source code, not in
this directory, whose object code is to be inserted into the current
LIBRARY. All source files in the AUX_SOURCE_DIRECTORY are compiled".  
That sounds to me a lot like my interpration above.  But as a CMake
beginner, I'm no doubt missing something.

> The command is left over from the very early days of CMake before the 
> current design philosophy was adopted and remains for backward 
> compatibility.  It works only when specifying a relative path one 
> directory below the directory containing the listfile.  In your case, 
> the CMakeExample directory would contain a CMakeLists.txt file with the 
> command
> 
>    AUX_SOURCE_DIRECTORY(Hello SRCS)
> 

Ok, I see, that would explain the strange directory-name concatenation
(it's only meant for sub directories specified relatively).  It's a
pretty major restriction on the use of AUX_SOURCE_DIRECTORY to be
omitted from the documentation though. 

> ADD_EXECUTABLE will guess file extensions for backward compatibility, 
> but giving file extensions is preferred.

Fair enough, but that's not documented either, and it's inconsistent
that guessing occurs in the CMakeLists.txt directory but not in other
directories. Also, the official "Hello" example does not use explicit
filename extensions.  
 
> What you probably want is a CMakeLists.txt file in CMakeExample 
> containing code like
> 
> ADD_EXECUTABLE(myExe Hello/src1.cxx Hello/src2.cxx
>                       World/src3.cxx World/src4.cxx)

Ok, thanks for the info. I guess I just thought AUX_SOURCE_DIRECTORY
would let me get away with not listing every file explicitly.

Hilary