[CMake] How to Determine If a Perl Module Is Installed?

Bruce Stephens bruce.r.stephens at gmail.com
Mon May 23 18:56:15 EDT 2016


On Mon, May 23, 2016 at 11:30 PM, Eric Eide <eeide at cs.utah.edu> wrote:
> Hi!  I am a CMake newbie, and I have a question about examining the set of
> available Perl modules on a system.
>
> In CMake (version 2.8.12+), how can I test for the presence of a particular
> Perl module, e.g., "Sys::CPU"?

I think use execute_process to execute a command like

   perl -MSys::CPU -e ""

So, something like

execute_process(COMMAND ${PERL_EXECUTABLE} -MSys::CPU -e ""
     ERROR_QUIET RESULT_VARIABLE status)

if ${status} is zero then the module exists, otherwise it doesn't. You
can wrap it in a function,
obviously.


More information about the CMake mailing list