You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/04/04 02:25:21 UTC

[GitHub] sterlinghughes closed pull request #152: builder/cmake: Native linker fixes

sterlinghughes closed pull request #152: builder/cmake: Native linker fixes
URL: https://github.com/apache/mynewt-newt/pull/152
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/newt/builder/cmake.go b/newt/builder/cmake.go
index 4d02fcb5..92ed7b8f 100644
--- a/newt/builder/cmake.go
+++ b/newt/builder/cmake.go
@@ -27,11 +27,12 @@ import (
 	"os"
 	"strings"
 
+	"path/filepath"
+
 	"mynewt.apache.org/newt/newt/project"
 	"mynewt.apache.org/newt/newt/target"
 	"mynewt.apache.org/newt/newt/toolchain"
 	"mynewt.apache.org/newt/util"
-	"path/filepath"
 )
 
 const CMAKELISTS_FILENAME string = "CMakeLists.txt"
@@ -150,6 +151,7 @@ func (b *Builder) CMakeTargetWrite(w io.Writer, targetCompiler *toolchain.Compil
 		lFlags = append(lFlags, "-T"+ld)
 	}
 
+	lFlags = append(lFlags, c.GetLocalCompilerInfo().Cflags...)
 	fmt.Fprintf(w, `
 	set_target_properties(%s
 							PROPERTIES
@@ -166,9 +168,26 @@ func (b *Builder) CMakeTargetWrite(w io.Writer, targetCompiler *toolchain.Compil
 
 	fmt.Fprintln(w)
 
+	libs := strings.Join(getLibsFromLinkerFlags(lFlags), " ")
+	fmt.Fprintf(w, "# Workaround for gcc linker woes\n")
+	fmt.Fprintf(w, "set(CMAKE_C_LINK_EXECUTABLE \"${CMAKE_C_LINK_EXECUTABLE} %s\")\n", libs)
+	fmt.Fprintln(w)
+
 	return nil
 }
 
+func getLibsFromLinkerFlags(lflags []string) []string {
+	libs := []string{}
+
+	for _, flag := range lflags {
+		if strings.HasPrefix(flag, "-l") {
+			libs = append(libs, flag)
+		}
+	}
+
+	return libs
+}
+
 func CmakeCompilerInfoWrite(w io.Writer, archiveFile string, bpkg *BuildPackage, cj toolchain.CompilerJob) {
 	c := cj.Compiler
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services