[CMake] How to using 'conditional statements at generate time'?

Stephen Kelly steveire at gmail.com
Fri Mar 22 10:27:23 EDT 2013


Yuchen Deng wrote:

> hi, there!
> I was reading the release log in here:
> http://www.kitware.com/news/home/browse/CMake?
2012_11_07&CMake+2.8.10+Just+Released
> Add see the parts:
> 
>> Generator expressions, which are used to introduce conditional statements
>> at generate time rather than at CMake compile time, are now available in
>> more contexts, *notably in the INCLUDE_DIRECTORIES and
>> COMPILE_DEFINITIONS target properties.* There are also new generator
>> expressions available in the 2.8.10 release.
> 
> In many times, I have to add more target in one CMakeLists.txt.
> 
> My question:
> How to use for INCLUDE_DIRECTORIES and COMPILE_DEFINITIONS target
> properties ?
> Any examples? tests? or docs?
> Thanks!
> 

Hi there,

I'm impressed that you ask for the tests for this stuff. That's where I look 
too when I want to find out how to use something. :)

The relevant tests in the cmake repo are in 

 Tests/CMakeCommands/* 
 Tests/GeneratorExpressions 
 Tests/CompileDefinitons/target_prop
 Tests/IncludeDirectories/TargetIncludeDirectories
 Tests/ExportImport

The target_include_directories is the more 'high level' API around the more 
low-level INCLUDE_DIRECTORIES and COMPILE_DEFINITIONS properties in the 
other tests.

See the docs like 

 cmake --help-property INTERFACE_INCLUDE_DIRECTORIES
 cmake --help-property INTERFACE_COMPILE_DEFINITIONS
 cmake --help-variable CMAKE_BUILD_INTERFACE_INCLUDES (note that this will 
be renamed to CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE soon)

See also more information here:

 http://thread.gmane.org/gmane.comp.kde.devel.buildsystem/7778

Thanks for trying the stuff out,

Steve.




More information about the CMake mailing list