Add wrapper function for setting CMake compiler launcher. Also adds a missing function doc comment. Change-Id: I0ff00cb326709134259b0aecc6b60046f209d2a8
diff --git a/build/cmake/aom_configure.cmake b/build/cmake/aom_configure.cmake index f306c8c..f7c18d0 100644 --- a/build/cmake/aom_configure.cmake +++ b/build/cmake/aom_configure.cmake
@@ -149,33 +149,15 @@ include("${AOM_ROOT}/build/cmake/cpu.cmake") if (ENABLE_CCACHE) - find_program(CCACHE "ccache") - if (NOT "${CCACHE}" STREQUAL "") - set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE}") - set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE}") - else () - message("--- Cannot find ccache, ENABLE_CCACHE ignored.") - endif () + set_compiler_launcher(ENABLE_CCACHE ccache) endif () if (ENABLE_DISTCC) - find_program(DISTCC "distcc") - if (NOT "${DISTCC}" STREQUAL "") - set(CMAKE_C_COMPILER_LAUNCHER "${DISTCC}") - set(CMAKE_CXX_COMPILER_LAUNCHER "${DISTCC}") - else () - message("--- Cannot find distcc, ENABLE_DISTCC ignored.") - endif () + set_compiler_launcher(ENABLE_DISTCC distcc) endif () if (ENABLE_GOMA) - find_program(GOMACC "gomacc") - if (NOT "${GOMACC}" STREQUAL "") - set(CMAKE_C_COMPILER_LAUNCHER "${GOMACC}") - set(CMAKE_CXX_COMPILER_LAUNCHER "${GOMACC}") - else () - message("--- Cannot find gomacc, ENABLE_GOMA ignored.") - endif () + set_compiler_launcher(ENABLE_GOMA gomacc) endif () if (NOT CONFIG_AV1_DECODER AND NOT CONFIG_AV1_ENCODER)
diff --git a/build/cmake/util.cmake b/build/cmake/util.cmake index 7d2b6c0..786e342 100644 --- a/build/cmake/util.cmake +++ b/build/cmake/util.cmake
@@ -24,6 +24,8 @@ set(${out_file_path} ${dummy_source_file} PARENT_SCOPE) endfunction () +# Convenience function for adding a dummy source file to $target_name using +# $extension as the file extension. Wraps create_dummy_source_file(). function (add_dummy_source_file_to_target target_name extension) create_dummy_source_file("${target_name}" "${extension}" "dummy_source_file") target_sources(${target_name} PRIVATE ${dummy_source_file}) @@ -45,5 +47,20 @@ message(WARNING "--- ${warning_message}") endfunction () +# Sets CMake compiler launcher to $launcher_name when $launcher_name is found in +# $PATH. Warns user about ignoring build flag $launcher_flag when $launcher_name +# is not found in $PATH. +function (set_compiler_launcher launcher_flag launcher_name) + find_program(launcher_path "${launcher_name}") + if (launcher_path) + set(CMAKE_C_COMPILER_LAUNCHER "${launcher_path}" PARENT_SCOPE) + set(CMAKE_CXX_COMPILER_LAUNCHER "${launcher_path}" PARENT_SCOPE) + message("--- Using ${launcher_name} as compiler launcher.") + else () + message(WARNING + "--- Cannot find ${launcher_name}, ${launcher_flag} ignored.") + endif () +endfunction () + endif() # AOM_BUILD_CMAKE_UTIL_CMAKE_