summaryrefslogtreecommitdiffstats
path: root/template/commonCMakeLists.txt
blob: b628bf0545efb9c0dc1586e4cb8ac1fe07a60177 (plain)
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
#################################################
#
#  (C) 2013 Alexander Golubev (Fat-Zer)
#  fatzer2 (AT) gmail.com
#
#  (C) 2020-2022 Slávek Banko
#  slavek.banko (AT) axis.cz
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

cmake_minimum_required( VERSION 3.1 )


##### general package setup #####################

string( REGEX REPLACE ".*-([^-]*)$" "\\1" _lang ${CMAKE_CURRENT_SOURCE_DIR} )
message( STATUS "Configure for language ${_lang}" )

project( koffice-i18n-${_lang} )


##### include essential cmake modules ###########

include( FindPkgConfig ) # required for find_package( TDE )


##### include our cmake modules #################

include( TDEMacros )


##### find required stuff #######################

find_package( TDE )


##### setup install paths #######################

tde_save_and_set( CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "${_lang}" )
include( TDESetupPaths )
tde_setup_paths( )


##### user requested modules ####################

option( BUILD_ALL "Build all" OFF )
option( BUILD_DOC "Build documentation" ${BUILD_ALL} )
option( BUILD_DATA "Build data" ${BUILD_ALL} )
option( BUILD_MESSAGES "Build message and GUI translation" ${BUILD_ALL} )


###### subdirectories ###########################

# build data files
if( BUILD_DATA AND
    EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/data/CMakeLists.txt )
  add_subdirectory( data )
endif()


# build documentation
if( BUILD_DOC )
  # search directories with documentation
  file( GLOB_RECURSE _doc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} docs/* )
  foreach( _doc_file IN LISTS _doc_files )
    get_filename_component( _doc_dir ${_doc_file} PATH )
    list( APPEND _doc_dirs ${_doc_dir} )
  endforeach()
  if( _doc_dirs )

    # sort and clear the list of directories
    list( SORT _doc_dirs )
    list( REMOVE_DUPLICATES _doc_dirs )
    list( REMOVE_ITEM _doc_dirs "docs/common" )

    # create handbooks or install other files
    foreach( _doc_dir IN LISTS _doc_dirs )
      file( GLOB _doc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${_doc_dir} ${_doc_dir}/*.docbook )
      string( REGEX REPLACE "^[^/]*/[^/]*/" "" _doc_dest ${_doc_dir} )
      if( _doc_files )
        list( FIND _doc_files "index.docbook" _find_index )
        if( -1 EQUAL _find_index )
          set( _noindex "NOINDEX" )
        else()
          unset( _noindex )
        endif()
        tde_create_handbook(
          SOURCE_BASEDIR ${_doc_dir}
          ${_noindex}
          LANG ${_lang}
          DESTINATION ${_doc_dest}
        )
      else()
        file( GLOB _doc_files
              RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
              ${_doc_dir}/*.css ${_doc_dir}/*.png )
        install(
          FILES ${_doc_files}
          DESTINATION ${HTML_INSTALL_DIR}/${_lang}/${_doc_dest}
        )
      endif()
    endforeach()
  endif()
endif()


# build messages
if( BUILD_MESSAGES )
  # install base files for locale
  file( GLOB locale_base_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
        messages/flag.png messages/charset )
  if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/messages/entry.desktop )
    tde_create_translated_desktop(
      SOURCE messages/entry.desktop
      DESTINATION ${LOCALE_INSTALL_DIR}/${_lang}
      PO_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../translations/desktop_files/entry.desktop
    )
  endif()
  if( locale_base_files )
    install(
      FILES ${locale_base_files}
      DESTINATION ${LOCALE_INSTALL_DIR}/${_lang}
    )
  endif()

  # create translations
  file( GLOB_RECURSE _messages RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} messages/*.po )
  if( _messages )
    tde_create_translation( FILES ${_messages} LANG ${_lang} )
  endif()
endif()


# restore default install component name

tde_restore( CMAKE_INSTALL_DEFAULT_COMPONENT_NAME )