Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add building the manual to cmake #2423

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.18)

include(CheckSymbolExists)
include(CheckIPOSupported)

option(NINJA_BUILD_BINARY "Build ninja binary" ON)
option(NINJA_BUILD_DOC "Build ninja's manual" ON)
option(NINJA_FORCE_PSELECT "Use pselect() even on platforms that provide ppoll()" OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you default this to OFF?


project(ninja CXX)
Expand Down Expand Up @@ -122,6 +123,18 @@ set(NINJA_PYTHON "python" CACHE STRING "Python interpreter to use for the browse

check_platform_supports_browse_mode(platform_supports_ninja_browse)

if(NINJA_BUILD_DOC)
find_program(Asciidoc_Executable asciidoc)

find_package(LibXslt REQUIRED)

if(NOT Asciidoc_Executable OR NOT TARGET LibXslt::xsltproc)
message(SEND_ERROR "asciidoc and xsltproc are required to build the documentation")
else()
add_subdirectory(doc)
endif()
endif()

# Core source files all build into ninja library.
add_library(libninja OBJECT
src/build_log.cc
Expand Down
17 changes: 17 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
add_custom_command(OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/manual.xml"
COMMAND
asciidoc --backend=docbook --doctype=book --out-file "${CMAKE_CURRENT_BINARY_DIR}/manual.xml" "${CMAKE_CURRENT_SOURCE_DIR}/manual.asciidoc"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing DEPENDS for the input, doesn't it?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
asciidoc --backend=docbook --doctype=book --out-file "${CMAKE_CURRENT_BINARY_DIR}/manual.xml" "${CMAKE_CURRENT_SOURCE_DIR}/manual.asciidoc"
${Asciidoc_Executable} --backend=docbook --doctype=book --out-file "${CMAKE_CURRENT_BINARY_DIR}/manual.xml" "${CMAKE_CURRENT_SOURCE_DIR}/manual.asciidoc"

to be safe?

)

add_custom_command(DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/manual.xml"
OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/manual.html"
COMMAND
LibXslt::xsltproc --nonet "${CMAKE_CURRENT_SOURCE_DIR}/docbook.xsl" manual.xml > "${CMAKE_CURRENT_BINARY_DIR}/manual.html"
)

add_custom_target(doc ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/manual.html")

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/manual.html" TYPE DOC)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of this?

Loading