qcommandline 0.2.0
[qcommandline:qcommandline.git] / CMakeLists.txt
1 # Copyright (C) 2009-2010 Corentin Chary <corentin.chary@gmail.com>
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Library General Public
5 # License as published by the Free Software Foundation; either
6 # version 2 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Library General Public License for more details.
12 #
13 # You should have received a copy of the GNU Library General Public License
14 # along with this library; see the file COPYING.LIB.  If not, write to
15 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 # Boston, MA 02110-1301, USA.
17
18 PROJECT(qcommandline)
19
20 # Stop cmake 2.6 from whining
21 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
22 IF(COMMAND cmake_policy)
23   CMAKE_POLICY(SET CMP0003 NEW)
24 ENDIF(COMMAND cmake_policy)
25
26 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
27 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules")
28
29 set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR})
30
31 # compile in debug mode
32 IF(NOT CMAKE_BUILD_TYPE)
33   SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
34       "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
35       FORCE)
36 ENDIF(NOT CMAKE_BUILD_TYPE)
37
38 IF("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*")
39   ADD_DEFINITIONS("-DQT_NO_DEBUG_OUTPUT")
40   ADD_DEFINITIONS("-DQT_NO_DEBUG_OUTPUT")
41 ENDIF("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*")
42
43 # Find Qt4
44 FIND_PACKAGE( Qt4 REQUIRED )
45
46 #add extra search paths for libraries and includes
47 SET (LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" )
48 SET (LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE STRING "Directory where lib will install")
49 SET (INCLUDE_INSTALL_DIR "include" CACHE PATH "The directory the headers are installed in")
50 SET (CMAKE_MODULES_INSTALL_DIR "share/apps/cmake/modules" CACHE PATH "The directory to install FindQCommandLine.cmake to")
51
52
53 set(QCOMMANDLINE_LIB_MAJOR_VERSION "0")
54 set(QCOMMANDLINE_LIB_MINOR_VERSION "2")
55 set(QCOMMANDLINE_LIB_PATCH_VERSION "0")
56
57 set(QCOMMANDLINE_LIB_VERSION_STRING "${QCOMMANDLINE_LIB_MAJOR_VERSION}.${QCOMMANDLINE_LIB_MINOR_VERSION}.${QCOMMANDLINE_LIB_PATCH_VERSION}")
58
59 set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}" )
60
61 # pkg-config
62 IF (NOT WIN32)
63   CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/QCommandLine.pc.in
64                   ${CMAKE_CURRENT_BINARY_DIR}/QCommandLine.pc
65                   @ONLY)
66   INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/QCommandLine.pc
67            DESTINATION lib${LIB_SUFFIX}/pkgconfig
68            COMPONENT devel)
69 ENDIF (NOT WIN32)
70
71 # Include the cmake file needed to use qt4
72 INCLUDE( ${QT_USE_FILE} )
73
74 # Subdirs
75 ADD_SUBDIRECTORY(src)
76 IF (QCOMMANDLINE_BUILD_EXAMPLES)
77   ADD_SUBDIRECTORY(examples)
78 ENDIF ()
79
80 add_subdirectory(cmake/modules)
81
82 set(CPACK_VERSION_MAJOR ${QCOMMANDLINE_LIB_MAJOR_VERSION})
83 set(CPACK_VERSION_MINOR ${QCOMMANDLINE_LIB_MINOR_VERSION})
84 set(CPACK_VERSION_PATCH ${QCOMMANDLINE_LIB_PATCH_VERSION})
85 set(CPACK_VERSION ${QCOMMANDLINE_LIB_VERSION_STRING})
86 set(CPACK_PACKAGE_VERSION ${QCOMMANDLINE_LIB_VERSION_STRING})
87 set(CPACK_PACKAGE_CONTACT "Corentin Chary <corentin.chary@gmail.com>")
88 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
89 set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README")
90 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A Command line parser for Qt")
91 set(CPACK_PACKAGE_VENDOR "http://xf.iksaif.net/dev/qcommandline.html")
92 set(CPACK_SOURCE_IGNORE_FILES
93   "~$"
94   "^${PROJECT_SOURCE_DIR}/\\\\.git"
95   "^${PROJECT_SOURCE_DIR}/build/")
96 #set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BUILD_DIR};qcommandline;ALL;/")
97 set(CPACK_COMPONENTS_ALL libraries devel)
98 set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Library")
99 set(CPACK_COMPONENT_DEVEL_DISPLAY_NAME "Development files")
100 set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "A Command line parser for Qt")
101 set(CPACK_COMPONENT_DEVEL_DESCRIPTION "Development files for Qcommandline")
102 set(CPACK_COMPONENT_DEVEL_DEPENDS libraries)
103 set(CPACK_PACKAGE_FILE_NAME "qcommandline-${CPACK_VERSION}-${CMAKE_SYSTEM_NAME}")
104 set(CPACK_SOURCE_PACKAGE_FILE_NAME "qcommandline-${CPACK_VERSION}")
105
106 if(NOT WIN32)
107   set(CPACK_GENERATOR "DEB")
108   set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2")
109   ## Debian specific ##
110   set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt4-core (>= 4.6)")
111   set(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "libqt4-dev (>= 4.6), cmake (>= 2.6)")
112 else()
113   set(CPACK_GENERATOR "ZIP;NSIS")
114   set(CPACK_SOURCE_GENERATOR "ZIP")
115   set(CPACK_BINARY_CYGWIN "OFF")
116   set(CPACK_SOURCE_CYGWIN "OFF")
117   set(CPACK_PACKAGE_FILE_NAME "qcommandline-${CPACK_VERSION}-win32")
118   set(CPACK_BINARY_NSIS "ON")
119   set(CPACK_NSIS_MODIFY_PATH "OFF")
120   set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} QCommandLine")
121   set(CPACK_NSIS_HELP_LINK "http://xf.iksaif.net/dev/qcommandline.html")
122   set(CPACK_NSIS_URL_INFO_ABOUT "http://xf.iksaif.net/dev/qcommandline.html")
123   set(CPACK_NSIS_CONTACT "Corentin Chary <corentin.chary@gmail.com>")
124   set(CPACK_PACKAGE_INSTALL_DIRECTORY "qcommandline")
125 endif()
126
127 include(CPack)