11/*
2- * Copyright (c) 2024 Arm Limited. All rights reserved.
2+ * Copyright (c) 2024-2025 Arm Limited. All rights reserved.
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -9,19 +9,17 @@ package maker
99import (
1010 "path"
1111 "path/filepath"
12- "regexp"
1312 "strconv"
1413 "strings"
1514
1615 "github.com/Open-CMSIS-Pack/cbuild2cmake/pkg/utils"
1716 log "github.com/sirupsen/logrus"
1817)
1918
20- func (m * Maker ) CreateSuperCMakeLists () error {
21- csolution := filepath .Base (m .CbuildIndex .BuildIdx .Csolution )
22- reg := regexp .MustCompile (`(.*)\.csolution.ya?ml` )
23- csolution = reg .ReplaceAllString (csolution , "$1" )
19+ const CMAKE_MIN_REQUIRED = "3.27"
2420
21+ func (m * Maker ) CreateSuperCMakeLists () error {
22+ // Iterate over cbuilds
2523 var contexts , dirs , contextOutputs string
2624 for i , cbuild := range m .Cbuilds {
2725 contexts = contexts + " \" " + strings .ReplaceAll (cbuild .BuildDescType .Context , " " , "_" ) + "\" \n "
@@ -43,9 +41,6 @@ func (m *Maker) CreateSuperCMakeLists() error {
4341 contextOutputs += ")"
4442 }
4543
46- solutionRoot , _ := filepath .EvalSymlinks (m .SolutionRoot )
47- solutionRoot = filepath .ToSlash (solutionRoot )
48-
4944 var verbosity , logConfigure , stepLog string
5045 if m .Options .Debug || m .Options .Verbose {
5146 verbosity = " --verbose"
@@ -55,18 +50,12 @@ func (m *Maker) CreateSuperCMakeLists() error {
5550 stepLog = "\n LOG TRUE"
5651 }
5752
58- // Create roots.cmake
59- err := m .CMakeCreateRoots (solutionRoot )
60- if err != nil {
61- return err
62- }
63-
6453 // Write content
6554 content :=
66- `cmake_minimum_required(VERSION 3.27 )
55+ `cmake_minimum_required(VERSION ` + CMAKE_MIN_REQUIRED + ` )
6756include(ExternalProject)
6857
69- project("` + csolution + `" NONE)
58+ project("` + m . SolutionName + `" NONE)
7059
7160# Roots
7261include("roots.cmake")
@@ -135,7 +124,7 @@ foreach(INDEX RANGE ${CONTEXTS_LENGTH})
135124endforeach()` + m .ExecutesCommands (m .CbuildIndex .BuildIdx .Executes ) + m .BuildDependencies () + `
136125`
137126 superCMakeLists := path .Join (m .SolutionTmpDir , "CMakeLists.txt" )
138- err = utils .UpdateFile (superCMakeLists , content )
127+ err : = utils .UpdateFile (superCMakeLists , content )
139128 if err != nil {
140129 return err
141130 }
@@ -163,3 +152,23 @@ cmake_path(ABSOLUTE_PATH SOLUTION_ROOT NORMALIZE OUTPUT_VARIABLE SOLUTION_ROOT)
163152
164153 return err
165154}
155+
156+ func (m * Maker ) CreateCMakeListsImageOnly () error {
157+ // Write content
158+ content :=
159+ `cmake_minimum_required(VERSION ` + CMAKE_MIN_REQUIRED + `)
160+
161+ project("` + m .SolutionName + `" NONE)
162+
163+ # Roots
164+ include("roots.cmake")` + m .ExecutesCommands (m .CbuildIndex .BuildIdx .Executes ) + m .BuildDependencies () + `
165+ `
166+ pathCMakeLists := path .Join (m .SolutionTmpDir , "CMakeLists.txt" )
167+ err := utils .UpdateFile (pathCMakeLists , content )
168+ if err != nil {
169+ return err
170+ }
171+
172+ log .Info ("CMakeLists was successfully generated in the " + m .SolutionTmpDir + " directory" )
173+ return nil
174+ }
0 commit comments