summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: 2fc65e44072038c4f957714c3b6cfa6af2f8098a (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
#################################################
#
#  (C) 2013 Alexander Golubev (Fat-Zer)
#  fatzer2 (AT) gmail.com
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

cmake_minimum_required( VERSION 3.1 )


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

project( k3b-i18n )
set( VERSION R14.0.12 )


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

include( FindPkgConfig ) # required for find_package( TDE )


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

set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
include( TDEMacros )


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

find_package( TDE )


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

include( TDESetupPaths )
tde_setup_paths( )

option( BUILD_DOC "Build documentation" ON )
option( BUILD_MESSAGES "Build message and GUI translation" ON )

string( REGEX REPLACE "[ \r\n\t]+" ";" _linguas "$ENV{LINGUAS}" )


###### build documentations for all languages ###

if( BUILD_DOC )
  file( GLOB_RECURSE _doc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} */doc/* )
  foreach( _doc_file IN LISTS _doc_files )
    get_filename_component( _dir ${_doc_file} PATH )
    list( APPEND _dirs ${_dir} )
  endforeach()
  if( _dirs )
    list( SORT _dirs )
    list( REMOVE_DUPLICATES _dirs )
  endif()

  foreach( _doc_dir IN LISTS _dirs )
    string( REGEX REPLACE "/.*" "" _lang ${_doc_dir} )
    if( NOT ${_lang} MATCHES "^(html|man|misc|other)$"
        AND ( ${_lang} STREQUAL "en" OR
              "${_linguas}" MATCHES "^;*$" OR
              ";${_linguas};" MATCHES ";${_lang};" ))

      file( GLOB _doc_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${_doc_dir} ${_doc_dir}/*.docbook )
      if( ${_doc_dir} MATCHES "^${_lang}/doc/[^/]*/" )
        string( REGEX REPLACE "^${_lang}/doc/(.*)" "\\1" _doc_dest "${_doc_dir}" )
      else()
        string( REGEX REPLACE "^${_lang}/doc/(.*)" "\\1" _doc_dest "${_doc_dir}/k3b" )
      endif()
      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}/*.jpg ${_doc_dir}/*.png )
        install(
          FILES ${_doc_files}
          DESTINATION ${HTML_INSTALL_DIR}/${_lang}/${_doc_dest}
        )
      endif()
    endif()
  endforeach()

endif()


###### build translations for all languages #####

if( BUILD_MESSAGES )
  file( GLOB_RECURSE po_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} */messages/*.po )

  foreach( _po ${po_files} )
    string( REGEX REPLACE "/.*" "" _lang ${_po} )
    if( "${_linguas}" MATCHES "^;*$" OR ";${_linguas};" MATCHES ";${_lang};" )
      tde_create_translation( FILES ${_po} LANG ${_lang} )
    endif()
  endforeach( )
endif( )