gpt4 book ai didi

CMake 检查主项目是否被调用

转载 作者:行者123 更新时间:2023-12-05 00:32:38 25 4
gpt4 key购买 nike

我有这种项目目录设计:

Main:
CMakeLists.txt
subproject1:
CMakeLists.txt
subproject2
CMakeLists.txt

如果 subproject1 cmake 是由 Main 项目调用的,或者作为独立项目调用,我如何检查 subproject1/CMakeLists.txt 文件?

最佳答案

干得好:

if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
# We are building as stand-alone project
project(subproject1)
...
else()
# We are building as part of Main project
endif()

关于CMake 检查主项目是否被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13289314/

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