我有这种项目目录设计:
Main:
CMakeLists.txt
subproject1:
CMakeLists.txt
subproject2
CMakeLists.txt
如果主项目调用subproject1 cmake,或者作为独立项目调用subproject1 / CMakeLists.txt文件,我该怎么办?
答案 0 :(得分:5)
你走了:
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()