gpt4 book ai didi

cmake - 如何检查cmake包含在 `include(...)`中的模块是否存在?

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

在我的一个 CMakeLists.txt 文件中:

include( AICxxProject )

在某些情况下(错误安装)这会产生:

CMake Error at src/CMakeLists.txt:1 (include):  
include could not find load file:

AICxxProject

我想告诉用户他们做错了什么以及如何解决带有 FATAL_ERROR 消息。但是,我如何检测模块是否像 AICxxProject 会在 include 之前被发现吗?

最佳答案

实际阅读include的文档解决了.

以下作品,

include( AICxxProject OPTIONAL RESULT_VARIABLE _module_path )                                                                                                            
if ( NOT _module_path )
message( FATAL_ERROR
"include could not find load file: AICxxProject\n"
"1) Make sure that you have the git submodule https://github.com/CarloWood/cwm4 in the top-level directory.\n"
"2) Use `include(cwm4/cmake/AICxxProject)` right below the `project(...)` command in your top-level CMakeLists.txt."
)
endif ()

作为输出

CMake Error at cwds/CMakeLists.txt:9 (message):
include could not find load file: AICxxProject

1) Make sure that you have the git submodule
https://github.com/CarloWood/cwm4 in the top-level directory.

2) Use `include(cwm4/cmake/AICxxProject)` right below the `project(...)`
command in your top-level CMakeLists.txt.


-- Configuring incomplete, errors occurred!

关于cmake - 如何检查cmake包含在 `include(...)`中的模块是否存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59507199/

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