gpt4 book ai didi

c++ - 如何在 CMake 文件中添加定义 QT_NO_DEBUG_OUTPUT?

转载 作者:行者123 更新时间:2023-11-30 05:03:38 26 4
gpt4 key购买 nike

我正在使用 ROS,因此编写 CMake 文件。在 Qt .pro 文件中,我们可以使用:

DEFINE+=QT_NO_DEBUG_OUTPUT

我们如何在 CMake 文件中做到这一点?我试过:

add_definitions(QT_NO_DEBUG_OUTPUT)

但它给了我以下错误:

c++: error: QT_NO_DEBUG_OUTPUT: No such file or directory

最佳答案

add_definitions要求您根据编译器语法编写标志:在您的情况下使用 -D (在视觉上将是 /D )。你应该只写:

add_definitions(-DQT_NO_DEBUG_OUTPUT)

一种更灵活、更细粒度的方法是使用 target_compile_definitions 为每个目标添加定义。 :

add_executable(foo ...)
target_compile_definitions(foo PUBLIC QT_DEBUG_NO_OUTPUT)

注意这里不需要-D

关于c++ - 如何在 CMake 文件中添加定义 QT_NO_DEBUG_OUTPUT?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49333056/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com