root/trunk/CMakeLists.txt

Revision 345, 5.5 KB (checked in by hsattler, 6 months ago)

require CMake-2.6 and let the linker find the right ws2_32 library (setting $LIB is not needed anymore)

Line 
1cmake_minimum_required ( VERSION 2.6 FATAL_ERROR )
2
3project ( openobex C )
4
5#
6# The project version
7#
8set ( VERSION_MAJOR 1 )
9set ( VERSION_MINOR 3 )
10set ( VERSION_PATCH 0 )
11
12set ( SHORT_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}" )
13set ( VERSION       "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
14if ( VERSION_PATCH GREATER 0 )
15  set ( SHORT_VERSION "${VERSION}" )
16endif ( VERSION_PATCH GREATER 0 )
17
18#
19# The path for our own CMake modules
20#
21set ( CMAKE_MODULE_PATH
22  ${PROJECT_SOURCE_DIR}/CMakeModules
23)
24
25#
26# Define the default build type
27#
28set ( CMAKE_CONFIGURATION_TYPES "Release;Debug"
29      CACHE STRING "" FORCE )
30if ( NOT CMAKE_BUILD_TYPE )
31  set ( CMAKE_BUILD_TYPE Release
32        CACHE STRING "Build type" FORCE )
33endif ( NOT CMAKE_BUILD_TYPE )
34
35#
36# define how to build libraries
37#
38option ( BUILD_SHARED_LIBS "Build shared libraries" ON )
39
40#
41# check common compiler flags
42#
43include ( CheckCCompilerFlag )
44if ( CMAKE_COMPILER_IS_GNUCC )
45  if ( UNIX AND NOT WIN32 )
46    set ( COMPILER_FLAG_VISIBILITY -fvisibility=hidden )
47    check_c_compiler_flag ( ${COMPILER_FLAG_VISIBILITY} COMPILER_SUPPORT_VISIBILITY )
48  endif ( UNIX AND NOT WIN32 )
49
50  set ( LINKER_FLAG_NOUNDEFINED   -Wl,--no-undefined )
51  check_c_compiler_flag ( "${LINKER_FLAG_NOUNDEFINED}" COMPILER_SUPPORT_NOUNDEFINED )
52endif ( CMAKE_COMPILER_IS_GNUCC )
53
54if ( MSVC )
55  # Some compiler options for MSVC to not print non-sense warnings.
56  add_definitions ( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE )
57endif ( MSVC )
58
59#
60# which transports shall be included
61#
62find_package ( Bluetooth )
63set ( OPENOBEX_BLUETOOTH_AVAILABLE ${Bluetooth_FOUND} )
64
65find_package ( Irda )
66set ( OPENOBEX_IRDA_AVAILABLE ${Irda_FOUND} )
67
68find_package ( LibUSB )
69set ( OPENOBEX_USB_AVAILABLE ${LibUSB_FOUND} )
70
71foreach ( transport BLUETOOTH IRDA USB )
72  if ( OPENOBEX_${transport}_AVAILABLE )
73    set ( OPENOBEX_${transport} ON
74          CACHE BOOL "Build with ${transport} support")
75  else ( OPENOBEX_${transport}_AVAILABLE )
76    set ( OPENOBEX_${transport} OFF
77          CACHE BOOL "Build with ${transport} support")
78  endif ( OPENOBEX_${transport}_AVAILABLE )
79  if (OPENOBEX_${transport})
80    add_definitions ( -DHAVE_${transport} )
81  endif (OPENOBEX_${transport})
82endforeach ( transport )
83
84if ( OPENOBEX_IRDA )
85  if ( WIN32 )
86    add_definitions ( -DHAVE_IRDA_WINDOWS )
87  else ( WIN32 )
88    string ( TOUPPER "HAVE_IRDA_${CMAKE_SYSTEM_NAME}" IRDA_SYSTEM_DEFINITION )
89    add_definitions ( -D${IRDA_SYSTEM_DEFINITION} )
90  endif ( WIN32 )
91endif ( OPENOBEX_IRDA )
92
93if ( OPENOBEX_BLUETOOTH )
94  if ( WIN32 )
95    add_definitions ( -DHAVE_BLUETOOTH_WINDOWS )
96  else ( WIN32 )
97    string ( TOUPPER "HAVE_BLUETOOTH_${CMAKE_SYSTEM_NAME}" BLUETOOTH_SYSTEM_DEFINITION )
98    add_definitions ( -D${BLUETOOTH_SYSTEM_DEFINITION} )
99  endif ( WIN32 )
100endif ( OPENOBEX_BLUETOOTH )
101
102#
103# create pkg-config files
104# these get copied and installed in the library dirs
105# TODO: those files should be moved to subdirs for each library
106#
107set ( prefix      "${CMAKE_INSTALL_PREFIX}" )
108set ( exec_prefix "\${prefix}" )
109set ( libdir      "\${prefix}/lib" )
110set ( includedir  "\${prefix}/include" )
111if ( OPENOBEX_USB AND UNIX AND NOT WIN32 )
112   set ( REQUIRES "libusb" )
113endif ( OPENOBEX_USB AND UNIX AND NOT WIN32 )
114foreach ( file openobex openobex-glib )
115  configure_file (
116    ${PROJECT_SOURCE_DIR}/${file}.pc.in
117    ${CMAKE_CURRENT_BINARY_DIR}/${file}.pc
118    @ONLY
119  )
120endforeach ( file )
121
122if ( NOT PKGCONFIG_INSTALL_DIR )
123  set ( PKGCONFIG_INSTALL_DIR lib/pkgconfig
124        CACHE PATH "Where to install .pc files to" FORCE )
125endif ( NOT PKGCONFIG_INSTALL_DIR )
126mark_as_advanced ( PKGCONFIG_INSTALL_DIR )
127
128
129#
130# process include directory
131#
132add_subdirectory ( include )
133include_directories ( BEFORE SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/include" )
134if ( MSVC )
135  include_directories ( AFTER SYSTEM "${CMAKE_SOURCE_DIR}/include/msvc" )
136endif ( MSVC )
137
138
139#
140# build the main library
141#
142add_subdirectory ( lib )
143link_directories ( "${CMAKE_CURRENT_BINARY_DIR}/lib" )
144if ( BUILD_SHARED_LIBS )
145  add_definitions ( -DOPENOBEX_DLL )
146endif ( BUILD_SHARED_LIBS )
147
148
149#
150# build the documentation
151#
152add_subdirectory ( doc )
153
154
155#
156# build the applications
157#
158add_custom_target ( openobex-apps )
159add_subdirectory ( apps )
160add_subdirectory ( ircp )
161
162
163#
164# build the glib binding library
165# not enabled by default because it requires an additional dependency
166#
167option ( BUILD_GLIB_BINDING "Build the glib binding library")
168if ( BUILD_GLIB_BINDING )
169  add_subdirectory ( glib )
170endif ( BUILD_GLIB_BINDING )
171
172
173#
174# The following adds CPack support
175#
176set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenObex" )
177set ( CPACK_PACKAGE_VENDOR "The OpenObex Development Team" )
178
179set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LIB" )
180set ( CPACK_RESOURCE_FILE_README  "${CMAKE_CURRENT_SOURCE_DIR}/README" )
181
182set ( CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}" )
183set ( CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}" )
184set ( CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}" )
185set ( CPACK_PACKAGE_VERSION       "${VERSION}" )
186
187if ( UNIX )
188  set ( CPACK_GENERATOR "TGZ" )
189  set ( CPACK_SOURCE_GENERATOR "TGZ" )
190
191elseif ( WIN32 )
192  #
193  # For NSIS, install from http://nsis.sf.net.
194  # For ZIP, install e.g. info-zip from http://www.info-zip.org.
195  #
196  set ( CPACK_GENERATOR "ZIP;NSIS" )
197  set ( CPACK_SOURCE_GENERATOR "ZIP" )
198endif ( UNIX )
199set ( CPACK_SOURCE_IGNORE_FILES
200  "/build/"
201  "/\\\\.svn/"
202  "~$"
203)
204
205# this must _follow_ the settings!
206include ( CPack )
Note: See TracBrowser for help on using the browser.