diff --git a/components/esp_modem/CMakeLists.txt b/components/esp_modem/CMakeLists.txt index 5d9edf0d4..33ed9cd5c 100644 --- a/components/esp_modem/CMakeLists.txt +++ b/components/esp_modem/CMakeLists.txt @@ -40,6 +40,11 @@ set(srcs ${platform_srcs} "src/esp_modem_vfs_socket_creator.cpp" "${command_dir}/src/esp_modem_modules.cpp") +if(IDF_BUILD_V2) + include(CMakeLists_v2.txt) + return() +endif() + idf_component_register(SRCS "${srcs}" INCLUDE_DIRS include ${command_dir}/include PRIV_INCLUDE_DIRS private_include diff --git a/components/esp_modem/CMakeLists_v2.txt b/components/esp_modem/CMakeLists_v2.txt new file mode 100644 index 000000000..9f415105a --- /dev/null +++ b/components/esp_modem/CMakeLists_v2.txt @@ -0,0 +1,37 @@ +# --- IDF Build System V2 Integration --- +# Initialize lists before use to avoid inheriting variables from +# a parent component scope (recursive evaluation in v2). +set(public_deps) +set(optional_deps) + +foreach(dep IN LISTS dependencies) + idf_component_include(${dep}) + list(APPEND public_deps idf::${dep}) +endforeach() + +add_library(${COMPONENT_TARGET} STATIC ${srcs}) + +target_include_directories(${COMPONENT_TARGET} + PUBLIC + include + ${command_dir}/include + PRIVATE + private_include +) + +target_link_libraries(${COMPONENT_TARGET} PUBLIC ${public_deps}) + +target_compile_features(${COMPONENT_TARGET} PUBLIC cxx_std_17) +set_target_properties(${COMPONENT_TARGET} PROPERTIES + CXX_EXTENSIONS ON +) + +# Optional dependency on "main" when custom module is enabled. +# Use TARGET_EXISTS generator expression so the link is a no-op when +# "main" is not part of the build (v2 makes all Kconfig visible, so +# CONFIG_ESP_MODEM_ADD_CUSTOM_MODULE can be set even if "main" is absent). +if(CONFIG_ESP_MODEM_ADD_CUSTOM_MODULE) + idf_component_include(main) + target_link_libraries(${COMPONENT_TARGET} PUBLIC + "$<$:idf::main>") +endif()