@@ -51,19 +51,29 @@ function(convert_arduino_libraries_to_components)
51
51
endif ()
52
52
endforeach ()
53
53
54
+ # Start CMakeLists.txt generation
55
+ file (WRITE ${component_cmakelist} "idf_component_register(" )
56
+
54
57
# Sources are not compiled only if precompiled=full and precompiled library for our target exists
55
- file (WRITE ${component_cmakelist} "idf_component_register(SRCS " )
56
58
if (NOT precompiled STREQUAL "full" OR NOT EXISTS "${src_dir} /${IDF_TARGET} /lib${child} .a" )
59
+ file (APPEND ${component_cmakelist} "SRCS " )
57
60
file (GLOB_RECURSE src_files "${src_dir} /*.c" "${src_dir} /*.cpp" )
58
61
foreach (src_file ${src_files} )
59
62
string (REPLACE "${child_dir} /" "" src_file "${src_file} " )
60
63
file (APPEND ${component_cmakelist} "\" ${src_file} \" " )
61
64
endforeach ()
62
- else ()
63
- file (APPEND ${component_cmakelist} "\"\" " )
64
65
endif ()
66
+ # Add src folder to includes
67
+ file (APPEND ${component_cmakelist} "INCLUDE_DIRS \" src\" " )
68
+
69
+ # Add component requires
65
70
file (APPEND ${component_cmakelist} "PRIV_REQUIRES ${arduino_component_name} ${main_component_name} )\n " )
66
71
72
+ # Add any custom LD_FLAGS, if defined
73
+ if (NOT "${ldflags} " STREQUAL "" )
74
+ file (APPEND ${component_cmakelist} "target_link_libraries(\$ {COMPONENT_TARGET} INTERFACE \" ${ldflags} \" )\n " )
75
+ endif ()
76
+
67
77
# If this lib has precompiled libs and they match our target, get them
68
78
if ((precompiled STREQUAL "true" OR precompiled STREQUAL "full" ) AND IS_DIRECTORY "${src_dir} /${IDF_TARGET} " )
69
79
file (GLOB_RECURSE lib_files "${src_dir} /${IDF_TARGET} /lib*.a" )
@@ -73,14 +83,6 @@ function(convert_arduino_libraries_to_components)
73
83
endforeach ()
74
84
endif ()
75
85
76
- # Add src folder to includes
77
- file (APPEND ${component_cmakelist} "target_include_directories(\$ {COMPONENT_TARGET} PUBLIC \" src\" )\n " )
78
-
79
- # Add any custom LD_FLAGS, if defined
80
- if (NOT "${ldflags} " STREQUAL "" )
81
- file (APPEND ${component_cmakelist} "target_link_libraries(\$ {COMPONENT_TARGET} INTERFACE \" ${ldflags} \" )\n " )
82
- endif ()
83
-
84
86
message (STATUS "Created IDF component for ${child} " )
85
87
else ()
86
88
message (STATUS "Processing 1.0 compatible library '${child} ' in '${libs_dir_abs} '" )
@@ -102,18 +104,17 @@ function(convert_arduino_libraries_to_components)
102
104
endforeach ()
103
105
endif ()
104
106
105
- # Require arduino and main components to suceed in compilation
106
- file (APPEND ${component_cmakelist} "PRIV_REQUIRES ${arduino_component_name} ${main_component_name} )\n " )
107
-
108
107
# Add root folder to includes
109
- file (APPEND ${component_cmakelist} "target_include_directories( \$ {COMPONENT_TARGET} PUBLIC \" .\" " )
108
+ file (APPEND ${component_cmakelist} "INCLUDE_DIRS \" .\" " )
110
109
111
110
# Add the utility folder to includes if it exists
112
111
if (IS_DIRECTORY "${utility_dir} " )
113
- file (APPEND ${component_cmakelist} " \" utility\" " )
112
+ file (APPEND ${component_cmakelist} "\" utility\" " )
114
113
endif ()
114
+
115
+ # Require arduino and main components to suceed in compilation
116
+ file (APPEND ${component_cmakelist} "PRIV_REQUIRES ${arduino_component_name} ${main_component_name} )\n " )
115
117
116
- file (APPEND ${component_cmakelist} ")\n " )
117
118
message (STATUS "Created IDF component for ${child} " )
118
119
endif ()
119
120
else ()
0 commit comments