This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
     new 61185b81 Fix CMake project name
61185b81 is described below

commit 61185b818d593687198099b302e660f67dfd10a8
Author: Andrzej Kaczmarek <[email protected]>
AuthorDate: Thu Nov 21 12:31:37 2024 +0100

    Fix CMake project name
    
    This fixes project name to use both project name and target name to
    avoid confusion in case there are multiple projects with the same target
    name (e.g. CLion would list them with the same name on recent projects
    list).
---
 newt/builder/cmake.go | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/newt/builder/cmake.go b/newt/builder/cmake.go
index 67d44f6f..5182fc74 100644
--- a/newt/builder/cmake.go
+++ b/newt/builder/cmake.go
@@ -412,10 +412,10 @@ func CmakeCompilerWrite(w io.Writer, c 
*toolchain.Compiler) {
        fmt.Fprintln(w)
 }
 
-func CmakeHeaderWrite(w io.Writer, c *toolchain.Compiler, targetName string) {
+func CmakeHeaderWrite(w io.Writer, c *toolchain.Compiler, projectName string) {
        fmt.Fprintln(w, "cmake_minimum_required(VERSION 3.7)\n")
        CmakeCompilerWrite(w, c)
-       fmt.Fprintf(w, "project(%s VERSION 0.0.0 LANGUAGES C CXX ASM)\n\n", 
targetName)
+       fmt.Fprintf(w, "project(%s VERSION 0.0.0 LANGUAGES C CXX ASM)\n\n", 
projectName)
        fmt.Fprintln(w, "SET(CMAKE_C_FLAGS_BACKUP  \"${CMAKE_C_FLAGS}\")")
        fmt.Fprintln(w, "SET(CMAKE_CXX_FLAGS_BACKUP  \"${CMAKE_CXX_FLAGS}\")")
        fmt.Fprintln(w, "SET(CMAKE_ASM_FLAGS_BACKUP  \"${CMAKE_ASM_FLAGS}\")")
@@ -442,7 +442,11 @@ func CMakeTargetGenerate(target *target.Target) error {
                return err
        }
 
-       CmakeHeaderWrite(w, targetCompiler, target.ShortName())
+       var proj *project.Project
+       if proj, err = project.TryGetProject(); err != nil {
+               return err
+       }
+       CmakeHeaderWrite(w, targetCompiler, fmt.Sprintf("\"%s (%s)\"", 
proj.Name(), target.ShortName()))
 
        if err := targetBuilder.CMakeTargetBuilderWrite(w, targetCompiler); err 
!= nil {
                return err

Reply via email to