CMake find_program script

CMake find_program does not generally consider NAMES parameter to have file suffixes unless manually specified. A special case is Windows, where .com and .exe file suffixes are also considered.

If on Windows and an executable “hello.exe” or “” exists, then CMake will find it. CMake would NOT find “hello.exe” on non-Windows platforms, where no file suffix is expected.

NOTE: CMAKE_EXECUTABLE_SUFFIX ONLY affects find_program() in CMake role PROJECT

find_program(v NAMES hello)

Shell scripts of any file suffix on any operating system are found iff:

  1. script file executable flag is set (find_program general requirement)
  2. script file suffix is specified as part of NAMES parameter

A complete standalone example: