[cmake-developers] Remove check for source files in add_library()

Ådne Hovda ahovda at openit.com
Fri Jun 27 09:48:34 EDT 2014


Hi

It would be handy when creating macros that wraps add_library where the 
number of source files is unknown to be able to write:

add_library( mylib )
target_sources( mylib PRIVATE mylib.c mylib.h )

but this fails with the warning "You have called ADD_LIBRARY for library 
testlib without any source files. This typically indicates a problem 
with your CMakeLists.txt file"

I have tried to just remove that check in cmAddLibraryCommand and apart 
from a warning about missing LINKER_LANGUAGE it works okay.

https://github.com/aadnehovda/CMake/commit/d527b1db787c426517f7af357df0cd3ba9d9a12a

I guess there are other implications I have not though of as well?

-- 
Best regards,
Ådne Hovda



More information about the cmake-developers mailing list