[cmake-developers] Best practice for providing inputs to find modules

Brad King brad.king at kitware.com
Mon Aug 21 07:47:10 EDT 2017


On 08/17/2017 12:20 PM, Anh Huynh wrote:
> If I want the user to provide inputs to select GPU targets
[snip]> Should I have the user set a definition before using find_package> and checking for that definition?

Yes.  Document it as an input variable that can be set prior to the
call.  Either the calling package or even the end user running CMake
could set it.

> Should I simply have the user add the relevant flags themselves?
Ideally not.  The caller of find_package(OpenACC) is always free
to ignore your results and add its own flags.  It shouldn't have to
know all the flags for various toolchains.

> Should I provide some variable that would contain the correct flag> so the user can use it to append to his flags?
Yes.  The caller of find_package(OpenACC) should use the variable
to add the flags to relevant parts of the project.

-Brad


More information about the cmake-developers mailing list