summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2020-05-09 03:35:15 (GMT)
committerCraig Scott <craig.scott@crascit.com>2020-05-09 03:35:51 (GMT)
commit5ec969080240324f493c8ea55968660a06438aee (patch)
treecc4727e0fce4ee987104254c3511cab43844515a
parent683abe4366b5bf1149130177181fb81047f3a1dc (diff)
downloadCMake-5ec969080240324f493c8ea55968660a06438aee.zip
CMake-5ec969080240324f493c8ea55968660a06438aee.tar.gz
CMake-5ec969080240324f493c8ea55968660a06438aee.tar.bz2
FindDoxygen: Allow generated files with USE_STAMP_FILE
Fixes: #20597
-rw-r--r--Modules/FindDoxygen.cmake8
-rw-r--r--Tests/FindDoxygen/StampFile/CMakeLists.txt21
2 files changed, 25 insertions, 4 deletions
diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake
index faa03f9..184a9a2 100644
--- a/Modules/FindDoxygen.cmake
+++ b/Modules/FindDoxygen.cmake
@@ -999,9 +999,11 @@ doxygen_add_docs() for target ${targetName}")
foreach(_item IN LISTS DOXYGEN_INPUT)
get_filename_component(_abs_item "${_item}" ABSOLUTE
BASE_DIR "${_args_WORKING_DIRECTORY}")
- if(EXISTS "${_abs_item}" AND
- NOT IS_DIRECTORY "${_abs_item}" AND
- NOT IS_SYMLINK "${_abs_item}")
+ get_source_file_property(_isGenerated "${_abs_item}" GENERATED)
+ if(_isGenerated OR
+ (EXISTS "${_abs_item}" AND
+ NOT IS_DIRECTORY "${_abs_item}" AND
+ NOT IS_SYMLINK "${_abs_item}"))
list(APPEND _sources "${_abs_item}")
elseif(_args_USE_STAMP_FILE)
message(FATAL_ERROR "Source does not exist or is not a file:\n"
diff --git a/Tests/FindDoxygen/StampFile/CMakeLists.txt b/Tests/FindDoxygen/StampFile/CMakeLists.txt
index 4bb0f3d..ed2bfbb 100644
--- a/Tests/FindDoxygen/StampFile/CMakeLists.txt
+++ b/Tests/FindDoxygen/StampFile/CMakeLists.txt
@@ -3,6 +3,7 @@ project(TestFindDoxygen VERSION 1.0 LANGUAGES NONE)
find_package(Doxygen REQUIRED)
+set(DOXYGEN_OUTPUT_DIRECTORY noFiles)
doxygen_add_docs(docsWithoutFilesWithStamp USE_STAMP_FILE)
if(NOT EXISTS "${PROJECT_BINARY_DIR}/Doxyfile.docsWithoutFilesWithStamp")
message(FATAL_ERROR "Missing generated file: Doxyfile.docsWithoutFilesWithStamp")
@@ -11,6 +12,7 @@ if(NOT TARGET docsWithoutFilesWithStamp)
message(FATAL_ERROR "Target docsWithoutFilesWithStamp not created")
endif()
+set(DOXYGEN_OUTPUT_DIRECTORY withFiles)
doxygen_add_docs(docsWithFilesWithStamp main.cpp main2.cpp USE_STAMP_FILE)
if(NOT EXISTS "${PROJECT_BINARY_DIR}/Doxyfile.docsWithFilesWithStamp")
message(FATAL_ERROR "Missing generated file: Doxyfile.docsWithFilesWithStamp")
@@ -19,6 +21,23 @@ if(NOT TARGET docsWithFilesWithStamp)
message(FATAL_ERROR "Target docsWithFilesWithStamp not created")
endif()
+# Confirm that doxygen_add_docs() doesn't cause a fatal error if given a
+# source file that is generated at build time
+file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/genDox.cpp)
+add_custom_command(OUTPUT genDox.cpp
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main2.cpp genDox.cpp
+ DEPENDS main2.cpp
+)
+set(DOXYGEN_OUTPUT_DIRECTORY withGenFiles)
+doxygen_add_docs(docsWithGenFilesWithStamp
+ main.cpp
+ ${CMAKE_CURRENT_BINARY_DIR}/genDox.cpp
+ USE_STAMP_FILE
+)
add_custom_target(allDocTargets)
-add_dependencies(allDocTargets docsWithoutFilesWithStamp docsWithFilesWithStamp)
+add_dependencies(allDocTargets
+ docsWithoutFilesWithStamp
+ docsWithFilesWithStamp
+ docsWithGenFilesWithStamp
+)