5

我有这种项目目录设计:

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

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

4

1 回答 1

7

干得好:

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()
于 2012-11-08T13:41:01.310 回答