Reputation: 11753
I understand I can add some files to a target in CMake if the target is an executable or a library with the following command:
add_executable(${target_name} ${source_files})
or add_library(${target_name} ${source_files})
Then my question is what if the target is not an an executable or a library. I raise this question because I want to build a target for documentation with Doxygen, and this can be done with the following commands:
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) #doxygen file
set(doxyfile ${PROJECT_BINARY_DIR}/Doxyfile)
#configure the doxygen file
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxygen.in ${PROJECT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target( doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
With Visual Studio, doc
becomes a target, and I also want to add Doxyfile.in
file in the project just in case that I need to change some variables inside with the IDE. Any ideas on how I can add this file on the doc
target? Thanks.
Upvotes: 2
Views: 1206
Reputation: 78290
You can use the SOURCES
argument of add_custom_target
for this:
add_custom_target( doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Doxygen.in
)
Upvotes: 2