mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.6k stars 1.63k forks source link

configure_file with format cmake doesn't handle @var@ like CMake does #13665

Open dcbaker opened 1 month ago

dcbaker commented 1 month ago

Describe the bug given a replacement file:

var=@var@
var2=${var}

CMake with a regular call to configure_file() will replace both the @var@ and ${var}, but Meson will only replace the latter. CMake will only replace the @var@ when using the ONLY@ configuration in cmake

To Reproduce Give the above file snippet as "file.in", and the following Meson vs CMake snippets:

cmake_minimum_required(VERSION 3.22)
project(test VERSION 1.0)
include(GNUInstallDirs)

set(var "VAR")
configure_file(file.in file.out)
project('test')

configure_file(
  input : 'file.in',
  output : 'file.out',
  configuration : {'var' : 'VAR'},
  format : 'cmake',
)

CMake will produce:

var=VAR
var2=VAR

while Meson will produce:

var=@var@
var2=VAR

Expected behavior Meson will generate the same output as CMake

system parameters

SirNate0 commented 1 month ago

Pretty sure the docs will also need an update. Presently they make it sound like meson and cmake@ are identical in their behavior, which doesn't make sense. One of the three options should allow both ${var} and @var@. From the docs

The format of defines. It defaults to 'meson', and so substitutes #mesondefine statements and variables surrounded by @ characters, you can also use 'cmake' to replace #cmakedefine statements and variables with the ${variable} syntax. Finally you can use 'cmake@' in which case substitutions will apply on #cmakedefine statements and variables with the @variable@ syntax.

dcbaker commented 1 month ago

meson and cmake@ look correct to me. as they do the following:

SirNate0 commented 1 month ago

🤦 I missed the difference in the #___define terms.