2 cmake_minimum_required (VERSION 2.8.0)
6 add_definitions (-Wall)
7 #add_definitions (-Werror)
12 set (VERSION_LONG "${VERSION}")
15 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
16 find_program (GIT_PROG "git")
19 COMMAND ${GIT_PROG} "describe" "${BRANCH}"
21 OUTPUT_STRIP_TRAILING_WHITESPACE)
23 set (VERSION_LONG "${DESCR}")
28 find_program (DATE_PROG "date")
31 COMMAND ${DATE_PROG} "+%Y-%m-%d"
33 OUTPUT_STRIP_TRAILING_WHITESPACE)
35 set (VERSION_LONG "${VERSION_LONG} built on ${DATE}")
39 set (HOST_SETUP "${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}")
40 set (VERSION_LONG "${VERSION_LONG} for ${HOST_SETUP}")
42 # Set build type default.
44 if (NOT CMAKE_BUILD_TYPE)
45 set (CMAKE_BUILD_TYPE "debug")
48 # Set verbose makefile default.
50 if (NOT CMAKE_VERBOSE_MAKEFILE)
51 set (CMAKE_VERBOSE_MAKEFILE false)
54 # Set WITHOUT_DESKTOP default.
56 if (NOT WITHOUT_DESKTOP)
57 set (WITHOUT_DESKTOP false)
60 # Set WITHOUT_QM default.
63 set (WITHOUT_QM false)
66 # Set WITHOUT_DOC default.
69 set (WITHOUT_DOC false)
75 "${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake.in"
76 "${CMAKE_CURRENT_BINARY_DIR}/config.h"
82 "${CMAKE_CURRENT_SOURCE_DIR}/nomnom.desktop.in"
83 "${CMAKE_CURRENT_BINARY_DIR}/nomnom.desktop"
135 set (nomnom_rc rc/nomnom.qrc)
138 file (GLOB nomnom_ts "${CMAKE_CURRENT_SOURCE_DIR}/tr/*.ts")
143 find_package (Qt4 4.5.0 COMPONENTS QtCore QtGui QtScript REQUIRED)
144 include (${QT_USE_FILE})
146 qt4_add_resources (nomnom_rc_src ${nomnom_rc})
148 qt4_add_translation (nomnom_qm ${nomnom_ts})
150 qt4_wrap_ui (nomnom_ui_hdr ${nomnom_ui})
151 qt4_wrap_cpp (nomnom_moc_src ${nomnom_moc_hdr})
153 # http://www.vtk.org/Wiki/CMake_2.8.0_Docs : qt4_create_translation
156 "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")
160 include_directories (
162 ${CMAKE_CURRENT_SOURCE_DIR}/src
163 ${CMAKE_CURRENT_SOURCE_DIR}/src/i
175 set (exec_components ${exec_components} ${nomnom_qm})
178 add_executable (nomnom ${exec_components})
187 message (STATUS "Configured:")
188 message (STATUS " NomNom ${VERSION_LONG}")
190 message (STATUS "Found:")
191 message (STATUS " Compiler: ${CMAKE_CXX_COMPILER}")
192 message (STATUS " Linker : ${CMAKE_LINKER}")
193 message (STATUS " Make : ${CMAKE_MAKE_PROGRAM}")
194 message (STATUS " Qt : ${qt_VERSION}")
196 message (STATUS "Options:")
197 message (STATUS " Install prefix: ${CMAKE_INSTALL_PREFIX}")
198 message (STATUS " Host setup : ${HOST_SETUP}")
199 message (STATUS " Build type : ${CMAKE_BUILD_TYPE}")
200 message (STATUS " (debug, release, relwithdebinfo, minsizerel)")
201 message (STATUS " Verbose make : ${CMAKE_VERBOSE_MAKEFILE}")
202 message (STATUS " Without desktop: ${WITHOUT_DESKTOP}")
203 message (STATUS " Without transl.: ${WITHOUT_QM}")
204 message (STATUS " Without doc : ${WITHOUT_DOC}")
207 # Force these variables to be written to cache.
209 set (CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH
210 "Install destination for ${PROJECT_NAME}" FORCE)
212 set (CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
213 "Type of build: none, debug, release, relwithdebinfo minsizerel" FORCE)
215 set (CMAKE_VERBOSE_MAKEFILE "${CMAKE_VERBOSE_MAKEFILE}" CACHE BOOL
216 "Build with verbose makefiles: true, false" FORCE)
218 set (WITHOUT_DESKTOP "${WITHOUT_DESKTOP}" CACHE BOOL
219 "Install without desktop integration files: true, false" FORCE)
221 set (WITHOUT_QM "${WITHOUT_QM}" CACHE BOOL
222 "Install without translation files: true, false" FORCE)
224 set (WITHOUT_DOC "${WITHOUT_DOC}" CACHE BOOL
225 "Install without documentation: true, false" FORCE)
229 target_link_libraries (nomnom ${QT_LIBRARIES})
233 include (InstallRequiredSystemLibraries)
235 set (CPACK_SOURCE_PACKAGE_FILE_NAME
241 set (CPACK_PACKAGE_FILE_NAME ${CPACK_SOURCE_PACKAGE_FILE_NAME})
242 set (CPACK_GENERATOR "TGZ")
243 set (CPACK_SOURCE_GENERATOR "TGZ")
244 set (CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
245 set (CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README)
247 set (CPACK_SOURCE_IGNORE_FILES
260 # Notice the inclusion here, after setting the cpack variables.
266 "${CMAKE_CURRENT_BINARY_DIR}/nomnom" DESTINATION bin/)
269 install (FILES ${nomnom_qm} DESTINATION share/nomnom/tr/)
272 if (NOT WITHOUT_DESKTOP)
273 install (FILES "${CMAKE_CURRENT_BINARY_DIR}/nomnom.desktop"
274 DESTINATION share/applications/)
276 install (FILES "${CMAKE_CURRENT_SOURCE_DIR}/rc/img/nomnom.png"
277 DESTINATION share/pixmaps/)
283 "${CMAKE_CURRENT_SOURCE_DIR}/uninstall.cmake.in"
284 "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
290 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"