Patch: [CMake] Wrong parsing of ADDITIONAL_HEADERS in llvm_add_library

Michael Kruse llvm-commits at meinersbur.de
Wed Feb 12 15:52:04 PST 2014


The signature of llvm_add_library purposefully omitted
ADDITIONAL_HEADERS to be handled by llvm_process_sources. However, if
invoked, the string "ADDITIONAL_HEADERS" will be interpreted as an
argument of the previous named parameter and thus not becoming a part
of ARG_UNPARSED_ARGUMENTS.

For instance, calling
add_clang_library(clangAST APValue.cpp ... LINK_LIBS clangBasic clangLex)
will append *.h files as
llvm_add_library(clangAST APValue.cpp ... LINK_LIBS clangBasic
clangLex ADDITIONAL_HEADERS AST.h ...)
thus causing
target_link_libraries(clangAST clangBasic clangLex ADDITIONAL_HEADERS AST.h ...)
and try to link clangAST with some file ADDITIONAL_HEADERS.lib and the
header files.

(I don't have commit rights)

Btw, previously there was some discussion whether such wrappers make
sense. I am in favor of them. For one, add_llvm_library is already a
wrapper around the intrinsic add_library, so nothing new is
introduced. It also removes code duplication because code for the same
task like llvm_process_sources is avoided. Lastly, the parameter
LINK_LIBS -- knowing the required libraries in advance -- allows
things like determining if the type of the library and add then using
$<TARGET_OBJECTS> instead if possible. OBJECT libraries allow
incremental linking in Visual Studio.

Regards,
Michael Kruse
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AddLLVM.cmake.patch
Type: application/octet-stream
Size: 996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140213/c9e8e7a6/attachment.obj>


More information about the llvm-commits mailing list