如何设置add_executable Win32属性或不取决于构建类型?

发布于 2025-02-13 04:01:19 字数 273 浏览 0 评论 0 原文

这将失败,因为“找不到源文件:win32。尝试扩展...”

add_executable(${PROJECT_NAME} $<$<CONFIG:Release>:WIN32> main.cpp)

我需要此功能才能以调试模式以控制台启动该应用程序并能够读取打印到控制台的信息。

据我所知,这是错误的,并在CMAKE文档中再次建议检查 cmake_build_type 直接发布

This fails with the error "Cannot find source file: WIN32. Tried extensions..."

add_executable(${PROJECT_NAME} 
lt;
lt;CONFIG:Release>:WIN32> main.cpp)

I need this in order to launch the app in the console in Debug mode and being able to read information printed to the console.

And as far as I know it's wrong and is advised agains in the cmake docs to check CMAKE_BUILD_TYPE being Release directly.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

古镇旧梦 2025-02-20 04:01:19

正如您注意到的那样,您不能在 add_executable 命令中使用Win32关键字的发电机表达式。

而是尝试在目标上设置相应的属性 win32_executable

set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE 
lt;CONFIG:Release>)

As you noticed you cannot use generator expressions for the WIN32 keyword in the add_executable command.

Instead, try setting the corresponding property WIN32_EXECUTABLE on the target:

set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE 
lt;CONFIG:Release>)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文