[GENDLT-20] Fixed bug to use old cmake version for copy file
[profile/ivi/dlt-daemon.git] / doc / CMakeLists.txt
1 #######
2 # Dlt - Diagnostic Log and Trace
3 # @licence make begin@
4  #
5  # Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de>
6  # 
7  # This program is free software; you can redistribute it and/or modify it under the terms of the 
8  # GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
9  # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
10  # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 
11  # Public License, version 2.1, for more details.
12  # 
13  # You should have received a copy of the GNU Lesser General Public License, version 2.1, along 
14  # with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
15  # 
16  # Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may 
17  # also be applicable to programs even in cases in which the program is not a library in the technical sense.
18  # 
19  # Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may 
20  # license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to 
21  # license your linked modules under the GNU Lesser General Public License, version 2.1, you 
22  # may use the program under the following exception.
23  # 
24  # As a special exception, the copyright holders of DLT give you permission to combine DLT 
25  # with software programs or libraries that are released under any license unless such a combination is not
26  # permitted by the license of such a software program or library. You may copy and distribute such a 
27  # system following the terms of the GNU Lesser General Public License, version 2.1, including this
28  # special exception, for DLT and the licenses of the other code concerned.
29  # 
30  # Note that people who make modified versions of DLT are not obligated to grant this special exception 
31  # for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, 
32  # version 2.1, gives permission to release a modified version without this exception; this exception 
33  # also makes it possible to release a modified version which carries forward this exception.
34  #
35  # @licence end@
36 ########
37
38 if(WITH_DOC)
39     find_package(Doxygen)
40        
41     configure_file(${CMAKE_SOURCE_DIR}/doc/doxygen.cfg.cmake ${CMAKE_BINARY_DIR}/doc/doxygen.cfg @ONLY)
42     configure_file(${CMAKE_SOURCE_DIR}/doc/filetransfer_doxygen.cfg.cmake ${CMAKE_BINARY_DIR}/doc/filetransfer_doxygen.cfg @ONLY)
43         
44         add_custom_target (doc ALL 
45                 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/doxygen.cfg 
46                 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc
47         )
48         
49         add_custom_target (doc-filetransfer ALL 
50                 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/filetransfer_doxygen.cfg 
51                 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc
52         )
53
54 endif(WITH_DOC)
55
56 if(WITH_MAN)
57         # Compress the man pages and install to proper place
58         FIND_PROGRAM(GZIP_TOOL
59                      NAMES gzip
60                      PATHS /bin
61                            /usr/bin
62                            /usr/local/bin)
63         
64         if(NOT GZIP_TOOL)
65           MESSAGE(FATAL_ERROR "Could not find gzip for man page compression.") 
66         endif(NOT GZIP_TOOL)                       
67         
68         set(MAN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
69         set(MAN_BUILD_DIR ${CMAKE_BINARY_DIR}/doc)
70         
71         set(MAN_SRC ${MAN_SRC_DIR}/dlt.conf.5 
72                                 ${MAN_SRC_DIR}/dlt-system.conf.5 
73                                 ${MAN_SRC_DIR}/dlt-convert.1 
74                                 ${MAN_SRC_DIR}/dlt-daemon.1 
75                                 ${MAN_SRC_DIR}/dlt-receive.1 
76                                 ${MAN_SRC_DIR}/dlt-system.1)
77         set(MAN_BUILD_SRC 
78                                 ${MAN_BUILD_DIR}/dlt.conf.5 
79                                 ${MAN_BUILD_DIR}/dlt-system.conf.5 
80                                 ${MAN_BUILD_DIR}/dlt-convert.1 
81                                 ${MAN_BUILD_DIR}/dlt-daemon.1 
82                                 ${MAN_BUILD_DIR}/dlt-receive.1 
83                                 ${MAN_BUILD_DIR}/dlt-system.1)
84         set(MAN_BUILD_GZ 
85                                 ${MAN_BUILD_DIR}/dlt.conf.5.gz 
86                                 ${MAN_BUILD_DIR}/dlt-system.conf.5.gz
87                                 ${MAN_BUILD_DIR}/dlt-convert.1.gz
88                                 ${MAN_BUILD_DIR}/dlt-daemon.1.gz
89                                 ${MAN_BUILD_DIR}/dlt-receive.1.gz
90                                 ${MAN_BUILD_DIR}/dlt-system.1.gz)
91         
92         foreach(MAN ${MAN_SRC})
93                 execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${MAN} ${MAN_BUILD_DIR}) 
94         endforeach(MAN)
95         
96         add_custom_target(compress_man ALL 
97                                 COMMAND ${GZIP_TOOL} -c ${MAN_BUILD_DIR}/dlt.conf.5 > ${MAN_BUILD_DIR}/dlt.conf.5.gz
98                                 COMMAND ${GZIP_TOOL} -c ${MAN_BUILD_DIR}/dlt-system.conf.5 > ${MAN_BUILD_DIR}/dlt-system.conf.5.gz
99                                 COMMAND ${GZIP_TOOL} -c ${MAN_BUILD_DIR}/dlt-convert.1  > ${MAN_BUILD_DIR}/dlt-convert.1.gz
100                                 COMMAND ${GZIP_TOOL} -c ${MAN_BUILD_DIR}/dlt-daemon.1 > ${MAN_BUILD_DIR}/dlt-daemon.1.gz
101                                 COMMAND ${GZIP_TOOL} -c ${MAN_BUILD_DIR}/dlt-receive.1 > ${MAN_BUILD_DIR}/dlt-receive.1.gz
102                                 COMMAND ${GZIP_TOOL} -c ${MAN_BUILD_DIR}/dlt-system.1 > ${MAN_BUILD_DIR}/dlt-system.1.gz)
103         
104         # If user has not set the base dir for man pages, use a default location
105         set(MAN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/man)
106         
107         install(FILES   ${MAN_BUILD_DIR}/dlt.conf.5.gz
108                                         ${MAN_BUILD_DIR}/dlt-system.conf.5.gz
109                         DESTINATION ${MAN_INSTALL_DIR}/man5
110         )
111         
112         install(FILES   ${MAN_BUILD_DIR}/dlt-convert.1.gz
113                                         ${MAN_BUILD_DIR}/dlt-daemon.1.gz
114                                         ${MAN_BUILD_DIR}/dlt-receive.1.gz
115                                         ${MAN_BUILD_DIR}/dlt-system.1.gz
116                         DESTINATION ${MAN_INSTALL_DIR}/man1
117         )
118 endif(WITH_MAN)