[CMake] scope of set_source_files_properties?

Simmons, Aaron asimmons at rosettastone.com
Tue Mar 23 11:16:51 EDT 2010


> Due to historical development reasons, source file properties
> are scoped only in the directory where they are set.  Only
> targets created by an add_exectuable, add_library, or
> add_custom_target commands in the *same* directory (not even
> a subdirectory) can see the property of a source file.

Wow, this seriously needs to be documented.  Also, I'm surprised this has never been mentioned on the list before (I've been searching).  As a feature request, perhaps set_source_files_properties() could have a scope parameter in the same way set() does.

This limitation has put a major crimp in my ability to cleanly make a project.  It's a library with tons of subfolders organized by feature:
     src/
          somefeature1/
          somefeature2/
          ...

I have CMakeList.txt files in each subfolder that add the sources for that folder.  Lots of these subfolders have per-source flags/args that need to be set.  Ideally, it should be up to the CMakeList in a subfolder to set these per-source flags.  Otherwise, the top level CMakeList needs to set them all, which makes it highly cluttered (and not particularly modular).

Is there some other way to go about doing this?



Thanks,
aaron



More information about the CMake mailing list