CMakeLists.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. cmake_minimum_required(VERSION 3.8)
  2. project(TestFindDoxygen VERSION 1.0 LANGUAGES NONE)
  3. # Testing backward compatible signature
  4. find_package(Doxygen REQUIRED)
  5. if(TARGET Doxygen::doxygen)
  6. # Check backward compatibility
  7. if(NOT DOXYGEN_EXECUTABLE)
  8. message(FATAL_ERROR "Backward compatibility broken: DOXYGEN_EXECUTABLE not set")
  9. endif()
  10. if(NOT DOXYGEN)
  11. message(FATAL_ERROR "Backward compatibility broken: DOXYGEN not set")
  12. endif()
  13. # Check presence of expected generated files
  14. foreach(file CMakeDoxyfile.in CMakeDoxygenDefaults.cmake)
  15. if(NOT EXISTS "${PROJECT_BINARY_DIR}/${file}")
  16. message(FATAL_ERROR "Missing generated file: ${file}")
  17. endif()
  18. endforeach()
  19. else()
  20. message(FATAL_ERROR "Import target Doxygen::doxygen not defined")
  21. endif()
  22. doxygen_add_docs(docsNoArgs)
  23. if(NOT EXISTS "${PROJECT_BINARY_DIR}/Doxyfile.docsNoArgs")
  24. message(FATAL_ERROR "Missing generated file: Doxyfile.docsNoArgs")
  25. endif()
  26. if(NOT TARGET docsNoArgs)
  27. message(FATAL_ERROR "Target docsNoArgs not created")
  28. endif()
  29. configure_file(spaces_in_name.cpp.in "spaces in name.cpp" COPYONLY)
  30. doxygen_add_docs(docsWithArgs
  31. "${CMAKE_CURRENT_BINARY_DIR}/spaces in name.cpp"
  32. main.cpp
  33. )
  34. if(NOT EXISTS "${PROJECT_BINARY_DIR}/Doxyfile.docsWithArgs")
  35. message(FATAL_ERROR "Missing generated file: Doxyfile.docsWithArgs")
  36. endif()
  37. if(NOT TARGET docsWithArgs)
  38. message(FATAL_ERROR "Target docsWithArgs not created")
  39. endif()
  40. # Note that CMake inserts at least one entry into SOURCES when a COMMAND or
  41. # DEPENDS option is given to add_custom_target(), so rather than looking for an
  42. # exact match, we only verify that the files we expect to be there are present
  43. get_target_property(srcList docsWithArgs SOURCES)
  44. set(expectedList
  45. "${CMAKE_CURRENT_BINARY_DIR}/spaces in name.cpp"
  46. "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
  47. )
  48. foreach(f IN LISTS expectedList)
  49. if(NOT f IN_LIST srcList)
  50. message(FATAL_ERROR "SOURCES missing file: ${f}")
  51. endif()
  52. endforeach()
  53. add_custom_target(allDocTargets)
  54. add_dependencies(allDocTargets docsNoArgs docsWithArgs)