我有一个像这样的目录树:
libs
support
db
csv
patterns
support_qt
helpers
dialogs
等
现在当我在add_subdirectory
级别执行support
时,我可以添加db
和patterns
并收集文件。但是在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放入根文件吗?
答案 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
)