set new www home
[nomnom.git] / CMakeLists.txt
blob4fa8a924197f7c08f87c0174329af43d5dad48b3
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 set (qt_VERSION
152     "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
154 # The executable.
156 include_directories (
157     ${CMAKE_BINARY_DIR}
158     ${CMAKE_CURRENT_SOURCE_DIR}/src
159     ${CMAKE_CURRENT_SOURCE_DIR}/src/i
162 set (exec_components
163     ${nomnom_src}
164     ${nomnom_hdr}
165     ${nomnom_moc_src}
166     ${nomnom_rc_src}
167     ${nomnom_ui_hdr}
170 if (NOT WITHOUT_QM)
171     set (exec_components ${exec_components} ${nomnom_qm})
172 endif ()
174 add_executable (nomnom ${exec_components})
176 # Subdirs.
178 subdirs (doc)
180 # Status.
182 message (STATUS)
183 message (STATUS "Configuration for")
184 message (STATUS "   NomNom ${VERSION_LONG}")
185 message (STATUS)
186 message (STATUS "Options:")
187 message (STATUS "   Install prefix: ${CMAKE_INSTALL_PREFIX}")
188 message (STATUS "   Host setup    : ${HOST_SETUP}")
189 message (STATUS "   Build type    : ${CMAKE_BUILD_TYPE}")
190 message (STATUS "       (debug, release, relwithdebinfo, minsizerel)")
191 message (STATUS "   Verbose make   : ${CMAKE_VERBOSE_MAKEFILE}")
192 message (STATUS "   Without desktop: ${WITHOUT_DESKTOP}")
193 message (STATUS "   Without transl.: ${WITHOUT_QM}")
194 message (STATUS "   Without doc    : ${WITHOUT_DOC}")
195 message (STATUS)
196 message (STATUS "Found:")
197 message (STATUS "   Compiler: ${CMAKE_CXX_COMPILER}")
198 message (STATUS "   Linker  : ${CMAKE_LINKER}")
199 message (STATUS "   Make    : ${CMAKE_MAKE_PROGRAM}")
200 message (STATUS "   Qt      : ${qt_VERSION}")
201 message (STATUS)
203 # Force these variables to be written to cache.
205 set (CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH
206     "Install destination for ${PROJECT_NAME}" FORCE)
208 set (CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
209     "Type of build: none, debug, release, relwithdebinfo minsizerel" FORCE)
211 set (CMAKE_VERBOSE_MAKEFILE "${CMAKE_VERBOSE_MAKEFILE}" CACHE BOOL
212     "Build with verbose makefiles: true, false" FORCE)
214 set (WITHOUT_DESKTOP "${WITHOUT_DESKTOP}" CACHE BOOL
215     "Install without desktop integration files: true, false" FORCE)
217 set (WITHOUT_QM "${WITHOUT_QM}" CACHE BOOL
218     "Install without translation files: true, false" FORCE)
220 set (WITHOUT_DOC "${WITHOUT_DOC}" CACHE BOOL
221     "Install without documentation: true, false" FORCE)
223 # Link.
225 target_link_libraries (nomnom ${QT_LIBRARIES})
227 # CPack.
229 include (InstallRequiredSystemLibraries)
231 set (CPACK_SOURCE_PACKAGE_FILE_NAME
232     "nomnom-${VERSION}"
233     CACHE INTERNAL
234     "tarball basename"
237 set (CPACK_PACKAGE_FILE_NAME ${CPACK_SOURCE_PACKAGE_FILE_NAME})
238 set (CPACK_GENERATOR "TGZ")
239 set (CPACK_SOURCE_GENERATOR "TGZ")
240 set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
241 set (CPACK_RESOURCE_FILE_README  ${CMAKE_CURRENT_SOURCE_DIR}/README)
243 set (CPACK_SOURCE_IGNORE_FILES
244     "/.git"
245     "/.cmake/"
246     "/CMakeFiles/"
247     "/CMakeCache/"
248     "/Makefile/"
249     "/tmp/"
250     "/OLD/"
251     "/old/"
252     "TODO"
253     "/patches/"
256 # Notice the inclusion here, after setting the cpack variables.
257 include (CPack)
259 # Install.
261 install (PROGRAMS
262     "${CMAKE_CURRENT_BINARY_DIR}/nomnom" DESTINATION bin/)
264 if (NOT WITHOUT_QM)
265     install (FILES ${nomnom_qm} DESTINATION share/nomnom/tr/)
266 endif ()
268 if (NOT WITHOUT_DESKTOP)
269     install (FILES "${CMAKE_CURRENT_BINARY_DIR}/nomnom.desktop"
270         DESTINATION share/applications/)
272     install (FILES "${CMAKE_CURRENT_SOURCE_DIR}/rc/img/nomnom.png"
273         DESTINATION share/pixmaps/)
274 endif ()
276 # Uninstall.
278 configure_file (
279     "${CMAKE_CURRENT_SOURCE_DIR}/uninstall.cmake.in"
280     "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
281     IMMEDIATE @ONLY
284 add_custom_target (
285     uninstall
286     "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"