summaryrefslogtreecommitdiffstats
path: root/modules/TDESetupPaths.cmake
blob: b28f09804d0664267804f3867c96900971072cfa (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#################################################
#
#  (C) 2010 Serghei Amelian
#  serghei (DOT) amelian (AT) gmail.com
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

#################################################
#####
##### __tde_internal_setup_paths_status

macro( __tde_internal_setup_paths_status __path __value __method )
  message( STATUS "  ${__path}=${__value} [${__method}]" )
endmacro( __tde_internal_setup_paths_status )


#################################################
#####
##### __tde_internal_setup_path

macro( __tde_internal_setup_path __path __default )
  set( __method "user" )
  if( NOT ${__path} )
    set( __method "default" )
    set( __kdeconfig_type ${ARGV2} )
    if( _use_kdeconfig AND __kdeconfig_type )
      execute_process(
        COMMAND ${KDECONFIG_EXECUTABLE} --expandvars --install ${__kdeconfig_type}
        OUTPUT_VARIABLE ${__path}
        RESULT_VARIABLE __result
        OUTPUT_STRIP_TRAILING_WHITESPACE )
      if( __result )
        tde_message_fatal( "Unable to run kde-config!\n kdelibs are correctly installed?\n LD_LIBRARY_PATH are correctly set?" )
      endif( __result )
    endif( _use_kdeconfig AND __kdeconfig_type )
    if( ${__path} )
      set( __method "kde-config" )
    else( ${__path} )
      set( ${__path} "${__default}" )
    endif( ${__path} )
  endif( NOT ${__path} )
  __tde_internal_setup_paths_status( ${__path} ${${__path}} ${__method} )
endmacro( __tde_internal_setup_path )


#################################################
#####
##### tde_setup_paths

macro( tde_setup_paths )

  message( STATUS "Setup install paths:" )

  # --prefix
  # install architecture-independent files in PREFIX
  if( NOT PREFIX )
    set( __method "CMAKE_INSTALL_PREFIX" )
    set( PREFIX "${CMAKE_INSTALL_PREFIX}" )
  else( NOT PREFIX )
    # PREFIX have precedence over CMAKE_INSTALL_PREFIX
    set( __method "user" )
    set( CMAKE_INSTALL_PREFIX "${PREFIX}" )
  endif( NOT PREFIX )
  __tde_internal_setup_paths_status( PREFIX ${PREFIX} ${__method} )

  # --exec-prefix
  # install architecture-dependent files in EPREFIX
  if( NOT EPREFIX )
    set( __method "default" )
    set( EPREFIX "${PREFIX}" )
  endif( NOT EPREFIX )
  __tde_internal_setup_paths_status( EPREFIX ${EPREFIX} ${__method} )

  # we will using kde-config for discover paths
  set( _use_kdeconfig ${ARGV0} )
  if( _use_kdeconfig )
    # KDECONFIG_EXECUTABLE is not set, so will must to search for it
    if( NOT KDECONFIG_EXECUTABLE )
      find_program( KDECONFIG_EXECUTABLE
        NAMES kde-config
        HINTS $ENV{KDEDIR}/bin
        PATHS "${EPREFIX}/bin" "${PREFIX}/bin" "${CMAKE_INSTALL_PREFIX}/bin" )
      if( NOT KDECONFIG_EXECUTABLE )
        tde_message_fatal(

"kde-config executable are NOT found!
 kdelibs(-devel) are installed? EPREFIX are correctly set?
 Try to set KDECONFIG_EXECUTABLE to kde-config path.
 Example: cmake -DKDECONFIG_EXECUTABLE=/usr/kde/3.5/bin/kde-config" )

      endif( NOT KDECONFIG_EXECUTABLE )
    endif( NOT KDECONFIG_EXECUTABLE )
  endif( _use_kdeconfig )

  # --bindir
  # user executables
  __tde_internal_setup_path( BINDIR "${EPREFIX}/bin" "exe" )

  # --sbindir
  # system admin executables
  __tde_internal_setup_path( SBINDIR "${EPREFIX}/sbin" )

  # --libexecdir
  # program executables
  __tde_internal_setup_path( LIBEXECDIR "${EPREFIX}/libexec" )

  # --sysconfdir
  # read-only single-machine data
  __tde_internal_setup_path( SYSCONFDIR "${PREFIX}/etc" )

  # --sharedstatedir
  # modifiable architecture-independent data
  __tde_internal_setup_path( SHAREDSTATEDIR "${PREFIX}/com" )

  # --localstatedir
  # modifiable single-machine data
  __tde_internal_setup_path( LOCALSTATEDIR "${PREFIX}/var" )

  # --libdir
  # object code libraries
  __tde_internal_setup_path( LIBDIR "${EPREFIX}/lib" "lib" )

  # --includedir
  # C header files
  __tde_internal_setup_path( INCLUDEDIR "${PREFIX}/include" "include" )

  # --oldincludedir
  # C header files for non-gcc
  __tde_internal_setup_path( OLDINCLUDEDIR "/usr/include" )

  # --datarootdir
  # read-only arch.-independent data root
  __tde_internal_setup_path( DATAROOTDIR "${PREFIX}/share" )

  # --datadir
  # read-only architecture-independent data
  __tde_internal_setup_path( DATADIR "${DATAROOTDIR}" )

  # --infodir
  # info documentation
  __tde_internal_setup_path( INFODIR "${DATAROOTDIR}/info" )

  # --localedir
  # locale-dependent data
  __tde_internal_setup_path( LOCALEDIR "${DATAROOTDIR}/locale" )

  # --mandir
  # man documentation
  __tde_internal_setup_path( MANDIR "${DATAROOTDIR}/man" )

  # --docdir
  # documentation root
  __tde_internal_setup_path( DOCDIR "${DATAROOTDIR}/doc/${PACKAGE}" )

  # --htmldir
  # html documentation
  __tde_internal_setup_path( HTMLDIR "${DOCDIR}" "html" )

  # --dvidir
  # dvi documentation
  __tde_internal_setup_path( DVIDIR "${DOCDIR}" )

  # --pdfdir
  # pdf documentation
  __tde_internal_setup_path( PDFDIR "${DOCDIR}" )

  # --psdir
  # ps documentation
  __tde_internal_setup_path( PSDIR "${DOCDIR}" )

endmacro( tde_setup_paths )