From 48a17b52342f8c97dcb6af193233f616ace9f5f6 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Mon, 30 Jul 2018 12:23:24 -0400 Subject: [PATCH] cmake ignore doxygen option when not a standalone build (#488) --- CMakeLists.txt | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c98a5ae04..ff799b9bfe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,29 +191,33 @@ endif() #============================================================================= # Doxygen # -option(BUILD_DOXYGEN "Build doxygen documentation" OFF) +# Only in standalone build +if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) -if (BUILD_DOXYGEN) - find_package(Doxygen) - if (DOXYGEN_FOUND) - # set input and output files - set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/docs/Doxyfile.in) - set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - - # request to configure the file - configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - - # note the option ALL which allows to build the docs together with the application - add_custom_target(doxygen ALL - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating documentation with Doxygen" - DEPENDS - VERBATIM - USES_TERMINAL - ) - - else() - message(FATAL_ERROR "Doxygen needs to be installed to generate documentation") + option(BUILD_DOXYGEN "Build doxygen documentation" OFF) + + if (BUILD_DOXYGEN) + find_package(Doxygen) + if (DOXYGEN_FOUND) + # set input and output files + set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in) + set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) + + # request to configure the file + configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) + + # note the option ALL which allows to build the docs together with the application + add_custom_target(doxygen ALL + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating documentation with Doxygen" + DEPENDS + VERBATIM + USES_TERMINAL + ) + + else() + message(FATAL_ERROR "Doxygen needs to be installed to generate documentation") + endif() endif() endif()