cmake的忽略-D CMAKE_BUILD_TYPE =调试 [英] cmake ignores -D CMAKE_BUILD_TYPE=Debug
问题描述
我只是试图建立在调试模式下cmake的项目,以使断言。我尝试了以下版本:
I'm just trying to build a cmake project in debug-mode to enable asserts. I tried the following versions:
cmake -D CMAKE_BUILD_TYPE:STRING=Debug -L ../../
cmake -DCMAKE_BUILD_TYPE:STRING=Debug -L ../../
cmake -DCMAKE_BUILD_TYPE=Debug -L ../../
不幸的是没有theese有预期的效果 - 即 CMAKE_BUILD_TYPE
设置为调试
(因此 NDEBUG
-flag不传递给GCC)。
Unfortunately none of theese has the desired effect - that CMAKE_BUILD_TYPE
is set to Debug
(and therefore the NDEBUG
-flag is not passed to gcc).
此外,我添加 variable_watch(CMAKE_BUILD_TYPE)
来我的主要的CMakeLists.txt
来检查值获取的某处是否覆盖。但第一输出是在我的主 READ_ACCESS
另外我补充 variable_watch(CMAKE_BUILD_TYPE)
来我的主要的CMakeLists.txt
还有价值已然是>发布。
Additionally I added variable_watch(CMAKE_BUILD_TYPE)
to my main CMakeLists.txt
to check whether the value get's overridden somewhere. But the first output is a READ_ACCESS
in my main
Additionally I added variable_watch(CMAKE_BUILD_TYPE)
to my main CMakeLists.txt
and the value there already is Release
.
是否有人有一个想法,为什么CMake的忽略配置?
Does someone have an idea why cmake ignores the configuration?
我使用cmake版本2.8.7。
I'm using cmake version 2.8.7.
感谢的提前任何帮助!
推荐答案
好吧, fgrep一样-RCMAKE_BUILD_TYPE
终于找到了我的问题。在某些的CMakeLists.txt
-file我发现这样的事情:
Ok, fgrep -R "CMAKE_BUILD_TYPE"
finally found the problem for me. In some CMakeLists.txt
-file I found something like that:
SET( CMAKE_BUILD_TYPE Release ... FORCE )
这将覆盖每一个用户定义的参数(因为力
)。
That overrides every user defined parameters (because of the FORCE
).
什么工作对我来说是:
IF( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Release ... FORCE )
ENDIF()
感谢对你的提示!
这篇关于cmake的忽略-D CMAKE_BUILD_TYPE =调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!