[CMake] add_library without source code

Ingolf Steinbach ingolf.steinbach at googlemail.com
Wed Jul 28 04:57:05 EDT 2010


2010/7/28 Michael Wild <themiwi at gmail.com>:
> Are those libraries only "convenience" libraries? I.e. are you ever going to install them? If not, just list the source-files in the top-level CMakeLists.txt:
>
>
> add_executable(super-duper
>  modul1/modul1.c
>  module2/module2.c
>  )

Even if they are not going to be *installed* as separate libraries,
there are realistic cases in which your approach is not ideal:

Let's assume that these are third-party libraries which come with
their own (and maybe even conflicting) compilation settings (compiler
flags, internal include files, ...). The top-level CMakeLists.txt
would have to
- "know" all the sources contributing to the libraries and
- reflect all these internals with respect to different compilation
settings on a source-by-source basis.

And if you are going to update one of these libraries you would have
to reflect all the necessary changes in the top-level file.

Kind regards
Ingolf


More information about the CMake mailing list