-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add all necessary files to build OpenObex with CMake >= 2.6, includin…
…g instructions (closes #17)
- Loading branch information
Showing
15 changed files
with
1,431 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
cmake_minimum_required ( VERSION 2.4.7 FATAL_ERROR ) | ||
|
||
project ( openobex C ) | ||
|
||
# | ||
# The project version | ||
# | ||
set ( VERSION_MAJOR 1 ) | ||
set ( VERSION_MINOR 3 ) | ||
set ( VERSION_PATCH 0 ) | ||
|
||
set ( SHORT_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}" ) | ||
set ( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" ) | ||
if ( VERSION_PATCH GREATER 0 ) | ||
set ( SHORT_VERSION "${VERSION}" ) | ||
endif ( VERSION_PATCH GREATER 0 ) | ||
|
||
# | ||
# 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 ) | ||
|
||
# | ||
# define how to build libraries | ||
# | ||
option ( BUILD_SHARED_LIBS "Build shared libraries" ON ) | ||
|
||
# | ||
# check common compiler flags | ||
# | ||
include ( CheckCCompilerFlag ) | ||
if ( CMAKE_COMPILER_IS_GNUCC ) | ||
if ( UNIX AND NOT WIN32 ) | ||
set ( COMPILER_FLAG_VISIBILITY -fvisibility=hidden ) | ||
check_c_compiler_flag ( ${COMPILER_FLAG_VISIBILITY} COMPILER_SUPPORT_VISIBILITY ) | ||
endif ( UNIX AND NOT WIN32 ) | ||
|
||
set ( LINKER_FLAG_NOUNDEFINED -Wl,--no-undefined ) | ||
check_c_compiler_flag ( "${LINKER_FLAG_NOUNDEFINED}" 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 ) | ||
if (OPENOBEX_${transport}) | ||
add_definitions ( -DHAVE_${transport} ) | ||
endif (OPENOBEX_${transport}) | ||
endforeach ( transport ) | ||
|
||
if ( OPENOBEX_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 ) | ||
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}/lib" ) | ||
set ( includedir "\${prefix}/include" ) | ||
if ( OPENOBEX_USB AND UNIX AND NOT WIN32 ) | ||
set ( REQUIRES "libusb" ) | ||
endif ( OPENOBEX_USB AND UNIX AND NOT WIN32 ) | ||
foreach ( file openobex openobex-glib ) | ||
configure_file ( | ||
${PROJECT_SOURCE_DIR}/${file}.pc.in | ||
${CMAKE_CURRENT_BINARY_DIR}/${file}.pc | ||
@ONLY | ||
) | ||
endforeach ( file ) | ||
|
||
if ( NOT PKGCONFIG_INSTALL_DIR ) | ||
set ( PKGCONFIG_INSTALL_DIR lib/pkgconfig | ||
CACHE PATH "Where to install .pc files to" FORCE ) | ||
endif ( NOT PKGCONFIG_INSTALL_DIR ) | ||
mark_as_advanced ( PKGCONFIG_INSTALL_DIR ) | ||
|
||
|
||
# | ||
# process include directory | ||
# | ||
add_subdirectory ( include ) | ||
include_directories ( BEFORE SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/include" ) | ||
if ( MSVC ) | ||
include_directories ( AFTER SYSTEM "${CMAKE_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 ) | ||
|
||
|
||
# | ||
# build the documentation | ||
# | ||
add_subdirectory ( doc ) | ||
|
||
|
||
# | ||
# build the applications | ||
# | ||
add_custom_target ( openobex-apps ) | ||
add_subdirectory ( apps ) | ||
add_subdirectory ( ircp ) | ||
|
||
|
||
# | ||
# build the glib binding library | ||
# not enabled by default because it requires an additional dependency | ||
# | ||
option ( BUILD_GLIB_BINDING "Build the glib binding library") | ||
if ( BUILD_GLIB_BINDING ) | ||
add_subdirectory ( glib ) | ||
endif ( BUILD_GLIB_BINDING ) | ||
|
||
|
||
# | ||
# 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 "${VERSION_MAJOR}" ) | ||
set ( CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}" ) | ||
set ( CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}" ) | ||
set ( CPACK_PACKAGE_VERSION "${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/" | ||
"/\\\\.svn/" | ||
"~$" | ||
) | ||
|
||
# this must _follow_ the settings! | ||
include ( CPack ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# - Find system default bluetooth implementation | ||
# | ||
# On Linux it will use PkgConfig if present and supported, | ||
# else and on all other architectures, it looks for it on its own. | ||
# The following standard variables get defined: | ||
# Bluetooth_FOUND: true if Bluetooth was found | ||
# Bluetooth_INCLUDE_DIRS: the directory that contains the include file | ||
# Bluetooth_LIBRARIES: full path to the libraries | ||
|
||
include ( CheckCSourceCompiles ) | ||
include ( CheckLibraryExists ) | ||
include ( CheckIncludeFile ) | ||
|
||
if ( CMAKE_SYSTEM_NAME STREQUAL "Linux" ) | ||
find_package ( PkgConfig ) | ||
if ( PKG_CONFIG_FOUND ) | ||
pkg_check_modules ( PKGCONFIG_BLUEZ bluez ) | ||
endif ( PKG_CONFIG_FOUND ) | ||
if ( PKGCONFIG_BLUEZ_FOUND ) | ||
set ( Bluetooth_FOUND ${PKGCONFIG_BLUEZ_FOUND} ) | ||
foreach ( i ${PKGCONFIG_BLUEZ_LIBRARIES} ) | ||
find_library ( ${i}_LIBRARY | ||
NAMES ${i} | ||
PATHS ${PKGCONFIG_BLUEZ_LIBRARY_DIRS} | ||
) | ||
list ( APPEND Bluetooth_LIBRARIES ${${i}_LIBRARY} ) | ||
mark_as_advanced ( ${i}_LIBRARY ) | ||
endforeach ( i ) | ||
set ( Bluetooth_LIBRARIES "${Bluetooth_LIBRARIES}" CACHE STRING "" ) | ||
mark_as_advanced ( Bluetooth_LIBRARIES ) | ||
add_definitions ( -DHAVE_SDPLIB ) | ||
else ( PKGCONFIG_BLUEZ_FOUND ) | ||
find_path ( Bluetooth_INCLUDE_DIRS | ||
NAMES | ||
bluetooth/bluetooth.h | ||
PATH_SUFFIXES | ||
include | ||
) | ||
mark_as_advanced ( Bluetooth_INCLUDE_DIRS ) | ||
|
||
find_library ( OpenObex_LIBRARY | ||
NAMES | ||
bluetooth | ||
PATH_SUFFIXES | ||
lib | ||
) | ||
set ( Bluetooth_LIBRARIES ${Bluetooth_LIBRARY} CACHE STRING "") | ||
mark_as_advanced ( Bluetooth_LIBRARY Bluetooth_LIBRARIES ) | ||
|
||
if ( Bluetooth_INCLUDE_DIRS AND Bluetooth_LIBRARIES ) | ||
set ( Bluetooth_FOUND true ) | ||
endif ( Bluetooth_INCLUDE_DIRS AND Bluetooth_LIBRARIES ) | ||
endif ( PKGCONFIG_BLUEZ_FOUND ) | ||
|
||
elseif ( CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" ) | ||
find_path ( Bluetooth_INCLUDE_DIRS | ||
NAMES | ||
bluetooth.h | ||
PATH_SUFFIXES | ||
include | ||
) | ||
mark_as_advanced ( Bluetooth_INCLUDE_DIRS ) | ||
|
||
if ( Bluetooth_INCLUDE_DIRS ) | ||
set ( CMAKE_REQUIRED_INCLUDES ${Bluetooth_INLUDE_DIRS} ) | ||
CHECK_C_SOURCE_COMPILES ( | ||
"#include <bluetooth.h> | ||
int main () { | ||
struct sockaddr_rfcomm f; | ||
return 0; | ||
}" | ||
Bluetooth_FOUND | ||
) | ||
endif ( Bluetooth_INCLUDE_DIRS ) | ||
|
||
elseif ( CMAKE_SYSTEM_NAME STREQUAL "NetBSD" ) | ||
find_path ( Bluetooth_INCLUDE_DIRS | ||
NAMES | ||
bluetooth.h | ||
PATH_SUFFIXES | ||
include | ||
) | ||
mark_as_advanced ( Bluetooth_INCLUDE_DIRS ) | ||
|
||
if ( Bluetooth_INCLUDE_DIRS ) | ||
set ( CMAKE_REQUIRED_INCLUDES ${Bluetooth_INLUDE_DIRS} ) | ||
CHECK_C_SOURCE_COMPILES ( | ||
"#include <bluetooth.h> | ||
int main () { | ||
struct sockaddr_bt f; | ||
return 0; | ||
}" | ||
Bluetooth_FOUND | ||
) | ||
endif ( Bluetooth_INCLUDE_DIRS ) | ||
|
||
elseif ( WIN32 ) | ||
CHECK_C_SOURCE_COMPILES ( | ||
"#include <winsock2.h> | ||
#include <ws2bth.h> | ||
int main () { | ||
SOCKADDR_BTH f; | ||
return 0; | ||
}" | ||
Bluetooth_FOUND | ||
) | ||
endif ( CMAKE_SYSTEM_NAME STREQUAL "Linux" ) | ||
|
||
if ( Bluetooth_FOUND ) | ||
set ( Bluetooth_FOUND true ) | ||
else ( Bluetooth_FOUND ) | ||
set ( Bluetooth_FOUND false ) | ||
endif ( Bluetooth_FOUND ) | ||
|
||
if ( NOT Bluetooth_FOUND ) | ||
if ( NOT Bluetooth_FIND_QUIETLY ) | ||
message ( STATUS "Bluetooth not found." ) | ||
endif ( NOT Bluetooth_FIND_QUIETLY ) | ||
if ( Bluetooth_FIND_REQUIRED ) | ||
message ( FATAL_ERROR "Bluetooth not found but required." ) | ||
endif ( Bluetooth_FIND_REQUIRED ) | ||
endif ( NOT Bluetooth_FOUND ) |
Oops, something went wrong.