Merge branch 'feature/add_subdirectory_if_exists' into 'master'
cmake: add subdirectory if exists utility See merge request espressif/esp-idf!7302
This commit is contained in:
commit
dc63badbd2
|
@ -302,4 +302,17 @@ function(file_generate output)
|
||||||
|
|
||||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${output}")
|
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES "${output}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# add_subdirectory_if_exists
|
||||||
|
#
|
||||||
|
# Like add_subdirectory, but only proceeds if the given source directory exists.
|
||||||
|
function(add_subdirectory_if_exists source_dir)
|
||||||
|
get_filename_component(abs_dir "${source_dir}"
|
||||||
|
ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
|
if(EXISTS "${abs_dir}")
|
||||||
|
add_subdirectory("${source_dir}" ${ARGN})
|
||||||
|
else()
|
||||||
|
message(STATUS "Subdirectory '${abs_dir}' does not exist, skipped.")
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
Loading…
Reference in a new issue