我正在尝试用介子配置一个项目。具体来说,我正在尝试设置一些选项。
meson config告诉我,除其他外:
Core options:
Option Current Value Possible Values Description
------ ------------- --------------- -----------
buildtype debug [plain, debug, debugoptimized, release, minsize, custom] Build type to use
Base options:
Option Current Value Possible Values Description
------ ------------- --------------- -----------
b_lto false [true, false] Use link time optimization
Run Code Online (Sandbox Code Playgroud)
(当然,其他选项已从此打印输出中删除。)
所以,我写:
meson build . --buildtype=release
Run Code Online (Sandbox Code Playgroud)
在我的构建目录中,一切顺利 - 没有警告或错误(我仔细检查了选项值是否已更改)。然后我写:
meson build . --b_lto=true
Run Code Online (Sandbox Code Playgroud)
但这让我感到:
meson: error: unrecognized arguments: --b_lto=true
Run Code Online (Sandbox Code Playgroud)
我也尝试过-b_lto=true、、、、。而所有这些都没有价值。没有运气。--b_lto trueb_lto=trueb_lto truetrue
那么我该如何设置这些“基本选项”呢?
command-line command-line-arguments buildconfiguration meson-build
对于我的介子项目,我有一个位于“不寻常”位置的依赖项:
/opt/MyDependence/lib/libmyLib.so
/opt/MyDependence/include/myLib.hpp
Run Code Online (Sandbox Code Playgroud)
我的介子文件是:
project('Test', ['cpp'])
cpp = meson.get_compiler('cpp')
myLib_dep = cpp.find_library('myLib', required: true)
Run Code Online (Sandbox Code Playgroud)
显然介子找不到图书馆
Meson.build:5:0: ERROR: C++ library 'myLib' not found
Run Code Online (Sandbox Code Playgroud)
问题是我不知道添加额外搜索路径以便 Meson 可以找到我的库的“规范”方法。任何想法?
更新:请注意,即使我使用:
meson --libdir=/opt/MyDepedence/lib build
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息:
meson.build:1:0: ERROR: The value of the 'libdir' option is '/opt/MyDepedence/lib' which must be a subdir of the prefix '/usr/local'.
Note that if you pass a relative path, it is assumed to be a subdir of prefix.
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Meson 构建一个 C++ 项目。
问题是,我有一些库,/opt/conda
但在运行meson build. 它似乎只是通过/usr/lib目录搜索。
据我了解,meson使用cmake和pkg-config寻找图书馆。那么设置类似的东西CMAKE_PREFIX_PATH是一个可行的解决方案吗?如果是这样,我该怎么做?
提前致谢。
我的项目(在C中)在构建时具有第三方依赖.但是,默认情况下,第三方库是安装的,/opt/而不是/lib,我找不到它pkg-config.从mesonbuild我的文档中,我应该使用declare_dependency,我没有其源代码将其视为我的子项目.如果我用dependency()它来定义它,我找不到正确的参数来定义自定义位置.
如何声明非标准第三方库的依赖关系?
我遇到过一些使用介子来组织建筑系统的项目。但当我想调试他们的构建系统时,我发现这很困难。最重要的任务是观察建筑系统在运行过程中的变量。我可以使用 message() 函数来显示类型的变量,例如
integer
string
lists (of string/integer/lists)
Run Code Online (Sandbox Code Playgroud)
但如果变量是字典类型,则message()将拒绝显示变量中的任何信息。
meson 是否有一个通用函数来显示任何类型的变量,就像 python 的 print() 函数一样?如果没有,我们有什么解决方案吗?
提前致谢。
I have an issue with the generation of makefiles stage of CMake being slow which is similar to this unanswered question:
CMake is slow to generate makefiles
My project is made up of a top level CMakeLists.txt file which uses add_subdirectory() to add various subprojects for individual library and executable components.
For a given component, the CMakeLists.txt file contains something like:
add_library(mylib SHARED
sourceFile1.cpp
sourceFile2.cpp
...
)
Run Code Online (Sandbox Code Playgroud)
I can build just the contents of that directory using:
make mylib
Run Code Online (Sandbox Code Playgroud)
If …
阅读了 Meson 站点页面(通常是高质量的)后,我仍然不确定处理不同构建类型的不同选项的预期最佳实践。
因此,要指定调试版本:
meson [srcdir] --buildtype=debug
Run Code Online (Sandbox Code Playgroud)
或者指定发布版本:
meson [srcdir] --buildtype=release
Run Code Online (Sandbox Code Playgroud)
但是,如果我只想b_sanitize=address为调试版本和b_ndebug=true发布版本添加(或其他任意复杂的参数集),我会这样做:
meson [srcdir] --buildtype=debug -Db_sanitize=address ...
meson [srcdir] --buildtype=release -Db_ndebug=true ...
Run Code Online (Sandbox Code Playgroud)
然而,在命令行上添加一堆自定义参数更麻烦,对我来说,把它放在 meson.build 文件中似乎更简洁。所以我知道我可以这样设置一些内置选项:
project('myproject', ['cpp'],
default_options : ['cpp_std=c++14',
'b_ndebug=true'])
Run Code Online (Sandbox Code Playgroud)
但它们是无条件设置的。
所以一个条件看起来像这样:
if get_option('buildtype').startswith('release')
add_project_arguments('-DNDEBUG', language : ['cpp'])
endif
Run Code Online (Sandbox Code Playgroud)
这是一种方法,但是,似乎b_ndebug=true更喜欢这种方法add_project_arguments('-DNDEBUG'),因为它是可移植的。
如何在 Meson 脚本中有条件地设置可移植样式的构建选项?
另外,b_sanitize=address设置没有任何测试编译器是否支持它。我希望它首先检查它是否受支持(例如,因为库可能丢失):
if meson.get_compiler('cpp').has_link_argument('-fsanitize=address')
add_project_arguments('-fsanitize=address', language : ['cpp'])
add_project_link_arguments('-fsanitize=address', language : ['cpp'])
endif
Run Code Online (Sandbox Code Playgroud)
是否可以检查内置的便携式构建选项(例如b_sanitize)是否受支持?
我正在尝试使用介子 Gnome PasswordSafe 构建应用程序。我已经成功地在 Arch 上构建了它,但后来转移到 PureOS (Debian)。
运行时:
$ meson . _build --prefix=/usr
Run Code Online (Sandbox Code Playgroud)
它告诉我:
meson.build:36:4: 错误:遇到问题:缺少依赖 pykeepass >= master
我错过了什么?
谢谢!
我安装pykeepass使用pip. 当那不起作用时,我尝试使用 pip3。当那不起作用时,我再次尝试了两者,但使用了 sudo。仍然没有骰子。
然后我从 repo/source ( https://github.com/pschmitt/pykeepass )安装了它。没有骰子。
目前,python 帮助识别pykeepass为安装到:
/home/dc3p/.local/lib/python3.7/site-packages/pykeepass/__init__.py
/usr/local/lib/python3.7/dist-packages/pykeepass/__init__.py
/home/dc3p/.local/lib/python2.7/site-packages/pykeepass/__init__.py
/usr/local/lib/python2.7/dist-packages/pykeepass/__init__.py
Run Code Online (Sandbox Code Playgroud)
pip和pip3列表显示pykeepass为存在。
虽然我目前在所有四个位置都安装了它,但我也尝试过一次只在任何位置安装一个。
我也试过meson没有和有 sudo 的命令。不管我做什么,介子都会抛出同样的错误。
预期结果是构建。
meson-build ×10
build ×3
build-system ×2
cmake ×2
dependencies ×2
c ×1
c++ ×1
command-line ×1
module ×1
python ×1
qt-creator ×1