[CMake] find_program doesn't use the PATH

Braden McDaniel braden at endoframe.com
Wed Jul 31 12:19:48 EDT 2019


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 <braden at endoframe.com>



More information about the CMake mailing list