Since upgrading minimum CMake version to 3.22.1 (commit 469d82a1), we can
now use find_program(REQUIRED) which was introduced in CMake 3.18.
This change replaces manual FATAL_ERROR checks with the REQUIRED option
and adds it to programs that are actually needed during the build. This
ensures the build fails early during configuration rather than later
during compilation when missing programs are invoked.
Changes:
- Replace find_program() + message(FATAL_ERROR) patterns with REQUIRED
- Add REQUIRED to programs that are used during build but previously
had no error checking
Reference: https://cmake.org/cmake/help/latest/command/find_program.html
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
17 lines
655 B
CMake
17 lines
655 B
CMake
function(find_make make_exe make_cmd)
|
|
# make_exe the name of the variable whose value will be the path to "make"
|
|
# executable
|
|
# make_cmd the name of the variable whose value will be the command to
|
|
# used in the generated build script executed by the cmake generator
|
|
find_program(MAKE_EXECUTABLE
|
|
NAMES gmake make
|
|
REQUIRED)
|
|
set(${make_exe} "${MAKE_EXECUTABLE}" PARENT_SCOPE)
|
|
if(CMAKE_MAKE_PROGRAM MATCHES "make")
|
|
# try to inherit command line arguments passed by parent "make" job
|
|
set(${make_cmd} "$(MAKE)" PARENT_SCOPE)
|
|
else()
|
|
set(${make_cmd} "${MAKE_EXECUTABLE}" PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|