[CMake] $<> expressions in include_directories command
Andreas Pokorny
andreas.pokorny at gmail.com
Wed Jul 13 03:12:53 EDT 2011
Hi,
We came across this problem too with our project. We fixed it by
reducing the cases of circular header dependencies, and we use
variables cache to assemble the include variables. We wrapped the
set command into a unique_set that ensures that no value is added
twice. Still we have to run cmake twice.
we thought about doing some magic:
set(RUN_CMAKE_AGAIN_COUNT 1 CACHE "" INTERNAL)
if(RUN_CMAKE_AGAIN_COUNT GREATER 0)
set(RUN ${RUN}_AGAIN CACHE "" STRING FORCE)
set(${RUN} ${RUN}_AGAIN CACHE "" STRING)
math(EXPR RUN_CMAKE_AGAIN_COUNT "${RUN_CMAKE_AGAIN_COUNT} - 1")
set(RUN_CMAKE_AGAIN_COUNT ${RUN_CMAKE_AGAIN_COUNT} CACHE "" INTERNAL FORCE)
endif()
to ensure that cmake runs twice, before actually building.
Such an improvement would be very welcome.. but.. have you considered a
different user interface? E.g. take a look at static libraries, CMake already
does transitive dependency resolution (if i am not mistaken). It also differs
between like "interface libraries" and "link libraries". Couldnt we
define something
like:
* header directories i need for building target A as a property of a target
* header directories other targets need if they depend on target A
then we would write in subdirectory foo:
add_library(foo ....)
target_include_paths(foo include/foo )
target_include_targets(foo bar)
...
then in a differerent subdirectory bar:
add_library(bar ...)
target_include_paths(bar include/bar src/mydirtystuff)
target_include_targets(bar foo)
# now since we do not want foo or any other target to access src/mydirtystuff:
set_target_properties(bar PROPERTIES INCLUDE_INTERFACE_PATH include/bar )
The existing include_directories command could "call"
target_include_paths(..) internally
for all targets defined afterwards..
Regards
Andreas Pokorny
More information about the CMake
mailing list