find_program doesn't use the PATH

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

find_program doesn't use the PATH

braden
I was tempted to go ahead and file a bug on this; but it seems so basic
that I figure I must be missing something.

Per the documentation for find_program:

   If NO_DEFAULT_PATH is not specified, the search process is as
   follows:
   ⋮
   5. Search the standard system environment variables. This can be
   skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.
    * PATH
That indicates to me that for "find_program(PROG_VAR NAME foo)", CMake
ought to find "foo" if "foo" is in the PATH. That doesn't seem to be
the case, though. A concrete example:

   cmake_minimum_required(VERSION 3.0)
   cmake_policy(SET CMP0048 NEW)
   project("hello" VERSION 0.1.0 LANGUAGES C)
   find_program(GETTEXT_MSGMERGE_EXECUTABLE NAME msgmerge)
   message(STATUS "GETTEXT_MSGMERGE_EXECUTABLE = ${GETTEXT_MSGMERGE_EXECUTABLE}")
   add_executable(hello hello.c)

This outputs:

   $ cmake -G "Unix Makefiles" ~/src/hello
   -- GETTEXT_MSGMERGE_EXECUTABLE = GETTEXT_MSGMERGE_EXECUTABLE-NOTFOUND
   -- Configuring done
   -- Generating done
   -- Build files have been written to: /home/mcdanb/build/hello
   $ which msgmerge
   /usr/bin/msgmerge

I am using CMake 3.14.5.

Have I misunderstood the documentation on this point?
 
--
Braden McDaniel <[hidden email]>

--

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
--
Braden McDaniel <braden@endoframe.com>
Reply | Threaded
Open this post in threaded view
|

Re: find_program doesn't use the PATH

Kornel Benko
Am Mittwoch, 31. Juli 2019, 12:19:48 CEST schrieb Braden McDaniel:

> I was tempted to go ahead and file a bug on this; but it seems so basic
> that I figure I must be missing something.
>
> Per the documentation for find_program:
>
>    If NO_DEFAULT_PATH is not specified, the search process is as
>    follows:
>    ⋮
>    5. Search the standard system environment variables. This can be
>    skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.
>     * PATH
> That indicates to me that for "find_program(PROG_VAR NAME foo)", CMake
> ought to find "foo" if "foo" is in the PATH. That doesn't seem to be
> the case, though. A concrete example:
>
>    cmake_minimum_required(VERSION 3.0)
>    cmake_policy(SET CMP0048 NEW)
>    project("hello" VERSION 0.1.0 LANGUAGES C)
>    find_program(GETTEXT_MSGMERGE_EXECUTABLE NAME msgmerge)
The find_program() is searching something like "/usr/bin/NAME". "NAME" should be a placeholder.
What you had in mind was probably the second form
        find_program(GETTEXT_MSGMERGE_EXECUTABLE NAMES msgmerge)
Mark the string "NAMES".


        Kornel
--

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

signature.asc (484 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: find_program doesn't use the PATH

braden
On Wed, 2019-07-31 at 20:32 +0200, Kornel Benko wrote:
> The find_program() is searching something like "/usr/bin/NAME".
> "NAME" should be a placeholder.
> What you had in mind was probably the second form
> find_program(GETTEXT_MSGMERGE_EXECUTABLE NAMES msgmerge)
> Mark the string "NAMES".

Oh, good grief.  Sigh.  Thanks for catching that.

--
Braden McDaniel <[hidden email]>

--

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
--
Braden McDaniel <braden@endoframe.com>