2015-04-25 21:42:51 +00:00
|
|
|
#
|
|
|
|
|
# CMakeLists.txt to build docs for the FLTK project using CMake (www.cmake.org)
|
|
|
|
|
#
|
2025-12-30 14:49:02 +00:00
|
|
|
# Copyright 1998-2025 by Bill Spitzak and others.
|
2015-04-25 21:42:51 +00:00
|
|
|
#
|
|
|
|
|
# This library is free software. Distribution and use rights are outlined in
|
|
|
|
|
# the file "COPYING" which should have been included with this file. If this
|
|
|
|
|
# file is missing or damaged, see the license at:
|
|
|
|
|
#
|
2020-01-26 14:06:46 +00:00
|
|
|
# https://www.fltk.org/COPYING.php
|
2015-04-25 21:42:51 +00:00
|
|
|
#
|
2020-07-01 16:03:10 +00:00
|
|
|
# Please see the following page on how to report bugs and issues:
|
2015-04-25 21:42:51 +00:00
|
|
|
#
|
2020-07-01 16:03:10 +00:00
|
|
|
# https://www.fltk.org/bugs.php
|
2015-04-25 21:42:51 +00:00
|
|
|
#
|
|
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
set(DOCS)
|
|
|
|
|
set(GENERATE_DOCS FALSE)
|
|
|
|
|
set(YEAR "")
|
|
|
|
|
set(CURRENT_DATE "")
|
|
|
|
|
|
|
|
|
|
if(FLTK_BUILD_HTML_DOCS OR FLTK_BUILD_PDF_DOCS)
|
|
|
|
|
set(GENERATE_DOCS TRUE)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(FLTK_INCLUDE_DRIVER_DOCS)
|
|
|
|
|
set(DRIVER_DOCS "DriverDev")
|
|
|
|
|
else()
|
|
|
|
|
set(DRIVER_DOCS "")
|
|
|
|
|
endif()
|
2018-12-29 19:04:38 +00:00
|
|
|
|
2022-08-10 16:51:53 +00:00
|
|
|
#------------------------------------------------
|
|
|
|
|
# generate files used for both HTML and PDF docs
|
|
|
|
|
#------------------------------------------------
|
|
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
if(GENERATE_DOCS)
|
2022-08-10 16:51:53 +00:00
|
|
|
|
|
|
|
|
# create required variables
|
|
|
|
|
|
2025-03-31 00:56:57 +00:00
|
|
|
string(TIMESTAMP YEAR "%Y" UTC)
|
2022-08-10 16:51:53 +00:00
|
|
|
# note: current locale is used for abbreviated month
|
2025-03-31 00:56:57 +00:00
|
|
|
string(TIMESTAMP CURRENT_DATE "%b %d, %Y" UTC)
|
|
|
|
|
string(TIMESTAMP PDF_DATE "D:%Y%m%d%H%M%SZ" UTC)
|
|
|
|
|
string(TIMESTAMP TODAY "%B %d, %Y" UTC)
|
|
|
|
|
string(REPLACE " 0" " " TODAY "${TODAY}")
|
2022-08-10 16:51:53 +00:00
|
|
|
|
2023-09-07 16:28:55 +00:00
|
|
|
# Find "short" doxygen version if it was built from Git
|
2024-08-12 17:58:32 +00:00
|
|
|
# Note: this is still needed in CMake 3.15 but later CMake versions
|
2023-09-07 16:28:55 +00:00
|
|
|
# (notably 3.25) remove the Git revision in 'DOXYGEN_VERSION'.
|
|
|
|
|
# Todo: Find the "first good" CMake version and remove this redundant
|
|
|
|
|
# code once we require this as our minimal version and replace the
|
|
|
|
|
# variable DOXYGEN_VERSION_SHORT with DOXYGEN_VERSION below.
|
2022-10-03 08:49:43 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
if(DOXYGEN_FOUND)
|
2022-10-03 08:49:43 +00:00
|
|
|
# strip trailing git revision if doxygen was built from source
|
2024-02-07 17:30:11 +00:00
|
|
|
string(REGEX REPLACE " .*$" "" DOXYGEN_VERSION_SHORT ${DOXYGEN_VERSION})
|
|
|
|
|
endif(DOXYGEN_FOUND)
|
2022-08-10 16:51:53 +00:00
|
|
|
|
2025-05-07 19:14:10 +00:00
|
|
|
# configure version.dox (includes the bare FLTK version number)
|
|
|
|
|
configure_file(
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/version.dox.in
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/version.dox
|
|
|
|
|
@ONLY
|
|
|
|
|
)
|
|
|
|
|
|
2022-08-10 16:51:53 +00:00
|
|
|
# configure copyright.dox (includes current year)
|
2024-02-07 17:30:11 +00:00
|
|
|
configure_file(
|
2022-08-10 16:51:53 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/copyright.dox.in
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/copyright.dox
|
|
|
|
|
@ONLY
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# configure generated.dox (includes date and versions)
|
2024-02-07 17:30:11 +00:00
|
|
|
configure_file(
|
2022-08-10 16:51:53 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/generated.dox.in
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/generated.dox
|
|
|
|
|
@ONLY
|
|
|
|
|
)
|
|
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
if(0) # debug
|
|
|
|
|
fl_debug_var(YEAR)
|
|
|
|
|
fl_debug_var(CURRENT_DATE)
|
2025-03-31 00:56:57 +00:00
|
|
|
fl_debug_var(PDF_DATE)
|
|
|
|
|
fl_debug_var(TODAY)
|
2024-08-12 17:58:32 +00:00
|
|
|
fl_debug_var(FLTK_GIT_REVISION)
|
2024-02-07 17:30:11 +00:00
|
|
|
fl_debug_var(DOXYGEN_FOUND)
|
|
|
|
|
fl_debug_var(DOXYGEN_EXECUTABLE)
|
|
|
|
|
fl_debug_var(DOXYGEN_VERSION)
|
|
|
|
|
fl_debug_var(DOXYGEN_VERSION_SHORT)
|
|
|
|
|
endif()
|
2022-10-03 08:49:43 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
endif(GENERATE_DOCS)
|
2022-08-10 16:51:53 +00:00
|
|
|
|
2015-04-25 21:42:51 +00:00
|
|
|
#--------------------------
|
|
|
|
|
# build html documentation
|
|
|
|
|
#--------------------------
|
|
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
if(FLTK_BUILD_HTML_DOCS)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
list(APPEND DOCS html)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2020-06-13 13:19:27 +00:00
|
|
|
# generate Doxygen file "Doxyfile"
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
set(GENERATE_HTML YES)
|
|
|
|
|
set(GENERATE_LATEX NO)
|
2025-12-28 20:37:23 +00:00
|
|
|
set(EXTRA_SECTIONS "HTML_SECTIONS")
|
2024-02-07 17:30:11 +00:00
|
|
|
set(LATEX_HEADER "")
|
|
|
|
|
set(DOXYFILE "Doxyfile")
|
|
|
|
|
set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log")
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2021-09-21 18:28:02 +00:00
|
|
|
# configure Doxygen input file for HTML docs (Doxyfile.in)
|
|
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
configure_file(
|
2020-06-13 13:19:27 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
|
2023-09-07 16:28:55 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}.in
|
2020-06-13 13:19:27 +00:00
|
|
|
@ONLY
|
|
|
|
|
)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2023-09-07 16:28:55 +00:00
|
|
|
# convert Doxyfile to used doxygen version
|
2021-09-21 18:28:02 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
add_custom_command(
|
2023-09-07 16:28:55 +00:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}
|
2021-09-21 18:28:02 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
2023-09-07 16:28:55 +00:00
|
|
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/convert_doxyfile
|
|
|
|
|
${DOXYGEN_EXECUTABLE}
|
|
|
|
|
${DOXYFILE}.in
|
|
|
|
|
${DOXYFILE}
|
|
|
|
|
${LOGFILE}
|
2023-09-07 11:41:47 +00:00
|
|
|
BYPRODUCTS ${LOGFILE}
|
2023-09-07 16:28:55 +00:00
|
|
|
COMMENT "Converting ${DOXYFILE} to doxygen version ${DOXYGEN_VERSION_SHORT}" VERBATIM
|
2020-06-13 13:19:27 +00:00
|
|
|
)
|
2019-09-16 15:17:54 +00:00
|
|
|
|
2021-09-21 18:28:02 +00:00
|
|
|
# generate HTML documentation
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
add_custom_target(html
|
2023-09-07 16:28:55 +00:00
|
|
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
|
|
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}
|
2020-06-13 13:19:27 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
|
COMMENT "Generating HTML documentation" VERBATIM
|
|
|
|
|
)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
endif(FLTK_BUILD_HTML_DOCS)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
|
|
|
|
#--------------------------
|
|
|
|
|
# build pdf documentation
|
|
|
|
|
#--------------------------
|
|
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
if(FLTK_BUILD_PDF_DOCS)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
list(APPEND DOCS pdf)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2021-09-21 18:28:02 +00:00
|
|
|
# generate Doxygen input file "Doxybook"
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
set(GENERATE_HTML NO)
|
|
|
|
|
set(GENERATE_LATEX YES)
|
2025-12-28 20:37:23 +00:00
|
|
|
set(EXTRA_SECTIONS "LATEX_SECTIONS")
|
2024-02-07 17:30:11 +00:00
|
|
|
set(LATEX_HEADER "${CMAKE_CURRENT_BINARY_DIR}/fltk-book.tex")
|
|
|
|
|
set(DOXYFILE "Doxybook")
|
|
|
|
|
set(LOGFILE "${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}_error.log")
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2025-12-28 21:18:07 +00:00
|
|
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated)
|
|
|
|
|
|
2021-09-21 18:28:02 +00:00
|
|
|
# configure Doxygen input file for PDF docs (Doxybook.in)
|
|
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
configure_file(
|
2020-06-13 13:19:27 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
|
2023-09-07 16:28:55 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}.in
|
2020-06-13 13:19:27 +00:00
|
|
|
@ONLY
|
|
|
|
|
)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2021-09-21 18:28:02 +00:00
|
|
|
# convert Doxybook to current doxygen version
|
|
|
|
|
|
2024-10-17 14:01:32 +00:00
|
|
|
# set DOXY_VERSION for compatibility with configure/make,
|
|
|
|
|
# to be replaced in fltk-title.tex.in
|
|
|
|
|
# FIXME: this can be simplified when configure/make is no longer supported
|
|
|
|
|
|
|
|
|
|
set(DOXY_VERSION "${DOXYGEN_VERSION_SHORT}") #
|
|
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
add_custom_command(
|
2023-09-07 16:28:55 +00:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}
|
2021-09-21 18:28:02 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
2023-09-07 16:28:55 +00:00
|
|
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/convert_doxyfile
|
|
|
|
|
${DOXYGEN_EXECUTABLE}
|
|
|
|
|
${DOXYFILE}.in
|
|
|
|
|
${DOXYFILE}
|
|
|
|
|
${LOGFILE}
|
2023-09-07 11:41:47 +00:00
|
|
|
BYPRODUCTS ${LOGFILE}
|
2023-09-07 16:28:55 +00:00
|
|
|
COMMENT "Converting ${DOXYFILE} to doxygen version ${DOXYGEN_VERSION_SHORT}" VERBATIM
|
2021-09-21 18:28:02 +00:00
|
|
|
)
|
|
|
|
|
|
2025-03-31 00:56:57 +00:00
|
|
|
# generate LaTeX title fltk-title.tex and make_pdf script
|
2021-02-15 18:45:20 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
configure_file(
|
2025-12-30 14:49:02 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/fltk-title.tex.in
|
2020-09-20 12:44:14 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex
|
2020-06-13 13:19:27 +00:00
|
|
|
@ONLY
|
|
|
|
|
)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2025-03-31 00:56:57 +00:00
|
|
|
configure_file(
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/make_pdf.in
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/make_pdf
|
|
|
|
|
@ONLY
|
|
|
|
|
)
|
|
|
|
|
|
2025-12-29 19:02:06 +00:00
|
|
|
# Generate code snapshots (images with international characters).
|
|
|
|
|
# Note: File names (even from different folders) must be unique !
|
|
|
|
|
|
|
|
|
|
set(image_output_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
|
|
|
|
set(_deps)
|
|
|
|
|
set(image_input_sources
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/unicode.dox
|
2025-12-30 14:49:02 +00:00
|
|
|
# ${CMAKE_CURRENT_SOURCE_DIR}/src/cmp.dox # more documentation files
|
|
|
|
|
# ${FLTK_SOURCE_DIR}/src/Fl.cxx # example source file
|
2025-12-29 19:02:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Generate one custom command and one timestamp per input file
|
|
|
|
|
# so dependencies can be used to generate the images only if
|
|
|
|
|
# the source file was changes.
|
|
|
|
|
# Variable `_deps` is used to make the final PDF generation
|
|
|
|
|
# depend on all input files.
|
|
|
|
|
|
|
|
|
|
foreach(_infile ${image_input_sources})
|
|
|
|
|
get_filename_component(_name "${_infile}" NAME)
|
|
|
|
|
set(_timestamp ${image_output_dir}/${_name}.timestamp)
|
|
|
|
|
list(APPEND _deps ${_timestamp})
|
|
|
|
|
# create custom command
|
|
|
|
|
add_custom_command(
|
|
|
|
|
OUTPUT ${_timestamp}
|
|
|
|
|
COMMAND touch ${_timestamp}
|
|
|
|
|
COMMAND code_snapshot ${_infile}
|
|
|
|
|
DEPENDS ${_infile}
|
|
|
|
|
WORKING_DIRECTORY ${image_output_dir}
|
|
|
|
|
COMMENT "Generating code snapshots (PNG) from '${_infile}'"
|
|
|
|
|
)
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
# Now generate the PDF file (fltk.pdf)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
add_custom_command(
|
2020-06-13 13:19:27 +00:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf
|
2020-09-20 12:44:14 +00:00
|
|
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make_header
|
2023-08-29 15:25:10 +00:00
|
|
|
${DOXYGEN_EXECUTABLE}
|
2020-09-20 12:44:14 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/fltk-book.tex
|
2023-09-07 16:28:55 +00:00
|
|
|
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
|
2025-03-31 00:56:57 +00:00
|
|
|
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/make_pdf
|
2020-06-13 13:19:27 +00:00
|
|
|
COMMAND cp -f latex/refman.pdf fltk.pdf
|
2025-12-29 19:02:06 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}.in
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${DOXYFILE}
|
2021-09-21 18:28:02 +00:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/fltk-title.tex
|
2025-12-29 19:02:06 +00:00
|
|
|
${_deps} # source files processed to generate PNG's
|
2020-06-13 13:19:27 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
|
COMMENT "Generating PDF documentation" VERBATIM
|
|
|
|
|
)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2020-06-13 13:19:27 +00:00
|
|
|
# add target 'pdf'
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
add_custom_target(pdf
|
2020-06-13 13:19:27 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf
|
|
|
|
|
)
|
2025-12-28 20:37:23 +00:00
|
|
|
add_dependencies(pdf code_snapshot)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
endif(FLTK_BUILD_PDF_DOCS)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
|
|
|
|
#----------------------------------
|
|
|
|
|
# add target 'docs' for all docs
|
|
|
|
|
#----------------------------------
|
|
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
if(DOCS)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
add_custom_target(docs
|
2020-06-13 13:19:27 +00:00
|
|
|
DEPENDS ${DOCS}
|
|
|
|
|
)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
endif(DOCS)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
|
|
|
|
#----------------------------------
|
|
|
|
|
# install html + pdf documentation
|
|
|
|
|
#----------------------------------
|
|
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
if(FLTK_INSTALL_HTML_DOCS AND FLTK_BUILD_HTML_DOCS)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
|
2020-06-13 13:19:27 +00:00
|
|
|
DESTINATION ${FLTK_DATADIR}/doc/fltk
|
|
|
|
|
)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
endif(FLTK_INSTALL_HTML_DOCS AND FLTK_BUILD_HTML_DOCS)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
if(FLTK_INSTALL_PDF_DOCS AND FLTK_BUILD_PDF_DOCS)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fltk.pdf
|
2020-06-13 13:19:27 +00:00
|
|
|
DESTINATION ${FLTK_DATADIR}/doc/fltk/
|
|
|
|
|
)
|
2015-04-25 21:42:51 +00:00
|
|
|
|
2024-02-07 17:30:11 +00:00
|
|
|
endif(FLTK_INSTALL_PDF_DOCS AND FLTK_BUILD_PDF_DOCS)
|