2018-04-17 11:58 GMT+02:00 David Demelier <[email protected]>:
> Hello,
>
> In my application I have some custom functions that help the process of
> creating executable, libraries, plugins and such.
>
> They don't do magic things but they mostly build, provide installation
> to specific place and optionally build the documentation and install
> them as well. This happens in my project. Since the project is
> extensible, I want to install the libraries **and** those macros so
> users will be able to use them so their plugins get installed in the
> correct place alongside the documentation without much effort.
>
> Example, the user will just write:
>
> irccd_define_plugin(
> SOURCES main.cpp
> DOCS myplugin.md
> )
>
> The problem with that macro, is that it has a conditional to build the
> documentation depending on an option. This is fine in my project since
> the user may build or not build the documentation by setting WITH_DOCS
> to Off.
> Now I wonder how I should handle this option when the macro is
> publicliy installed. The most problematic question is that variables do
> not have namespaces so if the user of my macro also have an option
> WITH_DOCS in its own CMakeLists.txt, this will interfer with the
> installed macro.
>
Add an optional BUILD_DOCS option parameter to your macro with default to
"False" if not present
so that user cannot call it without knowing.
i.e.
You will call:
irccd_define_plugin(
SOURCES main.cpp
DOCS myplugin.md
BUILD_DOCS ${WITH_DOC}
)
your user may safely call:
irccd_define_plugin(
SOURCES main.cpp
DOCS userplugin.md
)
Another option would be to carry "doc generation option" as a target level
custom property
you can attach to each target (exe, plugins , etc...) created by your macro.
Then your macro may decide to generate doc iff the chosen property is
defined on a per-target basis.
--
Eric
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake