forked from espressif/esp-idf
fix(cmake): Support CMock subdir option with idf_component_mock
Closes https://github.com/espressif/esp-idf/pull/15308 Closes https://github.com/espressif/esp-idf/issues/13360
This commit is contained in:
committed by
Konstantin Kondrashov
parent
5a0e1615d9
commit
0b8ecbb03a
@@ -542,10 +542,11 @@ endfunction()
|
||||
# to be passed here, too.
|
||||
# @param[in, optional] MOCK_HEADER_FILES (multivalue) list of header files from which the mocks shall be generated.
|
||||
# @param[in, optional] REQUIRES (multivalue) any other components required by the mock component.
|
||||
# @param[in, optional] MOCK_SUBDIR (singlevalue) tells cmake where are the CMock generated c files.
|
||||
#
|
||||
function(idf_component_mock)
|
||||
set(options)
|
||||
set(single_value)
|
||||
set(single_value MOCK_SUBDIR)
|
||||
set(multi_value MOCK_HEADER_FILES INCLUDE_DIRS REQUIRES)
|
||||
cmake_parse_arguments(_ "${options}" "${single_value}" "${multi_value}" ${ARGN})
|
||||
|
||||
@@ -561,8 +562,13 @@ function(idf_component_mock)
|
||||
|
||||
foreach(header_file ${__MOCK_HEADER_FILES})
|
||||
get_filename_component(file_without_dir ${header_file} NAME_WE)
|
||||
list(APPEND MOCK_GENERATED_HEADERS "${MOCK_GEN_DIR}/mocks/Mock${file_without_dir}.h")
|
||||
list(APPEND MOCK_GENERATED_SRCS "${MOCK_GEN_DIR}/mocks/Mock${file_without_dir}.c")
|
||||
if("${__MOCK_SUBDIR}" STREQUAL "")
|
||||
list(APPEND MOCK_GENERATED_HEADERS "${MOCK_GEN_DIR}/mocks/Mock${file_without_dir}.h")
|
||||
list(APPEND MOCK_GENERATED_SRCS "${MOCK_GEN_DIR}/mocks/Mock${file_without_dir}.c")
|
||||
else()
|
||||
list(APPEND MOCK_GENERATED_HEADERS "${MOCK_GEN_DIR}/mocks/${__MOCK_SUBDIR}/Mock${file_without_dir}.h")
|
||||
list(APPEND MOCK_GENERATED_SRCS "${MOCK_GEN_DIR}/mocks/${__MOCK_SUBDIR}/Mock${file_without_dir}.c")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(MAKE_DIRECTORY "${MOCK_GEN_DIR}/mocks")
|
||||
|
Reference in New Issue
Block a user