[cmake-developers] Remove check for source files in add_library()
Ben Boeckel
ben.boeckel at kitware.com
Fri Jun 27 10:35:22 EDT 2014
On Fri, Jun 27, 2014 at 15:48:34 +0200, Ådne Hovda wrote:
> 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"
Why not just defer the add_library until the end of the 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?
Does the test suite run without complaint? Also, a test for this would
be appreciated.
--Ben
More information about the cmake-developers
mailing list