Closed HealthyPear closed 9 months ago
Just to be clear, are you trying to use it after installing it system-wide, or as a meson subproject? You mention both "installation" and "subproject" above, so I'm not sure.
If you're using it as a subproject it should work (that's how I use it myself in a few other projects), though it could be that the example snippet is incorrect. Try this instead:
tomlplusplus = subproject('tomlplusplus').get_variable('tomlplusplus_dep')
alternatively this might also work:
tomlplusplus = dependency('tomlplusplus_dep')
I just followed the instructions here https://marzer.github.io/tomlplusplus/#mainpage-adding-lib-meson
so I have the wrap file and all seems to be in place under the subprojects
folder
Unfortunately your updated snippet gives me the same error - it cannot find your library headers
[1/2] Compiling C++ object main.p/main.cxx.o
FAILED: main.p/main.cxx.o
c++ -Imain.p -I. -I.. -Isubprojects/tomlplusplus-3.3.0/include -I../subprojects/tomlplusplus-3.3.0/include -fdiagnostics-color=always -Wall -Winvalid-pch -O0 -g -DTOML_HEADER_ONLY=0 -DTOML_SHARED_LIB=1 -MD -MQ main.p/main.cxx.o -MF main.p/main.cxx.o.d -o main.p/main.cxx.o -c ../main.cxx
../main.cxx:2:10: fatal error: 'toml++/toml.hpp' file not found
#include <toml++/toml.hpp>
^~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
I am using meson 1.3.1 always from Homebrew if it can be of any help
unfortunately I am quite ignorant about C++/CMake/Meson...
I am quite ignorant about C++/CMake/Meson...
Yeah, me too 😅
Unfortunately your updated snippet gives me the same error
Hmmmn. Let me look into it.
So I just did this:
shell:
meson wrap install tomlplusplus
meson.build:
project('test_tomlplusplus', 'cpp')
tomlplusplus = dependency('tomlplusplus')
executable('main', 'main.cxx', dependencies : tomlplusplus)
locally in a test project and it worked fine? I don't know where else to go from here.
what is the output of meson wrap status
? e.g.
> meson wrap status
Subproject status
tomlplusplus up to date. Branch 3.3.0, revision 1.
Subproject status tomlplusplus up to date. Branch 3.3.0, revision 1.
seems to be exactly the same
could you zip and share here your test project? maybe I made a mistake elsewhere?
Ohhhh wait, I know what's happening. That's 3.3.0, which didn't have toml.hpp
- I added that in 3.4.0. change your include to this:
#include <toml++/toml.h>
Totally my fault :) ideally the wrap should have been updated, but I haven't gotten around to it.
(there's no difference between the two headers - one just includes the other. I added the .hpp
version in v3.4.0 to be more idiomatic C++.)
Thanks that was indeed the issue here!
I suggest adding a note about this to the docs then.
Also, if it can be of any help, in my case (arch+compiler) I had to explicitly use 'cpp_std=c++17'
as a default option otherwise a ton of other error pop out (but that might be only my setup)
To be fair, I now went into the subproject source and I see the .hpp file, it's just not in the include directory but rather the top-level, together with the README
I suggest adding a note about this to the docs then.
Yep. I should flag this as a <= 3.3.0, >= 3.4.0
thing.
Also, if it can be of any help, in my case (arch+compiler) I had to explicitly use 'cpp_std=c++17' as a default option otherwise a ton of other error pop out (but that might be only my setup)
Well yeah, it's a C++17 project. Meson doesn't propagate the minimum C++ version up from dependencies (that I'm aware of, anyway) - it expects you to be explicit here. If you don't provide a value for cpp_std
it'll just be whatever your compiler's default is (often C++14 these days). See Meson: Compiler options for detail.
To be fair, I now went into the subproject source and I see the .hpp file, it's just not in the include directory but rather the top-level, together with the README
Yeah, that's the single-include version, with the entire library in one file. That's always been there. In v3.4.0 I added a 'normal' version of toml.hpp
in the same directory as toml.h
. (having different file extensions for the two different ways of including the library was a dumb historical mistake on my part, so I fixed it in v3.4.0.)
Would you say it's safer to include the .h
also for 3.4.0 until the wrap is updated?
Yep, the .h version isn't going anywhere :)
Just to be clear, are you trying to use it after installing it system-wide, or as a meson subproject? You mention both "installation" and "subproject" above, so I'm not sure.
If you're using it as a subproject it should work (that's how I use it myself in a few other projects), though it could be that the example snippet is incorrect. Try this instead:
tomlplusplus = subproject('tomlplusplus').get_variable('tomlplusplus_dep')
This is the old style, for when your wrap file doesn't support [provide]
.
alternatively this might also work:
tomlplusplus = dependency('tomlplusplus_dep')
This doesn't work at all, since tomlplusplus_dep is a meson.build script variable, not the name of a registered dependency.
...
The documentation suggests this:
tomlplusplus_dep = dependency('tomlplusplus')
which works fine, but could be improved a bit:
tomlplusplus_dep = dependency('tomlplusplus', version: '>=3.4.0')
since that will guarantee having "at least version 3.4.0", and that's something you want in order to provide consistency and reliability e.g. in terms of header include name. Plus, many of the examples for adding it to your project include minimum requirements like this.
Thanks for the clarifications @eli-schwartz 😃
The header include has been fixed in the documentation, as now there's a version selector - it'll be the correct value if you switch it to v3.3.0 :)
Environment
toml++ version and/or commit hash:
3.3.0 from meson subproject
Compiler:
Apple Clang 13
C++ standard mode:
not sure, the default one
Target arch:
x86_64
Library configuration overrides:
Relevant compilation flags:
Describe the bug
where
main.cxx
is this exampleSteps to reproduce (or a small repro code sample)
Follow the instructions and use the following build configuration
meson.build
then compile with
meson compile -C build
Additional information
This is my
meson setup
outputwhile the following is the (working) CMake configuration