本文介绍了CMake检查主项目是否被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这种项目目录设计:
I've got this kind of project directory design:
Main:
CMakeLists.txt
subproject1:
CMakeLists.txt
subproject2
CMakeLists.txt
如果subproject1 cmake是由Main项目调用的,还是作为独立项目调用的,该如何检入subproject1/CMakeLists.txt文件?
How can I check in subproject1/CMakeLists.txt file if subproject1 cmake was called by the Main project, or as a standalone one?
推荐答案
在这里:
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检查主项目是否被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!