gpt4 book ai didi

cmake - 如何中止处理当前目录的 CMakeLists

转载 作者:行者123 更新时间:2023-12-04 02:16:20 27 4
gpt4 key购买 nike

我有一个项目结构,如:

src/CMakeLists.txt
src/test/component1/CMakeLists.txt
src/test/component2/CMakeLists.txt

对于测试,我使用的是 Qt - 但是,我想确保如果 Qt(或其他一些特定于测试的包未找到)我只是跳过该包。

我试过
find_package(Qt4 QUIET COMPONENTS QtCore QtTestLib)
if (NOT QT4_FOUND)
message(SEND_ERROR "Qt4 not found - skipping building tests")
endif (NOT QT4_FOUND)

但这并不像我想要的那样工作,因为这仍然会阻止生成 Makefile。我能想到的唯一方法是将 CMakeLists 文件的整个主体放入条件的主体中。

有没有办法说“跳过处理此 CMakeLists 的其余部分”?

最佳答案

来自 CMake documentation

  • return: Return from a directory or function.

    return()

Returns from a directory or function. When this command is encountered, it caused process of the current function or directory to stop and control is return to the caller of the function, or the parent directory if any. Note that a macro is not a function and does not handle return like a function does.

关于cmake - 如何中止处理当前目录的 CMakeLists,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1511994/

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