views:

907

answers:

2

How would I go about having a CMake buildsystem, which scans for source files now using AUX_SOURCE_DIRECTORY, scan for header files too in the same directory, preferably using a similar command?

I didn't find an easy way to do this in the documentation yet, so I now have a crappy bash script to post-process my (CodeBlocks) project file...

A: 

The documentation to AUX_SOURCE_DIRECTORY suggests that it was not intended to be used that way, so I'd rather doubt that what you're asking is possible. If you want an authoritative answer, you can reach the CMake developers at [email protected] (they're actually very nice to deal with).

I'd recommend strongly against using wildcards to specify what is included in the build. The build files should specify the exact contents of the libraries, and not depend on what happens to exist in the directory. It may be cumbersome at first (if you're used to wildcards, or IDE's which works the same way), but when you get used to it, you don't want to have it any other way.

JesperE
+3  A: 

You can use the file(GLOB ... ) command. For example:

set(dir my_search_dir)
file (GLOB headers "${dir}/*.h")
message("My headers: " ${headers})

This command can also recurse, and list your files relative to a given path. See the "file" command entry in the cmake doc.

David
would you be kind to accept an answer ?
David