From b7080be597c50b0e9e8ea1630c85ce7d713c1d05 Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Mon, 4 Sep 2017 21:45:08 +0200 Subject: [PATCH 1/2] Support INTERFACE include directories in ROOT_GENERATE_DICTIONARY CMake offers three visibility qualifiers for target include directories, which are populated to target properties as shown in the following table: | | INTERFACE | PUBLIC | PRIVATE | | INCLUDE_DIRECTORIES | | x | x | | INTERFACE_INCLUDE_DIRECTORIES | X | x | | For dictionary generation the PUBLIC and INTERFACE qualifiers and hence the INTERFACE_INCLUDE_DIRECTORIES are to be preferred, because header files meant to be consumed by the user are usually put into PUBLIC and/or INTERFACE qualified directories. Furthermore, the CMake imported targets always have INTERFACE visibility. This commit changes the current behaviour to read the INTERFACE_INCLUDE_DIRECTORIES (as opposed to the INCLUDE_DIRECTORIES) target property which will catch more desired use cases, including imported targets. In other words, this will now ignore PRIVATE include directories, but include INTERFACE include directories - PUBLIC ones stay unchanged. In addition, this commit adds a condition which ignores include directories formulated as a CMake generator expression. Unfortunately, there is currently no way to evaluate those seperately. --- cmake/modules/RootNewMacros.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/modules/RootNewMacros.cmake b/cmake/modules/RootNewMacros.cmake index 72a4921f441bb..e6b30f94d55d0 100644 --- a/cmake/modules/RootNewMacros.cmake +++ b/cmake/modules/RootNewMacros.cmake @@ -290,9 +290,12 @@ function(ROOT_GENERATE_DICTIONARY dictionary) foreach(dep ${ARG_DEPENDENCIES}) if(TARGET ${dep}) - get_property(dep_include_dirs TARGET ${dep} PROPERTY INCLUDE_DIRECTORIES) + get_property(dep_include_dirs TARGET ${dep} PROPERTY INTERFACE_INCLUDE_DIRECTORIES) foreach(d ${dep_include_dirs}) - set(includedirs ${includedirs} -I${d}) + string(REGEX MATCHALL ^[$]<.* is_generator_expr ${d}) + if(NOT is_generator_expr) + set(includedirs ${includedirs} -I${d}) + endif() endforeach() endif() endforeach() From 83c59865536aab23ce217e86b2848e9dca0ab8f4 Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Fri, 8 Sep 2017 01:49:51 +0200 Subject: [PATCH 2/2] Do not ignore BUILD_INTERFACE generator expressions Turns out, naked absolute include directories as target properties will prohibit those targets from being exported with INSTALL(EXPORT ...). Therefore, one cannot ignore the $ type generator expressions. This commit will add another condition which detects BUILD_INTERFACE generator expressions and extracts the value which is then added to the list of include directories for rootcling. --- cmake/modules/RootNewMacros.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/modules/RootNewMacros.cmake b/cmake/modules/RootNewMacros.cmake index e6b30f94d55d0..bdb1a668cd75d 100644 --- a/cmake/modules/RootNewMacros.cmake +++ b/cmake/modules/RootNewMacros.cmake @@ -292,8 +292,11 @@ function(ROOT_GENERATE_DICTIONARY dictionary) if(TARGET ${dep}) get_property(dep_include_dirs TARGET ${dep} PROPERTY INTERFACE_INCLUDE_DIRECTORIES) foreach(d ${dep_include_dirs}) - string(REGEX MATCHALL ^[$]<.* is_generator_expr ${d}) - if(NOT is_generator_expr) + string(REGEX MATCHALL "^[$]<.*>$" is_generator_expr ${d}) + string(REGEX MATCHALL "^[$]$" is_build_interface ${d}) + if(CMAKE_MATCH_0) + set(includedirs ${includedirs} -I${CMAKE_MATCH_0}) + elseif(NOT is_generator_expr) set(includedirs ${includedirs} -I${d}) endif() endforeach()