File: CMakeLists.txt

package info (click to toggle)
libopenobex 1.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, stretch
  • size: 972 kB
  • ctags: 1,552
  • sloc: ansic: 9,988; xml: 407; makefile: 96
file content (227 lines) | stat: -rw-r--r-- 6,521 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
cmake_minimum_required ( VERSION 3.1 FATAL_ERROR )

project ( openobex
  LANGUAGES C
  VERSION 1.7.2
)

#
# The path for our own CMake modules
#
set ( CMAKE_MODULE_PATH
  ${PROJECT_SOURCE_DIR}/CMakeModules
)

#
# Define the default build type
#
set ( CMAKE_CONFIGURATION_TYPES "Release;Debug"
      CACHE STRING "" FORCE )
if ( NOT CMAKE_BUILD_TYPE )
  set ( CMAKE_BUILD_TYPE Release
        CACHE STRING "Build type" FORCE )
endif ( NOT CMAKE_BUILD_TYPE )

include ( MaintainerMode )
include ( GNUInstallDirs )

# This module currently expects C++ to be enabled in CMake-2.8.10.
include ( GenerateExportHeader )
add_compiler_export_flags ( C )

#
# define how to build libraries
#
option ( BUILD_SHARED_LIBS "Build shared libraries" ON )

#
# check common compiler flags
#
include ( CheckCCompilerFlag )
if ( CMAKE_COMPILER_IS_GNUCC )
  set ( LINKER_FLAG_NOUNDEFINED -Wl,--no-undefined )
  check_c_compiler_flag ( "${LINKER_FLAG_NOUNDEFINED}" COMPILER_SUPPORT_NOUNDEFINED )
  if ( NOT COMPILER_SUPPORT_NOUNDEFINED )
    set ( LINKER_FLAG_NOUNDEFINED )
  endif ( NOT COMPILER_SUPPORT_NOUNDEFINED )
endif ( CMAKE_COMPILER_IS_GNUCC )

if ( MSVC )
  # Some compiler options for MSVC to not print non-sense warnings.
  add_definitions ( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE )
endif ( MSVC )

#
# which transports shall be included
#
find_package ( Bluetooth )
set ( OPENOBEX_BLUETOOTH_AVAILABLE ${Bluetooth_FOUND} )

find_package ( Irda )
set ( OPENOBEX_IRDA_AVAILABLE ${Irda_FOUND} )

find_package ( LibUSB )
set ( OPENOBEX_USB_AVAILABLE ${LibUSB_FOUND} )

foreach ( transport BLUETOOTH IRDA USB )
  if ( OPENOBEX_${transport}_AVAILABLE )
    set ( OPENOBEX_${transport} ON
          CACHE BOOL "Build with ${transport} support")
  else ( OPENOBEX_${transport}_AVAILABLE )
    set ( OPENOBEX_${transport} OFF
          CACHE BOOL "Build with ${transport} support")
  endif ( OPENOBEX_${transport}_AVAILABLE )
endforeach ( transport )

if ( OPENOBEX_USB )
  if ( LibUSB_VERSION_1.0 )
    add_definitions ( -DHAVE_USB1 )
  endif ( LibUSB_VERSION_1.0 )
  add_definitions ( -DHAVE_USB )
endif ( OPENOBEX_USB )

if ( OPENOBEX_IRDA )
  add_definitions ( -DHAVE_IRDA )
  if ( WIN32 )
    add_definitions ( -DHAVE_IRDA_WINDOWS )
  else ( WIN32 )
    string ( TOUPPER "HAVE_IRDA_${CMAKE_SYSTEM_NAME}" IRDA_SYSTEM_DEFINITION )
    add_definitions ( -D${IRDA_SYSTEM_DEFINITION} )
  endif ( WIN32 )
endif ( OPENOBEX_IRDA )

if ( OPENOBEX_BLUETOOTH )
  add_definitions ( -DHAVE_BLUETOOTH )
  if ( WIN32 )
    add_definitions ( -DHAVE_BLUETOOTH_WINDOWS )
  else ( WIN32 )
    string ( TOUPPER "HAVE_BLUETOOTH_${CMAKE_SYSTEM_NAME}" BLUETOOTH_SYSTEM_DEFINITION )
    add_definitions ( -D${BLUETOOTH_SYSTEM_DEFINITION} )
  endif ( WIN32 )
endif ( OPENOBEX_BLUETOOTH )

#
# create pkg-config files
# these get copied and installed in the library dirs
# TODO: those files should be moved to subdirs for each library
#
set ( prefix      "${CMAKE_INSTALL_PREFIX}" )
set ( exec_prefix "\${prefix}" )
set ( libdir      "\${prefix}/${CMAKE_INSTALL_LIBDIR}" )
set ( includedir  "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}" )
set ( top_srcdir   "${CMAKE_SOURCE_DIR}" )
set ( top_builddir "${CMAKE_BINARY_DIR}" )
if ( OPENOBEX_BLUETOOTH AND UNIT AND NOT WIN32 )
  foreach ( lib Bluetooth_LIBRARIES )
    set ( LIBS_PRIVATE "${LIBS_PRIVATE} ${lib}" )
  endforeach ( lib )
endif ( OPENOBEX_BLUETOOTH AND UNIT AND NOT WIN32 )
if ( OPENOBEX_USB AND UNIX AND NOT WIN32 )
  if ( PKGCONFIG_LIBUSB_FOUND )
    if ( LibUSB_VERSION_1.0 )
      set ( REQUIRES "${REQUIRES} libusb-1.0" )
    else ( LibUSB_VERSION_1.0 )
      set ( REQUIRES "${REQUIRES} libusb" )
    endif ( LibUSB_VERSION_1.0 )
  else ( PKGCONFIG_LIBUSB_FOUND )
    foreach ( lib LibUSB_LIBRARIES )
      set ( LIBS_PRIVATE "${LIBS_PRIVATE} ${lib}" )
    endforeach ( lib )
  endif ( PKGCONFIG_LIBUSB_FOUND )
endif ( OPENOBEX_USB AND UNIX AND NOT WIN32 )
configure_file (
  ${CMAKE_CURRENT_SOURCE_DIR}/openobex.pc.in
  ${CMAKE_CURRENT_BINARY_DIR}/openobex.pc
  @ONLY
)

if ( NOT PKGCONFIG_INSTALL_DIR )
  set ( PKGCONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig
        CACHE PATH "Where to install .pc files to" FORCE )
endif ( NOT PKGCONFIG_INSTALL_DIR )
mark_as_advanced ( PKGCONFIG_INSTALL_DIR )


#
# process include directory
#
set ( openobex_INCLUDE_DIRS
  "${CMAKE_CURRENT_SOURCE_DIR}/include"
  "${CMAKE_CURRENT_BINARY_DIR}/include"
)
include_directories ( "${openobex_INCLUDE_DIRS}" )
add_subdirectory ( include/openobex )
if ( MSVC )
  include_directories ( AFTER SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/include/msvc" )
endif ( MSVC )


#
# build the main library
#
add_subdirectory ( lib )
link_directories ( "${CMAKE_CURRENT_BINARY_DIR}/lib" )
if ( BUILD_SHARED_LIBS )
  add_definitions ( -DOPENOBEX_DLL )
endif ( BUILD_SHARED_LIBS )
option ( EXPORT_PACKAGE "Register build directory for find_package" OFF )
if ( EXPORT_PACKAGE )
  export ( PACKAGE OpenObex )
endif ( EXPORT_PACKAGE )

#
# build udev support 
#
add_subdirectory ( udev )

#
# build the applications
#
add_custom_target ( openobex-apps )
add_subdirectory ( apps )


#
# build the documentation
#
option ( BUILD_DOCUMENTATION "Build library and application documentation" ON)
if ( BUILD_DOCUMENTATION )
  add_subdirectory ( doc )
endif ( BUILD_DOCUMENTATION )


#
# The following adds CPack support
#
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenObex" )
set ( CPACK_PACKAGE_VENDOR "The OpenObex Development Team" )

set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LIB" )
set ( CPACK_RESOURCE_FILE_README  "${CMAKE_CURRENT_SOURCE_DIR}/README" )

set ( CPACK_PACKAGE_VERSION_MAJOR "${openobex_VERSION_MAJOR}" )
set ( CPACK_PACKAGE_VERSION_MINOR "${openobex_VERSION_MINOR}" )
set ( CPACK_PACKAGE_VERSION_PATCH "${openobex_VERSION_PATCH}" )
set ( CPACK_PACKAGE_VERSION       "${openobex_VERSION}" )

if ( UNIX )
  set ( CPACK_GENERATOR "TGZ" )
  set ( CPACK_SOURCE_GENERATOR "TGZ" )

elseif ( WIN32 )
  #
  # For NSIS, install from http://nsis.sf.net.
  # For ZIP, install e.g. info-zip from http://www.info-zip.org.
  #
  set ( CPACK_GENERATOR "ZIP;NSIS" )
  set ( CPACK_SOURCE_GENERATOR "ZIP" )
endif ( UNIX )
set ( CPACK_SOURCE_IGNORE_FILES
  "/build/"
  "/\\\\.git/"
  "/\\\\.gitignore$"
  "~$"
)

# this must _follow_ the settings!
include ( CPack )