Cmake set_target_properties INCLUDE_DIRECTORIES ignored in linux

I have a whole group of goals, and I'm trying to set include directories on each target basis.

set_target_properties (foo PROPERTIES INCLUDE_DIRECTORIES ${CMAKE_Fortran_MODULE_DIRECTORY}/bar) 

When I create ( make VERBOSE=1 ) this on Mac OS X, I get

 ... -J../build/modules/foo -I../build/modules/bar 

When I do the same in Linux, I get

 ... -J../build/modules/foo ... 

The only difference I see is that on mac I use cmake 2.8.8 and on linux I use 2.8.7. Is this not supported in previous versions prior to 2.8.8?

+4
source share
1 answer

This behavior really depends on a version change from 2.8.7 to 2.8.8.

From changelog :

Call ExpandVariablesInString for each target INCLUDE_DIRECTORIES

Update documentation regarding INCLUDE_DIRECTORIES. [...]

Keep the target INCLUDE_DIRECTORIES property up to date.

Retrieve and use the target properties of INCLUDE_DIRECTORIES.

Of particular interest is fixing documentation changes . According to this property, INCLUDE_DIRECTORIES in 2.8.7 had a read-only property in directories. The target property was not at all in this version.

Since the setting of arbitrary target properties is allowed by CMake, your script works without errors, but the property is simply ignored by CMake.

This is another great example of why you should always take care of indicating the correct minimum required version .

+4
source

Source: https://habr.com/ru/post/1485647/


All Articles