如何在cmake中将构建类型更改为发布模式? [英] How to change the build type to Release mode in cmake?
本文介绍了如何在cmake中将构建类型更改为发布模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正试图在释放模式下建立一个项目。默认情况下,它是在调试模式下构建的。我在 CMakeLists.txt
中将变量 CMAKE_BUILD_TYPE
设置为Release。但它仍然在调试模式下构建项目。
当我在CMake命令中传递Release作为构建类型时,它仍然不工作。
I am trying to build a project in Release mode. By default it is built in debug mode. I am setting the variable CMAKE_BUILD_TYPE
to "Release" in CMakeLists.txt
. But it is still building the project in debug mode.
When I pass "Release" as the build type in the CMake command, it still does not work.
我使用的CMake命令是: / p>
The CMake command that I am using is:
cmake -G"Visual Studio 10" -DCMAKE_BUILD_TYPE=Release
-H"source_path" -B"Build path"
请提供一个解决方案。
推荐答案
使用它,而在根cmake文件中添加之前 项目关键字
Use it as you do it but in the root cmake file add the following before the project keyword
SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "" FORCE)
PROJECT(MY_PROJECT)#It's here just to show where you should add it.
这篇关于如何在cmake中将构建类型更改为发布模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文