bfgroup / Lyra

A simple to use, composable, command line parser for C++ 11 and beyond
https://bfgroup.github.io/Lyra/
Boost Software License 1.0
471 stars 56 forks source link

cmake install option #44

Closed NicoG60 closed 3 years ago

NicoG60 commented 3 years ago

I've added a simple cmake trick to detect if Lyra is "built" and installed directly or if it is used via the add_subdirectory directive.

This allow the users of the latter not being polluted by Lyra install targets. It is also compatible with existing procedure as it automatically turns the install targets ON when used directly.

Finally even when using it as a subdir, you can override that behaviour and still install Lyra by doing the following:

set(LYRA_INSTALL ON CACHE BOOL "please install lyra anyway" FORCE)
add_subdirectory(path/to/Lyra)

Hope it is useful for others :)

grafikrobot commented 3 years ago

@jayeshbadwaik since you added the install support.. any comments?

jayeshbadwaik commented 3 years ago

The required use case is already supported by using add_subdirectory with a EXCLUDE_FROM_ALL option as shown in this proof-of-concept project. Therefore, I do not see any need for the PR.

NicoG60 commented 3 years ago

@jayeshbadwaik Sorry I completely forgot about that feature! In this case yeah, my PR is useless.

grafikrobot commented 3 years ago

Thanks @jayeshbadwaik for pointing that out. And @NicoG60 , not totally useless. I've added an issue (https://github.com/bfgroup/Lyra/issues/45) to improve the doc comment in the cmakelists.txt.