diff --git a/tools/topology/CMakeLists.txt b/tools/topology/CMakeLists.txt index b0a844aa489e..e9453654aa11 100644 --- a/tools/topology/CMakeLists.txt +++ b/tools/topology/CMakeLists.txt @@ -1,5 +1,32 @@ set(SOF_TOPOLOGY_BINARY_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +# This use of VERBOSE relies on original CMake behavior. +# From the add_custom_command() manual: +# +# Use of VERBATIM is recommended as it enables correct behavior. +# When VERBATIM is not given the behavior is platform specific because +# there is no protection of tool-specific special characters. +# +# This is fine because: +# - We don't expect alsatplg to work on Windows any time soon. +# - CMake is too afraid to remove the original, no-VERBATIM behavior: +# https://gitlab.kitware.com/cmake/cmake/issues/18849 +# +# Also note that in alsa-utils commit v1.2.2~15-gcbabe7a3f0cc, alsatplg +# (accidentally?) started ignoring the verbosity level, now it's just +# verbose or not. +macro(add_alsatplg_command) + add_custom_command( + MAIN_DEPENDENCY ${ARGV0} + OUTPUT ${ARGV1} + # Use a redirection to work around hardcoded alsatplg permissions, + # see bug https://github.com/alsa-project/alsa-utils/issues/126 + COMMAND alsatplg \$\${VERBOSE:+-v 1} -c ${ARGV0} -o - > ${ARGV1} + USES_TERMINAL + ) +endmacro() + + add_custom_target(topologies ALL) add_dependencies(topologies topologies1) diff --git a/tools/topology/topology1/CMakeLists.txt b/tools/topology/topology1/CMakeLists.txt index 16034f1d080f..f4648f9ef47c 100644 --- a/tools/topology/topology1/CMakeLists.txt +++ b/tools/topology/topology1/CMakeLists.txt @@ -239,27 +239,7 @@ foreach(tplg ${TPLGS}) USES_TERMINAL ) -# This use of VERBOSE relies on original CMake behavior. -# From the add_custom_command() manual: -# -# Use of VERBATIM is recommended as it enables correct behavior. -# When VERBATIM is not given the behavior is platform specific because -# there is no protection of tool-specific special characters. -# -# This is fine because: -# - We don't expect alsatplg to work on Windows any time soon. -# - CMake is too afraid to remove the original, no-VERBATIM behavior: -# https://gitlab.kitware.com/cmake/cmake/issues/18849 -# -# Also note that in alsa-utils commit v1.2.2~15-gcbabe7a3f0cc, alsatplg -# (accidentally?) started ignoring the verbosity level, now it's just -# verbose or not. - add_custom_command( - OUTPUT production/${output}.tplg - COMMAND alsatplg \$\${VERBOSE:+-v 1} -c production/${output}.conf -o production/${output}.tplg - MAIN_DEPENDENCY production/${output}.conf - USES_TERMINAL - ) + add_alsatplg_command(production/${output}.conf production/${output}.tplg) add_custom_target(topology1_${output} DEPENDS production/${output}.tplg) add_dependencies(topologies1 topology1_${output}) diff --git a/tools/topology/topology1/development/CMakeLists.txt b/tools/topology/topology1/development/CMakeLists.txt index def451d98c3f..ae667b33e4b4 100644 --- a/tools/topology/topology1/development/CMakeLists.txt +++ b/tools/topology/topology1/development/CMakeLists.txt @@ -79,27 +79,7 @@ foreach(tplg ${TPLGS}) USES_TERMINAL ) -# This use of VERBOSE relies on original CMake behavior. -# From the add_custom_command() manual: -# -# Use of VERBATIM is recommended as it enables correct behavior. -# When VERBATIM is not given the behavior is platform specific because -# there is no protection of tool-specific special characters. -# -# This is fine because: -# - We don't expect alsatplg to work on Windows any time soon. -# - CMake is too afraid to remove the original, no-VERBATIM behavior: -# https://gitlab.kitware.com/cmake/cmake/issues/18849 -# -# Also note that in alsa-utils commit v1.2.2~15-gcbabe7a3f0cc, alsatplg -# (accidentally?) started ignoring the verbosity level, now it's just -# verbose or not. - add_custom_command( - OUTPUT ${output}.tplg - COMMAND alsatplg \$\${VERBOSE:+-v 1} -c ${output}.conf -o ${output}.tplg - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf - USES_TERMINAL - ) + add_alsatplg_command(${output}.conf ${output}.tplg) add_custom_target(topology_${output} DEPENDS ${output}.tplg) add_dependencies(dev_topologies1 topology_${output}) @@ -134,12 +114,7 @@ foreach(tplg ${TPLGS_UP}) VERBATIM USES_TERMINAL ) - add_custom_command( - OUTPUT ${output}.tplg - COMMAND alsatplg \$\${VERBOSE:+-v 1} -c ${output}.conf -o ${output}.tplg - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf - USES_TERMINAL - ) + add_alsatplg_command(${output}.conf ${output}.tplg) add_custom_target(topology_${output} DEPENDS ${output}.tplg) add_dependencies(dev_topologies1 topology_${output}) diff --git a/tools/topology/topology1/dsp_enhancement/CMakeLists.txt b/tools/topology/topology1/dsp_enhancement/CMakeLists.txt index 42af1acc13e3..9399b48e5c21 100644 --- a/tools/topology/topology1/dsp_enhancement/CMakeLists.txt +++ b/tools/topology/topology1/dsp_enhancement/CMakeLists.txt @@ -39,27 +39,7 @@ foreach(tplg ${TPLGS_UP}) USES_TERMINAL ) -# This use of VERBOSE relies on original CMake behavior. -# From the add_custom_command() manual: -# -# Use of VERBATIM is recommended as it enables correct behavior. -# When VERBATIM is not given the behavior is platform specific because -# there is no protection of tool-specific special characters. -# -# This is fine because: -# - We don't expect alsatplg to work on Windows any time soon. -# - CMake is too afraid to remove the original, no-VERBATIM behavior: -# https://gitlab.kitware.com/cmake/cmake/issues/18849 -# -# Also note that in alsa-utils commit v1.2.2~15-gcbabe7a3f0cc, alsatplg -# (accidentally?) started ignoring the verbosity level, now it's just -# verbose or not. - add_custom_command( - OUTPUT ${output}.tplg - COMMAND alsatplg \$\${VERBOSE:+-v 1} -c ${output}.conf -o ${output}.tplg - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf - USES_TERMINAL - ) + add_alsatplg_command(${output}.conf ${output}.tplg) add_custom_target(topology_${output} DEPENDS ${output}.tplg) add_dependencies(dsp_topologies1 topology_${output})