From 9df487eef56e20a4d1805cedfdddebb049af5012 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 25 Jan 2022 02:15:38 +0000 Subject: [PATCH 1/3] zephyr/cmake: remove obsolete cmake 3.12 version test Zephyr requires CMake 3.21 and SOF requires 3.13, see commit a0acad341455 ("CMake: require version 3.13") Fixes commit 4b2edf8eed56 ("zephyr: wrapper: complete zephyr support for working audio") Signed-off-by: Marc Herbert --- zephyr/CMakeLists.txt | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index b27109c4aa5f..4375266c9701 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -728,16 +728,8 @@ set(GENERATED_DIRECTORY ${PROJECT_BINARY_DIR}/include/generated) set(VERSION_H_PATH ${GENERATED_DIRECTORY}/sof_versions.h) -if(${CMAKE_VERSION} VERSION_LESS "3.12.0") - # FindPythonInterp is bugged and may sometimes be unable to find - # Python 3 when both Python 2 & 3 are in PATH, - # so it's always better to use CMake 3.12+ - find_package(PythonInterp 3.0) - set(PYTHON3 "${PYTHON_EXECUTABLE}") -else() - find_package(Python3 COMPONENTS Interpreter) - set(PYTHON3 "${Python3_EXECUTABLE}") -endif() +find_package(Python3 COMPONENTS Interpreter) +set(PYTHON3 "${Python3_EXECUTABLE}") # SOF uses GNU C99 extensions. TODO other flags required ? target_compile_options(SOF INTERFACE -std=gnu99 -fno-inline-functions) From a97b9b39a51fbff588b5ded410062d007b7bf90c Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 25 Jan 2022 01:45:32 +0000 Subject: [PATCH 2/3] cmake: simplify add_alsatplg2_command() macro alsatplg accepts empty definitions -D "" so let's simplify commit cb80023b229e ("topology2: fix build issues with no command line definitions"); 10 lines shorter. The less CMake code the better. Zero change, the build directory is bit for bit identical after this commit. Signed-off-by: Marc Herbert --- tools/topology/CMakeLists.txt | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/tools/topology/CMakeLists.txt b/tools/topology/CMakeLists.txt index b10b96ce02ce..fd2e0097e29f 100644 --- a/tools/topology/CMakeLists.txt +++ b/tools/topology/CMakeLists.txt @@ -30,32 +30,20 @@ endmacro() 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) + if (${ARGC} GREATER 3) + set (defines ${ARGV3}) + else() + set (defines "") endif() - if (defines STREQUAL "") - 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} -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 + 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() From ba040cf6c43950a329b3e014e167e5ff12ecbbf7 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Tue, 25 Jan 2022 02:01:12 +0000 Subject: [PATCH 3/3] cmake: move ALSA_CONFIG_DIR from .sh file to topology/CMakeLists.txt Fixes incremental builds of topology2 that were missing ALSA_CONFIG_DIR. This was making it impossible to troubleshoot alsatplg issues like #5249. Now incremental builds fail or pass the same as builds from scratch. Fixes commit 308a24a92b44 ("topology2: Add build support") Signed-off-by: Marc Herbert --- scripts/build-tools.sh | 1 - tools/topology/CMakeLists.txt | 3 ++- tools/topology/topology2/cavs/CMakeLists.txt | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/build-tools.sh b/scripts/build-tools.sh index 658c2ed58cae..434109aba869 100755 --- a/scripts/build-tools.sh +++ b/scripts/build-tools.sh @@ -6,7 +6,6 @@ set -e SOF_TOP=$(cd "$(dirname "$0")/.." && pwd) -export ALSA_CONFIG_DIR="${SOF_TOP}"/tools/topology/topology2 print_usage() { diff --git a/tools/topology/CMakeLists.txt b/tools/topology/CMakeLists.txt index fd2e0097e29f..4b7b36d1a2a1 100644 --- a/tools/topology/CMakeLists.txt +++ b/tools/topology/CMakeLists.txt @@ -41,7 +41,8 @@ macro(add_alsatplg2_command input_file output_file include_path) 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} + COMMAND ALSA_CONFIG_DIR=${CMAKE_SOURCE_DIR}/topology/topology2 alsatplg \$\${VERBOSE:+-v 1} + -I ${include_path} -D "'${defines}'" -p -c ${input_file} -o ${output_file} USES_TERMINAL ) endmacro() diff --git a/tools/topology/topology2/cavs/CMakeLists.txt b/tools/topology/topology2/cavs/CMakeLists.txt index 88c6ea9d7248..c4d5973da4af 100644 --- a/tools/topology/topology2/cavs/CMakeLists.txt +++ b/tools/topology/topology2/cavs/CMakeLists.txt @@ -37,6 +37,9 @@ foreach(tplg ${TPLGS}) endif() # copy ABI and input conf file contents + # + # BUG: move this from CMake configuration time to build time to + # fix incremental builds configure_file(${CMAKE_CURRENT_BINARY_DIR}/../abi.conf ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${input}.conf CONTENTS) file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf "${CONTENTS}")