forked from espressif/esp-idf
Merge branch 'contrib/github_pr_15308' into 'master'
fix(cmake): support CMock subdir option with idf_component_mock (GitHub PR) Closes IDFGH-14547 and IDFGH-12326 See merge request espressif/esp-idf!36761
This commit is contained in:
@@ -542,10 +542,11 @@ endfunction()
|
|||||||
# to be passed here, too.
|
# 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] 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] 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)
|
function(idf_component_mock)
|
||||||
set(options)
|
set(options)
|
||||||
set(single_value)
|
set(single_value MOCK_SUBDIR)
|
||||||
set(multi_value MOCK_HEADER_FILES INCLUDE_DIRS REQUIRES)
|
set(multi_value MOCK_HEADER_FILES INCLUDE_DIRS REQUIRES)
|
||||||
cmake_parse_arguments(_ "${options}" "${single_value}" "${multi_value}" ${ARGN})
|
cmake_parse_arguments(_ "${options}" "${single_value}" "${multi_value}" ${ARGN})
|
||||||
|
|
||||||
@@ -561,8 +562,13 @@ function(idf_component_mock)
|
|||||||
|
|
||||||
foreach(header_file ${__MOCK_HEADER_FILES})
|
foreach(header_file ${__MOCK_HEADER_FILES})
|
||||||
get_filename_component(file_without_dir ${header_file} NAME_WE)
|
get_filename_component(file_without_dir ${header_file} NAME_WE)
|
||||||
|
if("${__MOCK_SUBDIR}" STREQUAL "")
|
||||||
list(APPEND MOCK_GENERATED_HEADERS "${MOCK_GEN_DIR}/mocks/Mock${file_without_dir}.h")
|
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")
|
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()
|
endforeach()
|
||||||
|
|
||||||
file(MAKE_DIRECTORY "${MOCK_GEN_DIR}/mocks")
|
file(MAKE_DIRECTORY "${MOCK_GEN_DIR}/mocks")
|
||||||
|
Reference in New Issue
Block a user