add WITHOUT_DESKTOP
[nomnom.git] / CMakeLists.txt
blob6ebe58abe2e942990d18f17021d4ab3522f513ee
2 cmake_minimum_required (VERSION 2.8.0)
4 project (nomnom)
6 set (CMAKE_VERBOSE_MAKEFILE false)
8 add_definitions (-Wall)
9 #add_definitions (-Werror)
11 # Version.
13 set (VERSION "0.1.1")
14 set (VERSION_LONG "${VERSION}")
15 set (BRANCH "master")
17 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
18     find_program (GIT_PROG "git")
19     if (GIT_PROG)
20         execute_process (
21             COMMAND ${GIT_PROG} "describe" "${BRANCH}"
22             OUTPUT_VARIABLE DESCR
23             OUTPUT_STRIP_TRAILING_WHITESPACE)
24         if (DESCR)
25             set (VERSION_LONG "${DESCR}")
26         endif ()
27     endif ()
28 endif ()
30 find_program (DATE_PROG "date")
31 if (DATE_PROG)
32     execute_process (
33         COMMAND ${DATE_PROG} "+%Y-%m-%d"
34         OUTPUT_VARIABLE DATE
35         OUTPUT_STRIP_TRAILING_WHITESPACE)
36     if (DATE)
37         set (VERSION_LONG "${VERSION_LONG} built on ${DATE}")
38     endif ()
39 endif ()
41 set (HOST_SETUP "${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}")
42 set (VERSION_LONG "${VERSION_LONG} for ${HOST_SETUP}")
44 # Set default build type.
46 if (NOT CMAKE_BUILD_TYPE)
47     set (CMAKE_BUILD_TYPE "debug")
48 endif ()
50 # Set default for WITHOUT_DESKTOP.
52 if (NOT WITHOUT_DESKTOP)
53     set (WITHOUT_DESKTOP false)
54 endif ()
56 # Set default for WITHOUT_QM.
58 if (NOT WITHOUT_QM)
59     set (WITHOUT_QM false)
60 endif ()
62 # Set default for WITHOUT_DOC.
64 if (NOT WITHOUT_DOC)
65     set (WITHOUT_DOC false)
66 endif ()
68 # config.h
70 configure_file (
71     "${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake.in"
72     "${CMAKE_CURRENT_BINARY_DIR}/config.h"
75 # nomnom.desktop
77 configure_file (
78     "${CMAKE_CURRENT_SOURCE_DIR}/nomnom.desktop.in"
79     "${CMAKE_CURRENT_BINARY_DIR}/nomnom.desktop"
82 # Sources.
84 set (nomnom_src
85     # UI.
86     src/i/Preferences.cpp
87     src/i/YoutubeFeed.cpp
88     src/i/MainWindow.cpp
89     src/i/Reminder.cpp
90     src/i/LogView.cpp
91     src/i/About.cpp
92     # Other.
93     src/DownloadDiag.cpp
94     src/ProcProgDiag.cpp
95     src/Recent.cpp
96     src/Video.cpp
97     src/Log.cpp
98     src/main.cpp
99     src/util.cpp
100     src/tips.cpp
103 set (nomnom_hdr
104     src/Recent.h
105     src/Log.h
106     src/util.h
107     src/tips.h
110 set (nomnom_moc_hdr
111     src/i/Preferences.h
112     src/i/YoutubeFeed.h
113     src/i/MainWindow.h
114     src/i/Reminder.h
115     src/i/LogView.h
116     src/DownloadDiag.h
117     src/ProcProgDiag.h
118     src/i/About.h
119     src/Video.h
122 set (nomnom_ui
123     i/Preferences.ui
124     i/YoutubeFeed.ui
125     i/MainWindow.ui
126     i/Reminder.ui
127     i/LogView.ui
128     i/About.ui
131 set (nomnom_rc rc/nomnom.qrc)
133 if (NOT WITHOUT_QM)
134     file (GLOB nomnom_ts "${CMAKE_CURRENT_SOURCE_DIR}/tr/*.ts")
135 endif ()
137 # Prerequisites.
139 find_package (Qt4 4.5.0 COMPONENTS QtCore QtGui QtScript REQUIRED)
140 include (${QT_USE_FILE})
142 qt4_add_resources   (nomnom_rc_src  ${nomnom_rc})
143 if (NOT WITHOUT_QM)
144     qt4_add_translation (nomnom_qm  ${nomnom_ts})
145 endif ()
146 qt4_wrap_ui         (nomnom_ui_hdr  ${nomnom_ui})
147 qt4_wrap_cpp        (nomnom_moc_src ${nomnom_moc_hdr})
149 # http://www.vtk.org/Wiki/CMake_2.8.0_Docs : qt4_create_translation
151 # The executable.
153 include_directories (
154     ${CMAKE_BINARY_DIR}
155     ${CMAKE_CURRENT_SOURCE_DIR}/src
156     ${CMAKE_CURRENT_SOURCE_DIR}/src/i
159 set (exec_components
160     ${nomnom_src}
161     ${nomnom_hdr}
162     ${nomnom_moc_src}
163     ${nomnom_rc_src}
164     ${nomnom_ui_hdr}
167 if (NOT WITHOUT_QM)
168     set (exec_components ${exec_components} ${nomnom_qm})
169 endif ()
171 add_executable (nomnom ${exec_components})
173 # Subdirs.
175 subdirs (doc)
177 # Status.
179 message (STATUS)
180 message (STATUS "nomnom version     : ${VERSION}")
181 message (STATUS "host setup         : ${HOST_SETUP}")
182 message (STATUS "install prefix     : ${CMAKE_INSTALL_PREFIX}")
183 message (STATUS "build type         : ${CMAKE_BUILD_TYPE}")
184 message (STATUS "  (debug, release, relwithdebinfo, minsizerel)")
185 message (STATUS "compiler           : ${CMAKE_CXX_COMPILER}")
186 message (STATUS "linker             : ${CMAKE_LINKER}")
187 message (STATUS "make program       : ${CMAKE_MAKE_PROGRAM}")
188 if (DATE_PROG)
189     message (STATUS "date program       : ${DATE_PROG}")
190 else ()
191     message (STATUS "date program       : (not found)")
192 endif ()
193 message (STATUS "verbose make       : ${CMAKE_VERBOSE_MAKEFILE}")
194 message (STATUS "without desktop    : ${WITHOUT_DESKTOP}")
195 message (STATUS "without transl.    : ${WITHOUT_QM}")
196 message (STATUS "without doc        : ${WITHOUT_DOC}")
197 message (STATUS)
199 # Force these variables to be written to cache.
201 set (CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH
202     "Install destination for ${PROJECT_NAME}" FORCE)
204 set (CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
205     "Type of build: none, debug, release, relwithdebinfo minsizerel" FORCE)
207 set (CMAKE_VERBOSE_MAKEFILE "${CMAKE_VERBOSE_MAKEFILE}" CACHE BOOL
208     "Build with verbose makefiles: true, false" FORCE)
210 set (WITHOUT_DESKTOP "${WITHOUT_DESKTOP}" CACHE BOOL
211     "Install without desktop integration files: true, false" FORCE)
213 set (WITHOUT_QM "${WITHOUT_QM}" CACHE BOOL
214     "Install without translation files: true, false" FORCE)
216 set (WITHOUT_DOC "${WITHOUT_DOC}" CACHE BOOL
217     "Install without documentation: true, false" FORCE)
219 # Link.
221 target_link_libraries (nomnom ${QT_LIBRARIES})
223 # CPack.
225 include (InstallRequiredSystemLibraries)
227 set (CPACK_SOURCE_PACKAGE_FILE_NAME
228     "nomnom-${VERSION}"
229     CACHE INTERNAL
230     "tarball basename"
233 set (CPACK_PACKAGE_FILE_NAME ${CPACK_SOURCE_PACKAGE_FILE_NAME})
234 set (CPACK_GENERATOR "TGZ")
235 set (CPACK_SOURCE_GENERATOR "TGZ")
236 set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
237 set (CPACK_RESOURCE_FILE_README  ${CMAKE_CURRENT_SOURCE_DIR}/README)
239 set (CPACK_SOURCE_IGNORE_FILES
240     "/.git"
241     "/.cmake/"
242     "/CMakeFiles/"
243     "/CMakeCache/"
244     "/Makefile/"
245     "/tmp/"
246     "/OLD/"
247     "/old/"
248     "TODO"
249     "/patches/"
252 # Notice the inclusion here, after setting the cpack variables.
253 include (CPack)
255 # Install.
257 install (PROGRAMS
258     "${CMAKE_CURRENT_BINARY_DIR}/nomnom" DESTINATION bin/)
260 if (NOT WITHOUT_QM)
261     install (FILES ${nomnom_qm} DESTINATION share/nomnom/tr/)
262 endif ()
264 if (NOT WITHOUT_DESKTOP)
265     install (FILES "${CMAKE_CURRENT_BINARY_DIR}/nomnom.desktop"
266         DESTINATION share/applications/)
268     install (FILES "${CMAKE_CURRENT_SOURCE_DIR}/rc/img/nomnom.png"
269         DESTINATION share/pixmaps/)
270 endif ()
272 # Uninstall.
274 configure_file (
275     "${CMAKE_CURRENT_SOURCE_DIR}/uninstall.cmake.in"
276     "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
277     IMMEDIATE @ONLY
280 add_custom_target (
281     uninstall
282     "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"