[CMake] add_library without source code
Michael Wild
themiwi at gmail.com
Thu Jul 29 07:56:49 EDT 2010
On 29. Jul, 2010, at 10:18 , Ingolf Steinbach wrote:
> 2010/7/29 Michael Wild <themiwi at gmail.com>:
>> Where is the main() function? In B?
>
> Yes, it would be in B.
>
>> Perhaps it would be a good idea to not compile it into B, but use the file containing main() as the "required file" instead.
>
> This approach works around the current limitation. But I'd still
> consider it suboptimal: for instance, the suite of unit tests for the
> product would now require 6 (more or less identical) unit tests (for
> each of the main() functions) rather than only one.
>
> Kind regards
> Ingolf
Then just create an empty dummy file using e.g. file(WRITE ${CMAKE_BINARY_DIR}/dummy.c ""). It is fast and doesn't hurt too much. Most importantly it doesn't pollute your source tree.
Michael
More information about the CMake
mailing list