@@ -168,10 +168,12 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
168
168
// Add SO_PATHS option for libraries not getting found by pkg_config
169
169
cmakelist += "set(EXTRA_LIBS_DIRS \" \" CACHE STRING \" Additional paths for dynamic libraries\" )\n "
170
170
171
+ linkGroup := ""
171
172
for _ , lib := range libs {
172
173
// Dynamic libraries should be discovered by pkg_config
173
174
cmakelist += "pkg_search_module (" + strings .ToUpper (lib ) + " " + lib + ")\n "
174
175
relLinkDirectories = append (relLinkDirectories , "${" + strings .ToUpper (lib )+ "_LIBRARY_DIRS}" )
176
+ linkGroup += " " + lib
175
177
}
176
178
cmakelist += "link_directories (" + strings .Join (relLinkDirectories , " " ) + " ${EXTRA_LIBS_DIRS})\n "
177
179
for _ , staticLibsFile := range staticLibsFiles {
@@ -180,19 +182,20 @@ func (s *ExportProjectCMake) Run(ctx *types.Context) error {
180
182
lib = strings .TrimPrefix (lib , "lib" )
181
183
lib = strings .TrimSuffix (lib , ".a" )
182
184
if ! utils .SliceContains (libs , lib ) {
183
- libs = append ( libs , lib )
185
+ linkGroup += " " + lib
184
186
cmakelist += "add_library (" + lib + " STATIC IMPORTED)\n "
185
187
location := strings .TrimPrefix (staticLibsFile , cmakeFolder )
186
188
cmakelist += "set_property(TARGET " + lib + " PROPERTY IMPORTED_LOCATION " + "${PROJECT_SOURCE_DIR}" + location + " )\n "
187
189
}
188
190
}
191
+
189
192
// Include source files
190
193
// TODO: remove .cpp and .h from libraries example folders
191
194
cmakelist += "file (GLOB_RECURSE SOURCES core/*.c* lib/*.c* sketch/*.c*)\n "
192
195
193
196
// Compile and link project
194
197
cmakelist += "add_executable (" + projectName + " ${SOURCES} ${SOURCES_LIBS})\n "
195
- cmakelist += "target_link_libraries( " + projectName + " -Wl,--as-needed -Wl,--start-group " + strings . Join ( libs , " " ) + " -Wl,--end-group)\n "
198
+ cmakelist += "target_link_libraries( " + projectName + " -Wl,--as-needed -Wl,--start-group " + linkGroup + " -Wl,--end-group)\n "
196
199
197
200
utils .WriteFile (cmakeFile , cmakelist )
198
201
0 commit comments