How to Determine If a Perl Module Is Installed?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to Determine If a Perl Module Is Installed?

Eric Eide
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"?

At the time that CMake is run, I would like to check for the presence of
various Perl modules.  (These are Perl modules that will eventually be needed
when the programs in my project are run, but that are not needed to configure,
compile, or install my software as a whole.)  If a needed Perl module is not
available, I want to issue a CMake-time warning or error.

I've Googled around for an answer, and also looked in the archives of this list
for the past year, without finding an answer.  (This makes me wonder if my
question is somehow wrong-headed, since I would expect that checking for Perl
modules for be a fairly common thing to do!)

I am already using CMake's FindPerl module to find the Perl interpreter itself.

Thanks! ---

Eric.

--
-------------------------------------------------------------------------------
Eric Eide <[hidden email]>  .         University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX
--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to Determine If a Perl Module Is Installed?

Bruce Stephens
On Mon, May 23, 2016 at 11:30 PM, Eric Eide <[hidden email]> 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.
--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to Determine If a Perl Module Is Installed?

Eric Eide
Bruce Stephens <[hidden email]> writes:

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

Thank you very much for the tip!  The command above works very well for me.

As a CMake newbie, I was afraid that I was overlooking some sort of
"prepackaged" version of this.

Eric.

--
-------------------------------------------------------------------------------
Eric Eide <[hidden email]>  .         University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX
--

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:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How to Determine If a Perl Module Is Installed?

Bruce Stephens
On Tue, May 24, 2016 at 3:52 AM, Eric Eide <[hidden email]> wrote:

> As a CMake newbie, I was afraid that I was overlooking some sort of
> "prepackaged" version of this.

Doesn't look like it, but I agree it's the kind of thing that might be usefully
included with CMake.
--

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:
http://public.kitware.com/mailman/listinfo/cmake