diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dda22470e38..96746a4d7c94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,9 @@ set(SOF_ROOT_BINARY_DIRECTORY "${PROJECT_BINARY_DIR}") # check git hooks include(scripts/cmake/git-hooks.cmake) +# checkout submodules +include(scripts/cmake/git-submodules.cmake) + # most of other options are set on per-arch and per-target basis set(CMAKE_ASM_FLAGS -DASSEMBLY) @@ -55,6 +58,7 @@ set(CMAKE_ASM_FLAGS -DASSEMBLY) add_library(sof_public_headers INTERFACE) target_include_directories(sof_public_headers INTERFACE ${PROJECT_SOURCE_DIR}/src/include) +target_include_directories(sof_public_headers INTERFACE ${PROJECT_SOURCE_DIR}/rimage/src/include/sof) # interface library that is used only as container for sof binary options # other targets can use it to build with the same options @@ -162,6 +166,8 @@ install( ${PROJECT_SOURCE_DIR}/src/include/ipc ${PROJECT_SOURCE_DIR}/src/include/kernel ${PROJECT_SOURCE_DIR}/src/include/user + ${PROJECT_SOURCE_DIR}/rimage/src/include/sof/kernel + ${PROJECT_SOURCE_DIR}/rimage/src/include/sof/user DESTINATION include/sof PATTERN "*.h" ) diff --git a/scripts/cmake/git-submodules.cmake b/scripts/cmake/git-submodules.cmake new file mode 100644 index 000000000000..dc27797637e5 --- /dev/null +++ b/scripts/cmake/git-submodules.cmake @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: BSD-3-Clause + +find_package(Git) +if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + # Update submodules by default + option(GIT_SUBMODULE "Check submodules during build" ON) + + if(GIT_SUBMODULE) + message(STATUS "Git submodule update") + + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMOD_RESULT) + + if(NOT GIT_SUBMOD_RESULT EQUAL "0") + message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") + endif() + endif() +endif() + +if(NOT EXISTS "${PROJECT_SOURCE_DIR}/rimage/CMakeLists.txt") + message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") +endif()