-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
50 lines (49 loc) · 2.33 KB
/
CMakeLists.txt
File metadata and controls
50 lines (49 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# ==============================================================================
# ESP-IDF Component Configuration for Swift-Based Applications
# ==============================================================================
# This CMakeLists.txt configures the "main" component of an ESP-IDF project
# that uses Embedded Swift instead of traditional C/C++.
# ==============================================================================
# ------------------------------------------------------------------------------
# Step 1: Register the component with ESP-IDF
# ------------------------------------------------------------------------------
# idf_component_register() tells the build system about this component's files
# and dependencies. Even though we're using Swift, we still need to register
# as an IDF component.
#
# Parameters:
# SRCS: C/C++ source files to compile.
# PRIV_INCLUDE_DIRS: Private header directories for this component only.
# Set to "." so the BridgingHeader.h can be found.
# PRIV_REQUIRES: Components this component depends on (linked privately):
# - swift: Provides Embedded Swift runtime and compilation support
# - esp_driver_gpio: ESP-IDF GPIO driver for controlling hardware pins
#
# IMPORTANT: All dependencies must be explicitly listed.
if(WIN32)
set(devnull NUL)
else()
set(devnull /dev/null)
endif()
idf_component_register(
SRCS ${devnull}
PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES swift esp_driver_gpio
)
# ------------------------------------------------------------------------------
# Step 2: Configure Embedded Swift compilation
# ------------------------------------------------------------------------------
# idf_component_register_swift() is a custom function (provided by the 'swift'
# component) that configures the Swift compiler for embedded systems.
#
# Parameters:
# ${COMPONENT_LIB}: The CMake library target created by idf_component_register()
# (automatically available after registration)
# BRIDGING_HEADER: C header file that exposes C APIs to Swift code.
# This allows Swift to call ESP-IDF C functions.
# SRCS: Swift source files to compile. List all .swift files in your project.
idf_component_register_swift(
${COMPONENT_LIB}
BRIDGING_HEADER ${CMAKE_CURRENT_LIST_DIR}/BridgingHeader.h
SRCS Main.swift LedStrip.swift
)