1
|
# Copyright 2012 OSMOCOM Project
|
2
|
#
|
3
|
# This file is part of OsmoSDR
|
4
|
#
|
5
|
# GNU Radio is free software; you can redistribute it and/or modify
|
6
|
# it under the terms of the GNU General Public License as published by
|
7
|
# the Free Software Foundation; either version 3, or (at your option)
|
8
|
# any later version.
|
9
|
#
|
10
|
# GNU Radio is distributed in the hope that it will be useful,
|
11
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
# GNU General Public License for more details.
|
14
|
#
|
15
|
# You should have received a copy of the GNU General Public License
|
16
|
# along with GNU Radio; see the file COPYING. If not, write to
|
17
|
# the Free Software Foundation, Inc., 51 Franklin Street,
|
18
|
# Boston, MA 02110-1301, USA.
|
19
|
|
20
|
########################################################################
|
21
|
# Project setup
|
22
|
########################################################################
|
23
|
cmake_minimum_required(VERSION 2.6)
|
24
|
project(osmosdr C)
|
25
|
|
26
|
#select the release build type by default to get optimization flags
|
27
|
if(NOT CMAKE_BUILD_TYPE)
|
28
|
set(CMAKE_BUILD_TYPE "Release")
|
29
|
message(STATUS "Build type not specified: defaulting to release.")
|
30
|
endif(NOT CMAKE_BUILD_TYPE)
|
31
|
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
|
32
|
|
33
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
34
|
|
35
|
########################################################################
|
36
|
# Compiler specific setup
|
37
|
########################################################################
|
38
|
if(CMAKE_COMPILER_IS_GNUCC AND NOT WIN32)
|
39
|
ADD_DEFINITIONS(-Wall)
|
40
|
ADD_DEFINITIONS(-Wextra)
|
41
|
ADD_DEFINITIONS(-Wno-unused)
|
42
|
ADD_DEFINITIONS(-Wsign-compare)
|
43
|
#http://gcc.gnu.org/wiki/Visibility
|
44
|
add_definitions(-fvisibility=hidden)
|
45
|
endif()
|
46
|
|
47
|
########################################################################
|
48
|
# Find build dependencies
|
49
|
########################################################################
|
50
|
find_package(PkgConfig)
|
51
|
find_package(LibUSB)
|
52
|
|
53
|
if(NOT LIBUSB_FOUND)
|
54
|
message(FATAL_ERROR "LibUSB 1.0 required to compile OsmoSDR")
|
55
|
endif()
|
56
|
|
57
|
########################################################################
|
58
|
# Setup the include and linker paths
|
59
|
########################################################################
|
60
|
include_directories(
|
61
|
${CMAKE_SOURCE_DIR}/include
|
62
|
${LIBUSB_INCLUDE_DIR}
|
63
|
)
|
64
|
|
65
|
#link_directories(
|
66
|
# ...
|
67
|
#)
|
68
|
|
69
|
# Set component parameters
|
70
|
#set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE INTERNAL "" FORCE)
|
71
|
|
72
|
########################################################################
|
73
|
# Create uninstall target
|
74
|
########################################################################
|
75
|
configure_file(
|
76
|
${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
|
77
|
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
78
|
@ONLY)
|
79
|
|
80
|
add_custom_target(uninstall
|
81
|
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
82
|
)
|
83
|
|
84
|
########################################################################
|
85
|
# Install udev rules
|
86
|
########################################################################
|
87
|
option(INSTALL_UDEV_RULES "Install udev rules for OsmoSDR" OFF)
|
88
|
if (INSTALL_UDEV_RULES)
|
89
|
install (
|
90
|
FILES osmosdr.rules
|
91
|
DESTINATION "/etc/udev/rules.d"
|
92
|
COMPONENT "udev"
|
93
|
)
|
94
|
else (INSTALL_UDEV_RULES)
|
95
|
message (STATUS "Udev rules not being installed, install them with -DINSTALL_UDEV_RULES=ON")
|
96
|
endif (INSTALL_UDEV_RULES)
|
97
|
|
98
|
########################################################################
|
99
|
# Add subdirectories
|
100
|
########################################################################
|
101
|
add_subdirectory(include)
|
102
|
add_subdirectory(src)
|
103
|
|
104
|
########################################################################
|
105
|
# Create Pkg Config File
|
106
|
########################################################################
|
107
|
FOREACH(inc ${LIBUSB_INCLUDE_DIR})
|
108
|
LIST(APPEND OSMOSDR_PC_CFLAGS "-I${inc}")
|
109
|
ENDFOREACH(inc)
|
110
|
|
111
|
FOREACH(lib ${LIBUSB_LIBRARY_DIRS})
|
112
|
LIST(APPEND OSMOSDR_PC_LIBS "-L${lib}")
|
113
|
ENDFOREACH(lib)
|
114
|
|
115
|
# use space-separation format for the pc file
|
116
|
STRING(REPLACE ";" " " OSMOSDR_PC_CFLAGS "${OSMOSDR_PC_CFLAGS}")
|
117
|
STRING(REPLACE ";" " " OSMOSDR_PC_LIBS "${OSMOSDR_PC_LIBS}")
|
118
|
|
119
|
# unset these vars to avoid hard-coded paths to cross environment
|
120
|
IF(CMAKE_CROSSCOMPILING)
|
121
|
UNSET(OSMOSDR_PC_CFLAGS)
|
122
|
UNSET(OSMOSDR_PC_LIBS)
|
123
|
ENDIF(CMAKE_CROSSCOMPILING)
|
124
|
|
125
|
set(prefix ${CMAKE_INSTALL_PREFIX})
|
126
|
set(exec_prefix \${prefix})
|
127
|
set(libdir \${exec_prefix}/lib)
|
128
|
set(includedir \${prefix}/include)
|
129
|
|
130
|
CONFIGURE_FILE(
|
131
|
${CMAKE_CURRENT_SOURCE_DIR}/libosmosdr.pc.in
|
132
|
${CMAKE_CURRENT_BINARY_DIR}/libosmosdr.pc
|
133
|
@ONLY)
|
134
|
|
135
|
INSTALL(
|
136
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/libosmosdr.pc
|
137
|
DESTINATION lib/pkgconfig
|
138
|
)
|