File: CMakeLists.txt

package info (click to toggle)
wxmaxima 20.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 46,476 kB
  • sloc: cpp: 77,833; xml: 10,445; ansic: 3,583; lisp: 1,837; makefile: 13; sh: 7
file content (146 lines) | stat: -rw-r--r-- 7,232 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# -*- mode: CMake; cmake-tab-width: 4; -*-


find_program(PANDOC pandoc)
if(PANDOC)
	message(STATUS "Found pandoc: ${PANDOC}")

	# "make pdf" creates the manual in PDF form. The other targets that now
	# follow do the same for other formats
	add_custom_target(pdf)
	add_custom_target(epub)
	add_custom_target(html ALL)

	function(generate_wxmaxima_documentation_html FILEBASENAME)
		add_custom_command(
			OUTPUT ${FILEBASENAME}.html
			DEPENDS ${FILEBASENAME}.md
			COMMAND ${PANDOC} ${FILEBASENAME}.md -t html4 "--include-in-header=${CMAKE_CURRENT_SOURCE_DIR}/header.html" -o ${FILEBASENAME}.html --number-sections --table-of-contents --standalone --css=wxmaxima.css --metadata title="wxMaxima"
			COMMENT "Generating ${FILEBASENAME}.html")
		add_custom_target(build_${FILEBASENAME}.html DEPENDS ${FILEBASENAME}.html)
		add_dependencies(html build_${FILEBASENAME}.html)
		install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${FILEBASENAME}.html" DESTINATION share/doc/wxmaxima OPTIONAL)
	endfunction()

	function(generate_wxmaxima_documentation_pdf FILEBASENAME PANDOC_TEXSELECT_OPTION)
		add_custom_command(
			OUTPUT ${FILEBASENAME}.pdf
			DEPENDS ${FILEBASENAME}.md
			COMMAND ${PANDOC} ${FILEBASENAME}.md -t latex -o ${FILEBASENAME}.pdf --number-sections --table-of-contents --standalone --metadata title="wxMaxima" ${PANDOC_TEXSELECT_OPTION}
			COMMENT "Generating ${FILEBASENAME}.pdf")
		add_custom_target(build_${FILEBASENAME}.pdf DEPENDS ${FILEBASENAME}.pdf)
		add_dependencies(pdf build_${FILEBASENAME}.pdf)
		install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${FILEBASENAME}.pdf" DESTINATION share/doc/wxmaxima OPTIONAL)
	endfunction()

	function(generate_wxmaxima_documentation_epub FILEBASENAME)
		add_custom_command(
			OUTPUT ${FILEBASENAME}.epub
			DEPENDS ${FILEBASENAME}.md
			COMMAND ${PANDOC} ${FILEBASENAME}.md -t epub -o ${FILEBASENAME}.epub --number-sections --table-of-contents --standalone --css=wxmaxima.css --metadata title="wxMaxima"
			COMMENT "Generating ${FILEBASENAME}.epub")
		add_custom_target(build_${FILEBASENAME}.epub DEPENDS ${FILEBASENAME}.epub)
		add_dependencies(epub build_${FILEBASENAME}.epub)
		install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${FILEBASENAME}.epub" DESTINATION share/doc/wxmaxima OPTIONAL)
	endfunction()

	# Create a list of the common part of the name of all the translated manuals.
	# The "list(TRANSFORM" type of commands only is available in very new cmake
	# versions and therefore (in 2019) of only limited use so we'll have to do
	# this by hand.
	set(BASENAMES "")
	file(GLOB POFILES ${CMAKE_SOURCE_DIR}/locales/manual/*.po)
	foreach(POFILE ${POFILES})
		string(REGEX REPLACE ".*/(.*).po$" "wxmaxima.\\1" BASENAME ${POFILE})
		list(APPEND BASENAMES ${BASENAME})
	endforeach()

	# Find a suitable LaTeX installation
	find_package(LATEX COMPONENTS XELATEX LUALATEX)
        if(LATEX_XELATEX_FOUND)
            set(WXMAXIMA_LATEX_COMMAND "${XELATEX_COMPILER}")
        elseif(LATEX_LUALATEX_FOUND)
            set(WXMAXIMA_LATEX_COMMAND "${LUALATEX_COMPILER}")
        else()
            message(${NONCRIT_WARNING} "Xelatex or Lualatex not found. PDF documentation can not be converted from Markdown.")
	endif()

	find_program(PO4A_TRANSLATE po4a-translate)
	if(PO4A_TRANSLATE)
		# Get po4a-translate version number, only >= 0.55 works for wxMaxima.
		execute_process(COMMAND ${PO4A_TRANSLATE} --version
			OUTPUT_VARIABLE PO4A_TRANSLATE_VERSION_TEXT)
		string(REGEX REPLACE "^po4a-translate version ([^\n]*).*" "\\1"  PO4A_TRANSLATE_VERSION "${PO4A_TRANSLATE_VERSION_TEXT}")
		string(REGEX REPLACE "\\.$" ""  PO4A_TRANSLATE_VERSION "${PO4A_TRANSLATE_VERSION}") # remove trailing dot.
		message(STATUS "Found po4a-translate: ${PO4A_TRANSLATE} (found version \"${PO4A_TRANSLATE_VERSION}\")")
		if(PO4A_TRANSLATE_VERSION VERSION_LESS 0.55)
			message(WARNING "po4a-translate Version < 0.55 found. Please upgrade po4a, that version does not work. "
							"Disable po4a and the generation of localized documentation.")
			set(PO4A_TRANSLATE "")
		endif()
	else()
		message(STATUS "po4a-translate not found. Disable the generation of localized documentation.")
	endif()


	file(GLOB IMAGEFILES ${CMAKE_CURRENT_SOURCE_DIR}/*.png ${CMAKE_CURRENT_SOURCE_DIR}/*.jpg)
	file(COPY ${IMAGEFILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
	file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/wxmaxima.md DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

	generate_wxmaxima_documentation_html("wxmaxima")
	generate_wxmaxima_documentation_epub("wxmaxima")
	if(WXMAXIMA_LATEX_COMMAND)
		execute_process(
			COMMAND ${PANDOC} --version
			OUTPUT_VARIABLE PANDOC_VERSION_TEXT)
		# get pandoc major version number, if >=2 use --pdf-engine else --latex-engine (they changed the name of the command line option)
		string(REGEX REPLACE "^pandoc ([0-9]).*$" "\\1" PANDOC_VERSION ${PANDOC_VERSION_TEXT})
		if(PANDOC_VERSION LESS_EQUAL 1)
			message(STATUS "pandoc version < 2 found - using option --latex-engine=${WXMAXIMA_LATEX_COMMAND}")
			set(PANDOC_TEXSELECT_OPTION "--latex-engine=${WXMAXIMA_LATEX_COMMAND}")
		else()
			message(STATUS "pandoc version >= 2 found - using option --pdf-engine=${WXMAXIMA_LATEX_COMMAND}")
			set(PANDOC_TEXSELECT_OPTION "--pdf-engine=${WXMAXIMA_LATEX_COMMAND}")
		endif()
		generate_wxmaxima_documentation_pdf("wxmaxima" "${PANDOC_TEXSELECT_OPTION}")
    endif()

	if(PO4A_TRANSLATE)
		foreach(BASENAME ${BASENAMES})
			string(REGEX REPLACE "wxmaxima.(.*)$" "\\1" LANG ${BASENAME})
			string(REGEX REPLACE "wxmaxima$" "" LANG ${LANG})

			add_custom_command(
				OUTPUT ${BASENAME}.md
				DEPENDS ${CMAKE_SOURCE_DIR}/locales/manual/${LANG}.po ${CMAKE_CURRENT_SOURCE_DIR}/wxmaxima.md
				COMMAND ${PO4A_TRANSLATE} -k 0 -f text -o markdown -m ${CMAKE_CURRENT_SOURCE_DIR}/wxmaxima.md -p ${CMAKE_SOURCE_DIR}/locales/manual/${LANG}.po -l ${BASENAME}.md -M UTF-8)

			generate_wxmaxima_documentation_html("${BASENAME}")
			generate_wxmaxima_documentation_epub("${BASENAME}")
			if(WXMAXIMA_LATEX_COMMAND)
				generate_wxmaxima_documentation_pdf("${BASENAME}" "${PANDOC_TEXSELECT_OPTION}")
			endif()
		endforeach()
	else()
		foreach(BASENAME ${BASENAMES})
			install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${BASENAME}.html DESTINATION share/doc/wxmaxima)
		endforeach()
	endif()
else()
    message(WARNING "Pandoc not found. Documentation can not be converted from Markdown. Included HTML documentation will be installed.")
	file(GLOB WXMAXIMA_HTML_HELP "${CMAKE_CURRENT_SOURCE_DIR}/*.html")
	install(FILES ${WXMAXIMA_HTML_HELP} DESTINATION share/doc/wxmaxima)
	file(COPY ${WXMAXIMA_HTML_HELP} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
endif()

set(HTMLHELP_ADDITIONAL_FILES wxmaxima.css Autocomplete1.jpg Autocomplete2.jpg
                              BatchImage.png cell-example.png ezUnits.png InputCell.png MatrixTableExample.png
                              maxima_screenshot.png sbclMemory.png SecondTableExample.png SidePanes.png
                              wxMaxima_configuration_001.png wxMaximaLogo.png wxMaximaWindow.png wxmaxima.svg)
foreach(CURRENTFILE ${HTMLHELP_ADDITIONAL_FILES})
	install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${CURRENTFILE}" DESTINATION share/doc/wxmaxima)
	file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${CURRENTFILE}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
endforeach()