[CMake] coding style for modules

Alexander Neundorf a.neundorf-work at gmx.net
Thu Jan 4 16:09:28 EST 2018


On 2018 M01 4, Thu 05:09:54 CET Dave Milter wrote:
> Hello,
> 
> If there is some libfoo that I want to use in my project,
> and this libfoo has it's own CMakeLists.txt I have 3 options to deal
> with such external dependency:
> 
> a) Treat it like every other external dependency and write cmake code
>   like FindLibFoo.cmake to find libfoo on file system.

This would be a clean solution if you don't want to build libfoo as part of 
your project.

> b)Include this project as git submodule and use ExternalProject to
> invoke `cmake` and `cmake --build`

This would be a clean solution if you want to build libfoo as part of yur 
project.

> 
> c)Include this project as git submodule and use add_subdirectory(libfoo)

the "parent" project will/can influence the behaviour of libfoo then, I would 
not recommend this.

Or use d) as Alan suggests.

Alex



More information about the CMake mailing list