idf_component_register( SRCS "Dummy.c" INCLUDE_DIRS "." ) execute_process(COMMAND xcrun -f swiftc OUTPUT_VARIABLE SWIFTC OUTPUT_STRIP_TRAILING_WHITESPACE) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_swiftcode.o COMMAND ${SWIFTC} -target riscv32-none-none-eabi -Xfrontend -function-sections -enable-experimental-feature Embedded -wmo -parse-as-library -Osize $$\( echo '$' | tr '\;' '\\n' | sed -e 's/\\\(.*\\\)/-Xcc -I\\1/g' \) $$\( echo '${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}' | tr ' ' '\\n' | sed -e 's/\\\(.*\\\)/-Xcc -I\\1/g' \) -import-bridging-header ${CMAKE_CURRENT_LIST_DIR}/BridgingHeader.h ${CMAKE_CURRENT_LIST_DIR}/Main.swift -c -o ${CMAKE_CURRENT_BINARY_DIR}/_swiftcode.o DEPENDS ${CMAKE_CURRENT_LIST_DIR}/BridgingHeader.h ${CMAKE_CURRENT_LIST_DIR}/Main.swift ) add_custom_target(main-swiftcode DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/_swiftcode.o) target_link_libraries(${COMPONENT_LIB} ${CMAKE_CURRENT_BINARY_DIR}/_swiftcode.o ) add_dependencies(${COMPONENT_LIB} main-swiftcode)