The CMake Guide forset_directory_properties claims:
Set the property for the current directory and subdirectories.
It seems to me that the properties set in the parent directory should also be inherited in all subdirectories. But this does not seem to be the case. Consider:
CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(foo CXX)
set_property(DIRECTORY . PROPERTY narf "zort")
add_subdirectory(a)
get_property(res DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY narf)
message("Property read from root: " ${res})
a/CMakeLists.txt
get_property(res DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY narf)
message("Property for a read from a: " ${res})
get_property(res DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY narf)
message("Property for root directory root read from a: " ${res})
Fingerprints:
Property for a read from a:
Property for root directory root read from a: zort
Property read from root: zort
Thus, a property can only be obtained from the directory on which it was installed, and not from subdirectories. The same is true when using set_directory_properties/ get_directory_propertiesto handle properties.
Did I misunderstand the appropriate section in the manual set_directory_properties? Or is it just out of date / wrong?
source
share