Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dcbaker opened this issue Sep 11, 2024 · 3 comments · May be fixed by #13987
Open

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

dcbaker opened this issue Sep 11, 2024 · 3 comments · May be fixed by #13987
Labels

Comments

@dcbaker
Copy link
Member

dcbaker commented Sep 11, 2024

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

  • Is this a cross build or just a plain native build (for the same computer)? No
  • what operating system: Linux
  • what Python version are you using: 3.11.9
  • what meson --version: 1.5.99 and 1.4.2
  • what ninja --version if it's a Ninja build: 1.11.1
@dcbaker dcbaker added the bug label Sep 11, 2024
@SirNate0
Copy link

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
Copy link
Member Author

dcbaker commented Sep 13, 2024

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

  • meson: replace @...@, and #mesondefine
  • cmake@: replace @...@, and #cmakedefine

@SirNate0
Copy link

🤦 I missed the difference in the #___define terms.

@dcbaker dcbaker linked a pull request Dec 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants