I've many sub-folders
home
|
|-library1
|-library2
|
|-libraryn
I have a main CMakeLists.txt
in home folder, and a CMakeLists.txt for every subfolder.
In every subproject I've a custom target that I use to compile documentation
# 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)
As you see, in every subproject I create a libraryn_doc
target.
This is the main 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
)
I want to modify the doc
target of main CMakelists.txt in order to execute all libraryn_doc custom targets, so I can build documentation simply by using make doc
instead of make library1_doc; ... make libraryn_doc
.
How can I do it?
Simply modify the dependencies of your doc
target like this:
add_custom_target(doc
DEPENDS library1_doc library2_doc library3_doc library4_doc)