GraphViz output issues when using generator expressions
Hi,
I'm a bit unsure whether to label this as a bug, or just as a missing feature that we may not even want to provide...
In our code we use generator expressions quite heavily for setting up the include directories and linked libraries necessary for our libraries/executables. This is because during the installation of our software the externals used by our software may (do) end up in a different place than where we picked them up from during the build. Attached is a very simple demonstration of what sort of thing we do.
In it I set up two libraries. One that links against ZLIB in a very simple way, and one that sets up this linking sort of similarly to what we do in our real software.
# Set up the project:
cmake_minimum_required( VERSION 3.2 )
project( CMakeGraphvizProblem VERSION 1.0.0 LANGUAGES CXX )
# Used external(s):
find_package( ZLIB REQUIRED )
# Function making a variable "relocatable":
function( make_relocatable original updated_name )
# Massage the paths to add a ${SYSROOT} prefix for the exported
# configuration:
set( result )
foreach( path ${${original}} )
list( APPEND result $<BUILD_INTERFACE:${path}>
$<INSTALL_INTERFACE:\${SYSROOT}${path}> )
endforeach()
set( ${updated_name} ${result} PARENT_SCOPE )
# For debugging:
message( STATUS "${original} = ${${original}}" )
message( STATUS "${updated_name} = ${result}" )
endfunction( make_relocatable )
# Build Library1:
add_library( Library1 SHARED library1.h library1.cxx )
set_property( TARGET Library1
PROPERTY PUBLIC_HEADER library1.h )
target_include_directories( Library1 SYSTEM
PRIVATE ${ZLIB_INCLUDE_DIRS} )
target_link_libraries( Library1
PRIVATE ${ZLIB_LIBRARIES} )
# Build Library2:
add_library( Library2 STATIC library2.h library2.cxx )
set_property( TARGET Library2
PROPERTY PUBLIC_HEADER library2.h )
make_relocatable( ZLIB_INCLUDE_DIRS RELOCATABLE_ZLIB_INCLUDE_DIRS )
target_include_directories( Library2 SYSTEM
PUBLIC ${RELOCATABLE_ZLIB_INCLUDE_DIRS} )
make_relocatable( ZLIB_LIBRARIES RELOCATABLE_ZLIB_LIBRARIES )
target_link_libraries( Library2
PUBLIC ${RELOCATABLE_ZLIB_LIBRARIES} )
# Install the libraries:
install( TARGETS Library1 Library2
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include )
Now, when I generate a graph from this, I get:
It's only if I change from using RELOCATABLE_ZLIB_LIBRARIES
to ZLIB_LIBRARIES
for setting up Library2
that I get the graph that I expected.
So... Is this something that we need to learn to live with? Or would it be possible to teach the graphviz output of CMake to deal correctly with generator expressions?
Cheers, Attila