CMake add_subdirectory在子目录中未包含

时间:2015-06-04 11:47:57

标签: cmake

我有一个像这样的目录树:

libs
   support
       db
          csv
       patterns
   support_qt
       helpers
       dialogs

现在当我在add_subdirectory级别执行support时,我可以添加dbpatterns并收集文件。但是在db中我添加了另一个引用add_subdirectory的{​​{1}},但不知怎的,这会被忽略。

csv

support

set(SUPPORT_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/support_defs.h ${CMAKE_CURRENT_SOURCE_DIR}/support_dll_api.h ${CMAKE_CURRENT_SOURCE_DIR}/supportlib_namespace.h ${CMAKE_CURRENT_SOURCE_DIR}/dll_main.cpp ) add_subdirectory (db) add_subdirectory (patterns)

db

上述工作正常,但在set(SUPPORT_SOURCE ${SUPPORT_SOURCE} ${CMAKE_CURRENT_SOURCE_DIR}/column_types.h ${CMAKE_CURRENT_SOURCE_DIR}/dbcolumn.h ${CMAKE_CURRENT_SOURCE_DIR}/database_login.h ${CMAKE_CURRENT_SOURCE_DIR}/database_login.cpp ${CMAKE_CURRENT_SOURCE_DIR}/type_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/type_helper.cpp PARENT_SCOPE ) add_subdirectory(csv)

csv

但是这些文件不包含在构建中。那么我必须将add_subdirectory调用all放入根文件吗?

1 个答案:

答案 0 :(得分:0)

刚刚找到解决方案。我必须将add_subdirectory放在set命令之前。

add_subdirectory(csv)
set(SUPPORT_SOURCE ${SUPPORT_SOURCE}
    ${CMAKE_CURRENT_SOURCE_DIR}/column_types.h
    ${CMAKE_CURRENT_SOURCE_DIR}/dbcolumn.h
    ${CMAKE_CURRENT_SOURCE_DIR}/database_login.h
    ${CMAKE_CURRENT_SOURCE_DIR}/database_login.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/type_helper.h
    ${CMAKE_CURRENT_SOURCE_DIR}/type_helper.cpp

    PARENT_SCOPE
)