aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/cmake.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/rosa/cmake.go')
-rw-r--r--internal/rosa/cmake.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/internal/rosa/cmake.go b/internal/rosa/cmake.go
index bfa035c0..b1499037 100644
--- a/internal/rosa/cmake.go
+++ b/internal/rosa/cmake.go
@@ -122,6 +122,8 @@ type CMakeHelper struct {
// Path elements joined with source.
Append []string
+ // Value of CMAKE_BUILD_TYPE. The zero value is equivalent to "Release".
+ BuildType string
// CMake CACHE entries.
Cache []KV
// Runs after install.
@@ -164,14 +166,7 @@ func (*CMakeHelper) wantsDir() string { return "/cure/" }
// script generates the cure script.
func (attr *CMakeHelper) script(name string) string {
if attr == nil {
- attr = &CMakeHelper{
- Cache: []KV{
- {"CMAKE_BUILD_TYPE", "Release"},
- },
- }
- }
- if len(attr.Cache) == 0 {
- panic("CACHE must be non-empty")
+ attr = new(CMakeHelper)
}
generate := "Ninja"
@@ -189,6 +184,13 @@ func (attr *CMakeHelper) script(name string) string {
script += "\n" + test
}
+ cache := make([]KV, 1, 1+len(attr.Cache))
+ cache[0] = KV{"CMAKE_BUILD_TYPE", "Release"}
+ if attr.BuildType != "" {
+ cache[0][1] = attr.BuildType
+ }
+ cache = append(cache, attr.Cache...)
+
return `
cmake -G ` + generate + ` \
-DCMAKE_C_COMPILER_TARGET="${ROSA_TRIPLE}" \
@@ -196,7 +198,7 @@ cmake -G ` + generate + ` \
-DCMAKE_ASM_COMPILER_TARGET="${ROSA_TRIPLE}" \
-DCMAKE_INSTALL_LIBDIR=lib \
` + strings.Join(slices.Collect(func(yield func(string) bool) {
- for _, v := range attr.Cache {
+ for _, v := range cache {
if !yield("-D" + v[0] + "=" + v[1]) {
return
}