Auto-generate Vala API file, if desired
[appstream:appstream.git] / docs / CMakeLists.txt
1 # CMakeLists for documentation
2
3 find_program (XMLTO xmlto)
4 mark_as_advanced (XMLTO)
5 if (XMLTO STREQUAL "")
6         message (FATAL_ERROR "Xmlto was not found! Please install it to continue!")
7 endif (XMLTO STREQUAL "")
8
9 include (${CMAKE_SOURCE_DIR}/data/cmake/documentation.cmake)
10
11 add_xml_manpages(doc-man "sources/man/appstream-index.1" "" "")
12
13 if (DOCUMENTATION)
14         #########################
15         # General project documentation
16         find_program (PUBLICAN publican)
17         mark_as_advanced (PUBLICAN)
18         if (PUBLICAN STREQUAL "")
19                 message (FATAL_ERROR "Publican was not found! Please install the it to continue!")
20         endif (PUBLICAN STREQUAL "")
21
22         # we need to assemble our documentation build-directory before we can built it
23         add_custom_target (assemble-docs
24                 COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/prepare-docbuild.sh" "source_dir=${CMAKE_CURRENT_SOURCE_DIR}" "build_dir=${CMAKE_BINARY_DIR}/docbuild"
25                 DEPENDS "publican.cfg"
26                         "sources/"
27                         "${CMAKE_BINARY_DIR}/docbuild/"
28                         appstream
29                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
30                 VERBATIM
31         )
32
33         # the actual target to build all documentation
34         add_custom_target (documentation
35                 COMMAND ${PUBLICAN} "build" "--langs=en-US" "--publish" "--formats=html"
36                 DEPENDS "publican.cfg"
37                         "${CMAKE_BINARY_DIR}/docbuild/publican.cfg"
38                         assemble-docs
39                         doc-appstream
40                 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/docbuild/
41         )
42         add_custom_command (OUTPUT "${CMAKE_BINARY_DIR}/docbuild/"
43                         COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/docbuild"
44                         VERBATIM
45         )
46
47         set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_SOURCE_DIR}/html)
48         set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/docbuild)
49
50         # a target to export documentation html to the source tree (useful when building the tarballs)
51         add_custom_target (documentation-htmlexport
52                 COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/docbuild/AppStream-Docs/en-US/html/" "${CMAKE_CURRENT_SOURCE_DIR}/html"
53                 DEPENDS documentation
54                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
55         )
56         add_custom_command(
57                 TARGET documentation-htmlexport POST_BUILD
58                 COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/api/html" "${CMAKE_CURRENT_SOURCE_DIR}/html/api/html"
59                 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
60         )
61
62         #########################
63         # API documentation
64
65         find_package(GtkDoc)
66         if(NOT GTKDOC_FOUND)
67                 message(FATAL_ERROR "gtkdoc was not found, API documentation can not be built.")
68         endif()
69         include(UseGtkDoc)
70
71         gtk_doc_add_module(appstream ${CMAKE_SOURCE_DIR}/src
72                 IGNOREHEADERS as-component-private.h as-utils.h as-database-write.h as-settings-private.h
73                 SUFFIXES h c hh cc
74                 LDFLAGS
75                         -L${CMAKE_CURRENT_BINARY_DIR}/../src
76                         -lappstream
77                 LDPATH
78                         "${CMAKE_CURRENT_BINARY_DIR}/../src"
79                 OUTPUT_DIR
80                         "${CMAKE_CURRENT_SOURCE_DIR}/api"
81                 DEPENDS appstream)
82
83         set_directory_properties (PROPERTIES CLEAN_NO_CUSTOM ${CMAKE_CURRENT_SOURCE_DIR}/api)
84         set_directory_properties (PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/api/html;${CMAKE_CURRENT_SOURCE_DIR}/api/xml;${CMAKE_CURRENT_SOURCE_DIR}/api/tmpl")
85 endif()