我有很多子文件夹
home
|
|-library1
|-library2
|
|-libraryn
我在主文件夹中有一个主CMakeLists.txt
,每个子文件夹都有一个CMakeLists.txt。
在每个子项目中,我都有一个用于编译文档的自定义目标
# in library1/CMakelists.txt
find_package (Doxygen)
if (DOXYGEN_FOUND)
set (Doxygen_Dir ${CMAKE_BINARY_DIR}/export/${library1_Version}/doc)
# Copy images folder
file (GLOB IMAGES_SRC "images/*")
file (COPY ${IMAGES_SRC} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/images)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target (library1_doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating doxygen documentation" VERBATIM
)
else (DOXYGEN_FOUND)
message (STATUS "Doxygen must be installed in order to compile doc")
endif (DOXYGEN_FOUND)
# in libraryn/CMakelists.txt
find_package (Doxygen)
if (DOXYGEN_FOUND)
set (Doxygen_Dir ${CMAKE_BINARY_DIR}/export/${library1_Version}/doc)
# Copy images folder
file (GLOB IMAGES_SRC "images/*")
file (COPY ${IMAGES_SRC} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/images)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target (libraryn_doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating doxygen documentation" VERBATIM
)
else (DOXYGEN_FOUND)
message (STATUS "Doxygen must be installed in order to compile doc")
endif (DOXYGEN_FOUND)
如您所见,在每个子项目中,我创建了一个libraryn_doc
目标。
这是主CMakeLists.txt:
cmake_minimum_required (VERSION 2.8)
### Versions ###
# This exports the library version
set (library1_Version 0.0)
### Projects ###
add_subdirectory (library1)
add_subdirectory (library2)
add_subdirectory (library3)
add_subdirectory (library4)
### Project dependencies ###
add_dependencies (librrary4 library1)
### Project documentation ###
add_custom_target(doc
DEPENDS library1 library2 library3 library4
)
我想修改主CMakelists.txt的doc
目标,以便执行所有libraryn_doc自定义目标,因此我可以简单地通过使用make doc
而不是make library1_doc; ... make libraryn_doc
来构建文档。
我该怎么做?
只需像这样修改doc
目标的依赖项:
add_custom_target(doc
DEPENDS library1_doc library2_doc library3_doc library4_doc)