Skip to content

Commit

Permalink
topology/cmake: move alsatplg_version() one level up
Browse files Browse the repository at this point in the history
We want to use it in topology1 too.

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb authored and kv2019i committed Oct 24, 2023
1 parent f8a202a commit d9fb722
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
25 changes: 25 additions & 0 deletions tools/topology/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
set(SOF_TOPOLOGY_BINARY_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")


function(alsatplg_version OUT_STATUS OUT_VERSION)
execute_process(COMMAND alsatplg --version
RESULT_VARIABLE status
OUTPUT_VARIABLE stdout
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(DEBUG "alsatplg --version: status=${status}, output=${stdout}")

set(${OUT_STATUS} "${status}" PARENT_SCOPE)

# Some error messages have already been printed on stderr
if(NOT status EQUAL 0)
message(WARNING "alsatplg --version returned status: ${status},
${stdout}")
return()
endif()

string(REPLACE "\n" ";" ALSA_VERSION_LIST ${stdout})
list(GET ALSA_VERSION_LIST 0 ALSATPLG_VERSION)
string(REGEX MATCH "[0-9]\.[0-9]\.*[0-9]*" ALSATPLG_VERSION_NUMBER ${ALSATPLG_VERSION})

set(${OUT_VERSION} "${ALSATPLG_VERSION_NUMBER}" PARENT_SCOPE)
endfunction()


# This use of VERBOSE relies on original CMake behavior.
# From the add_custom_command() manual:
#
Expand Down
24 changes: 0 additions & 24 deletions tools/topology/topology2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,6 @@ add_custom_target(topologies2)

# Check alsatplg version and build topology2 if alsatplg version is
# 1.2.7 or greater, see https://github.com/thesofproject/sof/issues/5323

function(alsatplg_version OUT_STATUS OUT_VERSION)
execute_process(COMMAND alsatplg --version
RESULT_VARIABLE status
OUTPUT_VARIABLE stdout
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(DEBUG "alsatplg --version: status=${status}, output=${stdout}")

set(${OUT_STATUS} "${status}" PARENT_SCOPE)

# Some error messages have already been printed on stderr
if(NOT status EQUAL 0)
message(WARNING "alsatplg --version returned status: ${status},
${stdout}")
return()
endif()

string(REPLACE "\n" ";" ALSA_VERSION_LIST ${stdout})
list(GET ALSA_VERSION_LIST 0 ALSATPLG_VERSION)
string(REGEX MATCH "[0-9]\.[0-9]\.*[0-9]*" ALSATPLG_VERSION_NUMBER ${ALSATPLG_VERSION})

set(${OUT_VERSION} "${ALSATPLG_VERSION_NUMBER}" PARENT_SCOPE)
endfunction()

alsatplg_version(STATUS ALSATPLG_VERSION_NUMBER)

if(NOT STATUS EQUAL 0)
Expand Down

0 comments on commit d9fb722

Please sign in to comment.