[CMake] Evaluate generator expressions with install interface
P F
pfultz2 at yahoo.com
Tue May 16 14:02:23 EDT 2017
Hi,
I would like to evaluate generator expressions to generate a pkgconfig file. Something like:
function(auto_pkgconfig TARGET)
file(GENERATE OUTPUT ${TARGET}.pc CONTENT "
Name: ${TARGET}
Cflags: -I$<JOIN:$<TARGET_PROPERTY:${TARGET},INTERFACE_INCLUDE_DIRECTORIES>, -I>
Libs: -L$<TARGET_FILE_DIR:${TARGET}> -l${TARGET}
")
install(FILES ${TARGET}.pc DESTINATION lib/pkgconfig)
endfunction()
However, this doesn’t work very well. It always evaluates the build interface or computes the TARGET_FILE_DIR according the build directory instead of installation. Also, if include directories are added to the target after calling `auto_pkgconfig` it doesn’t capture those(ie it runs file(GENERATE) at config time instead of generator time).
So, is there a way to evaluate generator expressions for installation? And evaluate them at generator time?
Calling `file(GENERATE)` at installation time(with install(CODE) or install(SCRIPT)) does not solve this problem either.
Thanks,
Paul
More information about the CMake
mailing list