gpt4 book ai didi

c++ - CMake: "SET(PODOFO_BUILD_SHARED NOT ${PODOFO_BUILD_SHARED})"是什么意思?

转载 作者:太空宇宙 更新时间:2023-11-04 11:45:56 27 4
gpt4 key购买 nike

# If the user hasn't told use specifically what they want, build only
# a static library.

IF(NOT DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
SET(PODOFO_BUILD_STATIC TRUE)
SET(PODOFO_BUILD_SHARED FALSE)
ENDIF(NOT DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)

IF(DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
SET(PODOFO_BUILD_SHARED NOT ${PODOFO_BUILD_SHARED})
ENDIF(DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)

IF(NOT DEFINED PODOFO_BUILD_SHARED AND DEFINED PODOFO_BUILD_STATIC)
SET(PODOFO_BUILD_SHARED NOT ${PODOFO_BUILD_STATIC})
ENDIF(NOT DEFINED PODOFO_BUILD_SHARED AND DEFINED PODOFO_BUILD_STATIC)

“SET(PODOFO_BUILD_SHARED NOT ${PODOFO_BUILD_SHARED})”是什么意思?在这些片段之前我看不到 PODOFO_BUILD_SHARED 变量的任何定义

最佳答案

  • 前 4 行采用 2 个“ bool ”变量 PODOFO_BUILD_STATIC 和 PODOFO_BUILD_SHARED,如果它们都未定义,则将它们设置为默认值
  • 如果只定义了 PODOFO_BUILD_SHARED,则后 3 行反转 PODOFO_BUILD_SHARED 的值,无论其初始值是什么。 奇怪!
  • 如果只定义了 PODOFO_BUILD_STATIC,最后 3 行取 PODOFO_BUILD_STATIC 的反转值并将其分配给 PODOFO_BUILD_SHARED

但是,整体行为似乎有点奇怪。我的猜测是(第二三行):

IF(DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
SET(PODOFO_BUILD_SHARED NOT ${PODOFO_BUILD_SHARED})
ENDIF(DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)

应该是:

IF(DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
SET(PODOFO_BUILD_STATIC NOT ${PODOFO_BUILD_SHARED})
ENDIF(DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)

这样更有意义:如果只定义了 2 个变量中的一个,它将另一个设置为相反的值。

what does "SET(PODOFO_BUILD_SHARED NOT ${PODOFO_BUILD_SHARED})"means? before those snippet i cann't see any definition of PODOFO_BUILD_SHARED variable

可以通过多种方式预先在文件外部定义变量(例如,从命令行,或通过 cmake-gui 设置缓存变量)

关于c++ - CMake: "SET(PODOFO_BUILD_SHARED NOT ${PODOFO_BUILD_SHARED})"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19833211/

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