[CMake] INCLUDE() guards
Nico Schlömer
nico.schloemer at gmail.com
Tue Sep 9 07:45:11 EDT 2014
Hi all,
I have a project with multiple interdependent subpackages here, each
of which has its own export config file. The dependency hierarchy is
reflected in the `INCLUDE()` statements in the export files.
I would like to avoid that an export config file is included more than
once, so I'm guarding the files with
```
IF(NOT <name of the subpackage>_CONFIG_INCLUDED)
SET(<name of the subpackage>_CONFIG_INCLUDED 1)
[...]
<setting of export variable etc>
[...]
ENDIF()
```
This looks very much like the old C/C++ `#ifdef` `#include` header
guards, so I was wondering if this is an appropriate pattern for CMake
too. Or maybe there is another CMake command that already does exactly
what I want?
Cheers,
Nico
More information about the CMake
mailing list