| 1 | cmake_minimum_required ( VERSION 2.6 FATAL_ERROR ) |
|---|
| 2 | |
|---|
| 3 | project ( openobex C ) |
|---|
| 4 | |
|---|
| 5 | # |
|---|
| 6 | # The project version |
|---|
| 7 | # |
|---|
| 8 | set ( VERSION_MAJOR 1 ) |
|---|
| 9 | set ( VERSION_MINOR 3 ) |
|---|
| 10 | set ( VERSION_PATCH 0 ) |
|---|
| 11 | |
|---|
| 12 | set ( SHORT_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}" ) |
|---|
| 13 | set ( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" ) |
|---|
| 14 | if ( VERSION_PATCH GREATER 0 ) |
|---|
| 15 | set ( SHORT_VERSION "${VERSION}" ) |
|---|
| 16 | endif ( VERSION_PATCH GREATER 0 ) |
|---|
| 17 | |
|---|
| 18 | # |
|---|
| 19 | # The path for our own CMake modules |
|---|
| 20 | # |
|---|
| 21 | set ( CMAKE_MODULE_PATH |
|---|
| 22 | ${PROJECT_SOURCE_DIR}/CMakeModules |
|---|
| 23 | ) |
|---|
| 24 | |
|---|
| 25 | # |
|---|
| 26 | # Define the default build type |
|---|
| 27 | # |
|---|
| 28 | set ( CMAKE_CONFIGURATION_TYPES "Release;Debug" |
|---|
| 29 | CACHE STRING "" FORCE ) |
|---|
| 30 | if ( NOT CMAKE_BUILD_TYPE ) |
|---|
| 31 | set ( CMAKE_BUILD_TYPE Release |
|---|
| 32 | CACHE STRING "Build type" FORCE ) |
|---|
| 33 | endif ( NOT CMAKE_BUILD_TYPE ) |
|---|
| 34 | |
|---|
| 35 | # |
|---|
| 36 | # define how to build libraries |
|---|
| 37 | # |
|---|
| 38 | option ( BUILD_SHARED_LIBS "Build shared libraries" ON ) |
|---|
| 39 | |
|---|
| 40 | # |
|---|
| 41 | # check common compiler flags |
|---|
| 42 | # |
|---|
| 43 | include ( CheckCCompilerFlag ) |
|---|
| 44 | if ( 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 ) |
|---|
| 52 | endif ( CMAKE_COMPILER_IS_GNUCC ) |
|---|
| 53 | |
|---|
| 54 | if ( 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 ) |
|---|
| 57 | endif ( MSVC ) |
|---|
| 58 | |
|---|
| 59 | # |
|---|
| 60 | # which transports shall be included |
|---|
| 61 | # |
|---|
| 62 | find_package ( Bluetooth ) |
|---|
| 63 | set ( OPENOBEX_BLUETOOTH_AVAILABLE ${Bluetooth_FOUND} ) |
|---|
| 64 | |
|---|
| 65 | find_package ( Irda ) |
|---|
| 66 | set ( OPENOBEX_IRDA_AVAILABLE ${Irda_FOUND} ) |
|---|
| 67 | |
|---|
| 68 | find_package ( LibUSB ) |
|---|
| 69 | set ( OPENOBEX_USB_AVAILABLE ${LibUSB_FOUND} ) |
|---|
| 70 | |
|---|
| 71 | foreach ( 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}) |
|---|
| 82 | endforeach ( transport ) |
|---|
| 83 | |
|---|
| 84 | if ( 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 ) |
|---|
| 91 | endif ( OPENOBEX_IRDA ) |
|---|
| 92 | |
|---|
| 93 | if ( 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 ) |
|---|
| 100 | endif ( 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 | # |
|---|
| 107 | set ( prefix "${CMAKE_INSTALL_PREFIX}" ) |
|---|
| 108 | set ( exec_prefix "\${prefix}" ) |
|---|
| 109 | set ( libdir "\${prefix}/lib" ) |
|---|
| 110 | set ( includedir "\${prefix}/include" ) |
|---|
| 111 | if ( OPENOBEX_USB AND UNIX AND NOT WIN32 ) |
|---|
| 112 | set ( REQUIRES "libusb" ) |
|---|
| 113 | endif ( OPENOBEX_USB AND UNIX AND NOT WIN32 ) |
|---|
| 114 | foreach ( file openobex openobex-glib ) |
|---|
| 115 | configure_file ( |
|---|
| 116 | ${PROJECT_SOURCE_DIR}/${file}.pc.in |
|---|
| 117 | ${CMAKE_CURRENT_BINARY_DIR}/${file}.pc |
|---|
| 118 | @ONLY |
|---|
| 119 | ) |
|---|
| 120 | endforeach ( file ) |
|---|
| 121 | |
|---|
| 122 | if ( NOT PKGCONFIG_INSTALL_DIR ) |
|---|
| 123 | set ( PKGCONFIG_INSTALL_DIR lib/pkgconfig |
|---|
| 124 | CACHE PATH "Where to install .pc files to" FORCE ) |
|---|
| 125 | endif ( NOT PKGCONFIG_INSTALL_DIR ) |
|---|
| 126 | mark_as_advanced ( PKGCONFIG_INSTALL_DIR ) |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | # |
|---|
| 130 | # process include directory |
|---|
| 131 | # |
|---|
| 132 | add_subdirectory ( include ) |
|---|
| 133 | include_directories ( BEFORE SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/include" ) |
|---|
| 134 | if ( MSVC ) |
|---|
| 135 | include_directories ( AFTER SYSTEM "${CMAKE_SOURCE_DIR}/include/msvc" ) |
|---|
| 136 | endif ( MSVC ) |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | # |
|---|
| 140 | # build the main library |
|---|
| 141 | # |
|---|
| 142 | add_subdirectory ( lib ) |
|---|
| 143 | link_directories ( "${CMAKE_CURRENT_BINARY_DIR}/lib" ) |
|---|
| 144 | if ( BUILD_SHARED_LIBS ) |
|---|
| 145 | add_definitions ( -DOPENOBEX_DLL ) |
|---|
| 146 | endif ( BUILD_SHARED_LIBS ) |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | # |
|---|
| 150 | # build the documentation |
|---|
| 151 | # |
|---|
| 152 | add_subdirectory ( doc ) |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | # |
|---|
| 156 | # build the applications |
|---|
| 157 | # |
|---|
| 158 | add_custom_target ( openobex-apps ) |
|---|
| 159 | add_subdirectory ( apps ) |
|---|
| 160 | add_subdirectory ( ircp ) |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | # |
|---|
| 164 | # build the glib binding library |
|---|
| 165 | # not enabled by default because it requires an additional dependency |
|---|
| 166 | # |
|---|
| 167 | option ( BUILD_GLIB_BINDING "Build the glib binding library") |
|---|
| 168 | if ( BUILD_GLIB_BINDING ) |
|---|
| 169 | add_subdirectory ( glib ) |
|---|
| 170 | endif ( BUILD_GLIB_BINDING ) |
|---|
| 171 | |
|---|
| 172 | |
|---|
| 173 | # |
|---|
| 174 | # The following adds CPack support |
|---|
| 175 | # |
|---|
| 176 | set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenObex" ) |
|---|
| 177 | set ( CPACK_PACKAGE_VENDOR "The OpenObex Development Team" ) |
|---|
| 178 | |
|---|
| 179 | set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LIB" ) |
|---|
| 180 | set ( CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README" ) |
|---|
| 181 | |
|---|
| 182 | set ( CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}" ) |
|---|
| 183 | set ( CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}" ) |
|---|
| 184 | set ( CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}" ) |
|---|
| 185 | set ( CPACK_PACKAGE_VERSION "${VERSION}" ) |
|---|
| 186 | |
|---|
| 187 | if ( UNIX ) |
|---|
| 188 | set ( CPACK_GENERATOR "TGZ" ) |
|---|
| 189 | set ( CPACK_SOURCE_GENERATOR "TGZ" ) |
|---|
| 190 | |
|---|
| 191 | elseif ( 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" ) |
|---|
| 198 | endif ( UNIX ) |
|---|
| 199 | set ( CPACK_SOURCE_IGNORE_FILES |
|---|
| 200 | "/build/" |
|---|
| 201 | "/\\\\.svn/" |
|---|
| 202 | "~$" |
|---|
| 203 | ) |
|---|
| 204 | |
|---|
| 205 | # this must _follow_ the settings! |
|---|
| 206 | include ( CPack ) |
|---|