This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathCMakeLists.txt
133 lines (105 loc) · 4.77 KB
/
CMakeLists.txt
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
#
# Part of the KiCad ASCIIDOC Documentation Project
#
# (c)2015 KiCad Developers
# (c)2015 Brian Sidebotham <[email protected]>
#
# Require CMake V2.8 as a minimum. You can experiment with setting this lower if that's all you
# have available, but it's not guaranteed to work or be supported.
cmake_minimum_required( VERSION 2.8 )
project( KiCadDocumentation NONE )
# Provide an option for deciding which PDF generation scheme to use
# Desired targets are DBLATEX,FOP and ASCIIDOCTOR-PDF
set( PDF_GENERATOR "DBLATEX" CACHE STRING "Specify which PDF generator to use: DBLATEX|FOP" )
# Provide an option to limit the set of languages built. This helps developers to speed up a
# build they're working on, or limit the number of dependencies for packagers
set( LANGUAGES "" CACHE LIST "Specify languages to build: ca;de;en;es;fr;id;it;ja;nl;pl;ru;zh" )
# Provide an option to decide which documentation formats to build.
set( BUILD_FORMATS "html;pdf;epub" CACHE LIST "Specify which output formats to build html/pdf/epub" )
# Add our custom modules to the module path
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules" ${CMAKE_MODULE_PATH} )
# Include the Asciidoc target helpers
include( AsciidocHelpers )
# Add the common asciidoc options
add_adoc_option( -b html5 )
add_adoc_option( -a toc2 )
add_adoc_option( --section-numbers )
add_adoc_option( --theme flask )
# Add the common a2x options
add_a2x_option( --xsltproc-opts=--nonet )
add_a2x_option( --no-xmllint )
add_a2x_option( -f pdf )
#add_a2x_option( --verbose )
if( "${BUILD_FORMATS}" MATCHES "(p|P)(d|D)(f|F)" )
# Add a2x options depending on which PDF generator we're using
if( ${PDF_GENERATOR} MATCHES DBLATEX )
set_dblatex_common_options()
find_package( DBLATEX REQUIRED )
endif()
if( ${PDF_GENERATOR} MATCHES FOP )
add_a2x_option( --fop )
add_a2x_option( --xsl-file ${PROJECT_SOURCE_DIR}/xsl/kicad.xsl )
find_package( FOP REQUIRED )
endif()
if( ${PDF_GENERATOR} MATCHES ASCIIDOCTORPDF )
message( FATAL_ERROR "AsciiDoctor-pdf is not currently supported!" )
# Discover if the AsciiDoctor toolchain is available
# find_package( ASCIIDOCTOR )
# find_package( ASCIIDOCTORPDF )
endif()
endif()
# Discover if the PO4A package is available
find_package( PO4A REQUIRED )
# Discover if the Asciidoc toolchain is available
find_package( ASCIIDOC REQUIRED )
find_package( A2X REQUIRED )
include( KiCadDocumentation )
add_subdirectory( src )
# Start with the package version being unknown, then prove otherwise
set( CPACK_PACKAGE_VERSION "unknown" )
# Use Git to determine parts of the package name
find_package( Git )
if( GIT_FOUND )
# Discover information about the build (AT CONFIGURE TIME, not as a target that updates in
# subsequent builds)
execute_process( COMMAND "${GIT_EXECUTABLE}" describe --tags
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE git_tags_output
RESULT_VARIABLE git_tags_result
ERROR_VARIABLE git_tags_error
OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process( COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE git_branch_output
RESULT_VARIABLE git_branch_result
ERROR_VARIABLE git_branch_error
OUTPUT_STRIP_TRAILING_WHITESPACE )
message (STATUS "On branch ${git_branch_output} with tag ${git_tags_output}" )
# Due to how tags work in Git it's necessary for us to ensure a few things. For a start, if we
# create a new branch, switch to it and create a tag, that tag becomes visible in the master
# branch. Make sure if we're on the master branch that we use that in the
if( "${git_branch_output}" STREQUAL "master" )
# TODO: Should we include a 6-digit hash here too?
set( CPACK_PACKAGE_VERSION "HEAD" )
else()
if( NOT "${git_tags_output}" STREQUAL "" )
set( CPACK_PACKAGE_VERSION ${git_tags_output} )
endif()
endif()
message (STATUS "Setting package version to ${CPACK_PACKAGE_VERSION}")
endif()
# Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
set( KICAD_DOC_INSTALL_PATH share/doc/kicad
CACHE PATH "Install path of KiCad documentation files relative to CMAKE_INSTALL_PREFIX." )
# If there is more than one build format, do not bother transforming the
# package name, otherwise if there's only one, add it to the package name
list( LENGTH BUILD_FORMATS BUILD_FORMATS_LENGTH )
if( ${BUILD_FORMATS_LENGTH} GREATER 1 )
set( PACKAGE_BUILD_FORMAT "" )
else()
set( PACKAGE_BUILD_FORMAT "-${BUILD_FORMATS}" )
endif()
# Generate both .tar.gz package target
set( CPACK_GENERATOR "TGZ" )
set( CPACK_PACKAGE_FILE_NAME "kicad-doc${PACKAGE_BUILD_FORMAT}-${CPACK_PACKAGE_VERSION}" )
include( CPack )