gpt4 book ai didi

cmake - 我应该缓存 CMAKE_BUILD_TYPE 吗?

转载 作者:行者123 更新时间:2023-12-04 03:03:23 26 4
gpt4 key购买 nike

如果不设置 CMAKE_BUILD_TYPE ,然后,默认情况下,它不会被缓存。我应该缓存它吗?例如我应该:

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" )
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Type of build (Debug, Release etc." FORCE)
endif()

要不就:
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" )
endif()

还是真的无所谓?

最佳答案

CMAKE_BUILD_TYPE 的缓存对于 cmake-gui 很有用:您的项目用户将能够以一种很好的方式更改构建类型。

有一个很好的模板来设置默认的 CMAKE_BUILD_TYPE from developers :

# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()

关于cmake - 我应该缓存 CMAKE_BUILD_TYPE 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46820155/

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