CMAKE-从命令行附加cmake_cxx_flags

发布于 2025-02-05 17:34:02 字数 424 浏览 1 评论 0原文

我想从命令行添加一些cmake_cxx_flags cmakelists.txt中定义的标志,例如:

cmake -DCMAKE_CXX_FLAGS="-Wall" ..

它仅在cmakelists.txt中的标志附加到列表中时才能工作。

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")

在下种情况下:

set(CMAKE_CXX_FLAGS "-Wall")

cmake_cxx_flags从命令行传递会被覆盖。

是否有任何方法可以防止命令行中定义的覆盖标志,而无需modyfing cmakelists.txt?

I would like to add some CMAKE_CXX_FLAGS from the command line to the flags defined in CMakeLists.txt, for example:

cmake -DCMAKE_CXX_FLAGS="-Wall" ..

It will work only when flags are appended to the list in the CMakeLists.txt, for example:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")

In the following case:

set(CMAKE_CXX_FLAGS "-Wall")

CMAKE_CXX_FLAGS passed from the command line wil be overwritten.

Is there any way to prevent overwritting flags defined in the command line without modyfing CMakeLists.txt ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文