topology2: fix build issues with no command line definitions

If there are no command line definitions, the build fails because the
4th argument to the add_alsatplg2_command macro is NULL.

Fix this by using named arguments for the macro and checking for the
optional argument for command line definitions.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
This commit is contained in:
Ranjani Sridharan 2022-01-23 20:28:32 -08:00 committed by Liam Girdwood
parent 95d8e941cf
commit cb80023b22
2 changed files with 29 additions and 9 deletions

View File

@ -28,14 +28,34 @@ macro(add_alsatplg_command)
)
endmacro()
macro(add_alsatplg2_command)
macro(add_alsatplg2_command input_file output_file include_path)
# command line definitions are optional
set (defines "")
set (optional_args ${ARGN})
# Set defines if there is an optional argument
list(LENGTH optional_args optional_args_count)
if (${optional_args_count} GREATER 0)
list(GET optional_args 0 defines)
endif()
if (defines STREQUAL "")
add_custom_command(
MAIN_DEPENDENCY ${ARGV0}
OUTPUT ${ARGV1}
MAIN_DEPENDENCY ${input_file}
OUTPUT ${output_file}
# -p to pre-process Topology2.0 conf file
COMMAND alsatplg \$\${VERBOSE:+-v 1} -I ${ARGV2} -D ${ARGV3} -p -c ${ARGV0} -o ${ARGV1}
COMMAND alsatplg \$\${VERBOSE:+-v 1} -I ${include_path} -p -c ${input_file} -o ${output_file}
USES_TERMINAL
)
else()
add_custom_command(
MAIN_DEPENDENCY ${input_file}
OUTPUT ${output_file}
# -p to pre-process Topology2.0 conf file
COMMAND alsatplg \$\${VERBOSE:+-v 1} -I ${include_path} -D ${defines} -p -c ${input_file} -o ${output_file}
USES_TERMINAL
)
endif()
endmacro()

View File

@ -41,7 +41,7 @@ foreach(tplg ${TPLGS})
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${input}.conf CONTENTS)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf "${CONTENTS}")
add_alsatplg2_command(${output}.conf ${output}.tplg ${CMAKE_CURRENT_SOURCE_DIR} ${defines})
add_alsatplg2_command("${output}.conf" "${output}.tplg" "${CMAKE_CURRENT_SOURCE_DIR}" "${defines}")
add_custom_target(topology2_${output} DEPENDS ${output}.tplg)
add_dependencies(topology2_cavs topology2_${output})
endforeach()