Skip to content

Commit

Permalink
Fix CMake project name
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
andrzej-kaczmarek committed Nov 21, 2024
1 parent c6bf556 commit c9d85e3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions newt/builder/cmake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}\")")
Expand All @@ -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
Expand Down

0 comments on commit c9d85e3

Please sign in to comment.