[CMake] Inherited project settings
Marcel Loose (Astron)
loose at astron.nl
Wed Feb 3 06:11:51 EST 2010
Hi Brian,
You ask a lot of questions in one mail ;-)
I'll answer some inline (see below).
Best regards,
Marcel Loose.
On Tuesday 02 February 2010 22:15:11 Brian Davis wrote:
> So I have various CMakeLists.txt files in my directory structure. Some
> with the PROJECT( name ) specified at the top and some without. I am
> using add_sub directory to add each directory.
>
> /CMakeLists.txt
> /source/cpp/app/CMakeLists.txt
> /source/cpp/app/someapp/CMakeLists.txt
> /source/cpp/lib/CmakeLists.txt
> source/cpp/lib/somelib
>
> For the subdirectory structure above build settings for someapp will
> inherit from app/CMakeLists.txt and the top level CMakeLists.txt file.
> However if the build directories and include paths are set for libraries
> in
> /source/cpp/lib/CmakeLists.txt how would apps see these.
>
> Is there a way for one project to inherit project settings from another
> project which is not in the path from the originating subproject
> CMakeLists.txt (app/CMakeLists.txt) up to the root CMakeLists.txt?
>
> For example is there a way for apps to inherit project settings in libs
> (such as include paths) without having to use CACHE STRING "" FORCE and
> having to move these vars up the path to the root CMakeLists.txt file.
Instead of using cached variables, you might consider using global (user-
defined) properties. That's what I do when I need to "inherit", e.g., include
directories, across directory structures. Note that INCLUDE_DIRECTORIES is a
property of a directory. So you can always look up that property for a given
directory.
>
> Is there also a way to disable recursive sub directory project inheritance
> in CMake?
I don't know what you mean by "project inheritance", but AFAIK it is not
possible to disable inheriting settings from your parent directory.
>
> Is there another name I can give to my CMakeLists.txt files that CMake will
> parse in add_subdirectory? I have multiple CMakeLists.txt files open in
> eclipse and can never keep which one is which straight (they all have the
> same name).
No, that name is hard-coded into CMake.
>
> I also noticed that if I have a CMakeLists.txt in between the top/root
> level CMakeLists.txt without the PROJECT( name ) in the file that include
> paths added at the intermediary CMakeLists.txt using INCLUDE_DIRECTORIES(
> wherever) are still inherited.
Yep, that's default behavior. And usually, that's the behavior you would
expect and prefer.
>
More information about the CMake
mailing list