ChangeLog: add 769e7a,1b177a5,1318000,45d8c5b
[nomnom.git] / CMakeLists.txt
blobccc54be89aff35309d82bd1319a731e2c2da2f4d
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 # config.h
52 configure_file (
53     "${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake.in"
54     "${CMAKE_CURRENT_BINARY_DIR}/config.h"
57 # nomnom.desktop
59 configure_file (
60     "${CMAKE_CURRENT_SOURCE_DIR}/nomnom.desktop.in"
61     "${CMAKE_CURRENT_BINARY_DIR}/nomnom.desktop"
64 # Sources.
66 set (nomnom_src
67     # UI.
68     src/i/Preferences.cpp
69     src/i/YoutubeFeed.cpp
70     src/i/MainWindow.cpp
71     src/i/Reminder.cpp
72     src/i/LogView.cpp
73     src/i/About.cpp
74     # Other.
75     src/ProcProgDiag.cpp
76     src/Download.cpp
77     src/History.cpp
78     src/Video.cpp
79     src/Log.cpp
80     src/main.cpp
81     src/util.cpp
82     src/tips.cpp
85 set (nomnom_hdr
86     src/History.h
87     src/Log.h
88     src/util.h
89     src/tips.h
92 set (nomnom_moc_hdr
93     src/i/Preferences.h
94     src/i/YoutubeFeed.h
95     src/i/MainWindow.h
96     src/i/Reminder.h
97     src/i/LogView.h
98     src/ProcProgDiag.h
99     src/Download.h
100     src/i/About.h
101     src/Video.h
104 set (nomnom_ui
105     i/Preferences.ui
106     i/YoutubeFeed.ui
107     i/MainWindow.ui
108     i/Reminder.ui
109     i/LogView.ui
110     i/About.ui
113 set (nomnom_rc rc/nomnom.qrc)
114 file (GLOB nomnom_ts tr/*.ts)
116 # Prerequisites.
118 find_package (Qt4 4.5.0 COMPONENTS QtCore QtGui QtScript REQUIRED)
119 include (${QT_USE_FILE})
121 qt4_add_resources   (nomnom_rc_src  ${nomnom_rc})
122 qt4_add_translation (nomnom_qm      ${nomnom_ts})
123 qt4_wrap_ui         (nomnom_ui_hdr  ${nomnom_ui})
124 qt4_wrap_cpp        (nomnom_moc_src ${nomnom_moc_hdr})
126 # http://www.vtk.org/Wiki/CMake_2.8.0_Docs : qt4_create_translation
128 # The executable.
130 include_directories (
131     ${CMAKE_BINARY_DIR}
132     ${CMAKE_CURRENT_SOURCE_DIR}/src
133     ${CMAKE_CURRENT_SOURCE_DIR}/src/i
136 add_executable (nomnom
137     ${nomnom_src}
138     ${nomnom_hdr}
139     ${nomnom_moc_src}
140     ${nomnom_rc_src}
141     ${nomnom_ui_hdr}
142     ${nomnom_qm}
145 # Status.
147 message (STATUS)
148 message (STATUS "nomnom version     : ${VERSION}")
149 message (STATUS "host setup         : ${HOST_SETUP}")
150 message (STATUS "install prefix     : ${CMAKE_INSTALL_PREFIX}")
151 message (STATUS "build type         : ${CMAKE_BUILD_TYPE}")
152 message (STATUS "  (debug, release, relwithdebinfo, minsizerel)")
153 message (STATUS "compiler           : ${CMAKE_CXX_COMPILER}")
154 message (STATUS "linker             : ${CMAKE_LINKER}")
155 message (STATUS "make program       : ${CMAKE_MAKE_PROGRAM}")
156 if (DATE_PROG)
157     message (STATUS "date program       : ${DATE_PROG}")
158 else ()
159     message (STATUS "date program       : (not found)")
160 endif ()
161 message (STATUS "verbose make       : ${CMAKE_VERBOSE_MAKEFILE}")
162 message (STATUS)
164 # Force these variables to be written to cache.
166 set (CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH
167     "Install destination for ${PROJECT_NAME}" FORCE)
169 set (CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
170     "Type of build: none, debug, release, relwithdebinfo minsizerel" FORCE)
172 set (CMAKE_VERBOSE_MAKEFILE "${CMAKE_VERBOSE_MAKEFILE}" CACHE BOOL
173     "Build with verbose makefiles: true, false" FORCE)
175 # Link.
177 target_link_libraries (nomnom ${QT_LIBRARIES})
179 # CPack.
181 include (InstallRequiredSystemLibraries)
183 set (CPACK_SOURCE_PACKAGE_FILE_NAME
184     "nomnom-${VERSION}"
185     CACHE INTERNAL
186     "tarball basename"
189 set (CPACK_PACKAGE_FILE_NAME ${CPACK_SOURCE_PACKAGE_FILE_NAME})
190 set (CPACK_GENERATOR "TGZ")
191 set (CPACK_SOURCE_GENERATOR "TGZ")
192 set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
193 set (CPACK_RESOURCE_FILE_README  ${CMAKE_CURRENT_SOURCE_DIR}/README)
195 set (CPACK_SOURCE_IGNORE_FILES
196     "/.git"
197     "/.cmake/"
198     "/CMakeFiles/"
199     "/CMakeCache/"
200     "/Makefile/"
201     "/tmp/"
202     "/OLD/"
203     "/old/"
204     "TODO"
205     "/patches/"
208 # Notice the inclusion here, after setting the cpack variables.
209 include (CPack)
211 # Install.
213 install (PROGRAMS
214     "${CMAKE_CURRENT_BINARY_DIR}/nomnom" DESTINATION bin/)
216 install (FILES ${nomnom_qm} DESTINATION share/nomnom/tr/)
218 install (FILES
219     "${CMAKE_CURRENT_BINARY_DIR}/nomnom.desktop" DESTINATION share/applications/)
221 install (FILES
222     "${CMAKE_CURRENT_SOURCE_DIR}/rc/img/nomnom.png" DESTINATION share/pixmaps/)
224 # Uninstall.
226 configure_file (
227     "${CMAKE_CURRENT_SOURCE_DIR}/uninstall.cmake.in"
228     "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
229     IMMEDIATE @ONLY
232 add_custom_target (
233     uninstall
234     "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"