[CMake] add_library without source code

Michael Wild themiwi at gmail.com
Thu Jul 29 03:59:56 EDT 2010


On 29. Jul, 2010, at 9:26 , Ingolf Steinbach wrote:

> 2010/7/28 Michael Wild <themiwi at gmail.com>:
>> So, these external libraries should be compiled using ExternalProject_Add (refer to the docs). [...]
> 
> Ok. I cannot check right now but your proposed way probably solves that problem.
> 
>> If I didn't understand your scenario correctly, please provide some more detail and what you would CMake expect to do. Also, what would you do in "manual mode", i.e. if you did it by just using command line operations.
> 
> So let's turn to another situation:
> 
> Our product comes in different configurations (for instance to support
> different display devices or communication protocols). Due to
> restrictions with respect to the size of the code, each configuration
> only contains those modules which are needed for that configuration.
> So there are the following Modules
> 
> B - basic functionality; used in all configurations
> C1 - communication module, type 1
> C2 - communication module, type 2
> C3 - communication module, type 3
> Da - display module, type a
> Db - display module, type b
> 
> Each configuration consists of A and one of C* and D*.
> 
> My approach would be to have the following structure
> 
> top_level
> +- C
> |   +- include (external interface of each of the C* modules)
> |   +- C1 (static library with implementation of C1)
> |   +- C2 (static library with implementation of C1)
> |   +- C3 (static library with implementation of C1)
> +- D
> |   +- include (external interface of each of the D* modules)
> |   +- Da (static library with implementation of Da)
> |   +- Db (static library with implementation of Da)
> +- B  (static library with implementation of basic functionality)
> +- config
>     +- 1a (executable B, C1, Da)
>     +- 1b (executable B, C1, Db)
>     +- 2a (executable B, C2, Da)
>     +- 2b (executable B, C2, Db)
>     +- 3a (executable B, C3, Da)
>     +- 3b (executable B, C3, Db)
> 
> There would not have to be a single source file in the subdirectories
> of config -- the executables are created by just linking the static
> libraries B and one of C* and one of D*.
> 
> In my opinion, the requirement to have at least one source file may
> ease the implementation within CMake but looks artificial from a user
> point of view.
> 
> Kind regards
> Ingolf

This looks reasonable to me. Where is the main() function? 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.


Michael



More information about the CMake mailing list