blob: 11d589d4af9abd19f479a8b282af2a698709add5 [file] [log] [blame]
piotr437f5462014-02-04 17:57:25 +01001# Copyright 2011,2012 Free Software Foundation, Inc.
2#
3# This file is part of GNU Radio
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########################################################################
22# Project setup
23########################################################################
24cmake_minimum_required(VERSION 2.6)
ptrkrysika25b8302015-05-08 08:59:17 +020025project(gr-grgsm CXX C)
piotr437f5462014-02-04 17:57:25 +010026enable_testing()
27
ptrkrysik58213792014-10-30 09:05:15 +010028#set(CMAKE_BUILD_TYPE "Debug")
piotr437f5462014-02-04 17:57:25 +010029#select the release build type by default to get optimization flags
30if(NOT CMAKE_BUILD_TYPE)
31 set(CMAKE_BUILD_TYPE "Release")
32 message(STATUS "Build type not specified: defaulting to release.")
33endif(NOT CMAKE_BUILD_TYPE)
34set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
35
36list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
37
38########################################################################
39# Compiler specific setup
40########################################################################
41if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
42 #http://gcc.gnu.org/wiki/Visibility
43 add_definitions(-fvisibility=hidden)
44endif()
45
46########################################################################
47# Find boost
48########################################################################
49if(UNIX AND EXISTS "/usr/lib64")
50 list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
51endif(UNIX AND EXISTS "/usr/lib64")
52set(Boost_ADDITIONAL_VERSIONS
53 "1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39"
54 "1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44"
55 "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49"
56 "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54"
57 "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59"
58 "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64"
59 "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69"
60)
Martin Jesper Low Madsenf3105d92015-06-24 13:33:56 +020061find_package(Boost "1.35" COMPONENTS filesystem system thread)
piotr437f5462014-02-04 17:57:25 +010062
63if(NOT Boost_FOUND)
ptrkrysik3c738102015-04-04 12:20:50 +020064 message(FATAL_ERROR "Boost required to compile gr-gsm")
piotr437f5462014-02-04 17:57:25 +010065endif()
66
Piotr Krysik7765bbd2016-04-14 13:20:38 +020067find_package(SWIG)
68
69if(SWIG_FOUND)
70 # Minimum SWIG version required is 1.3.31
71 set(SWIG_VERSION_CHECK FALSE)
72 if("${SWIG_VERSION}" VERSION_GREATER "1.3.30")
73 set(SWIG_VERSION_CHECK TRUE)
74 endif()
Piotr Krysikf6a76ab2016-04-26 16:00:48 +020075else()
76 message(FATAL_ERROR "SWIG required to compile gr-gsm")
Piotr Krysik7765bbd2016-04-14 13:20:38 +020077endif(SWIG_FOUND)
78
79
piotr437f5462014-02-04 17:57:25 +010080########################################################################
81# Install directories
82########################################################################
83include(GrPlatform) #define LIB_SUFFIX
84set(GR_RUNTIME_DIR bin)
85set(GR_LIBRARY_DIR lib${LIB_SUFFIX})
ptrkrysik3be74a72014-12-13 10:11:00 +010086set(GR_INCLUDE_DIR include/grgsm)
ptrkrysik3c738102015-04-04 12:20:50 +020087set(GR_INCLUDE_DIR include/grgsm/misc_utils)
ptrkrysik3be74a72014-12-13 10:11:00 +010088set(GR_INCLUDE_DIR include/grgsm/receiver)
89set(GR_INCLUDE_DIR include/grgsm/demapping)
90set(GR_INCLUDE_DIR include/grgsm/decoding)
piotr437f5462014-02-04 17:57:25 +010091set(GR_DATA_DIR share)
92set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME})
93set(GR_DOC_DIR ${GR_DATA_DIR}/doc)
94set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME})
95set(GR_CONF_DIR etc)
96set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d)
97set(GR_LIBEXEC_DIR libexec)
98set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME})
99set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks)
100
101########################################################################
102# Find gnuradio build dependencies
103########################################################################
Piotr Krysik4a1ca982016-07-15 13:39:19 +0200104set(GR_REQUIRED_COMPONENTS RUNTIME FILTER PMT)
David Holmc7f26822014-12-03 22:18:12 +0100105find_package(Gnuradio)
ptrkrysikaea7f342014-12-03 00:37:57 +0100106find_package(Volk)
piotr437f5462014-02-04 17:57:25 +0100107find_package(CppUnit)
ptrkrysik35433842014-08-14 14:56:16 +0200108find_package(Doxygen)
Roman Khassraf9c588462015-07-17 13:57:24 +0200109find_package(Libosmocore)
Piotr Krysikb516e6d2016-09-28 11:53:26 +0200110find_package(Libosmocoding)
piotr437f5462014-02-04 17:57:25 +0100111
piotr437f5462014-02-04 17:57:25 +0100112if(NOT GNURADIO_RUNTIME_FOUND)
ptrkrysik3c738102015-04-04 12:20:50 +0200113 message(FATAL_ERROR "GnuRadio Runtime required to compile gr-gsm")
piotr437f5462014-02-04 17:57:25 +0100114endif()
ptrkrysikaea7f342014-12-03 00:37:57 +0100115if(NOT VOLK_FOUND)
ptrkrysik3c738102015-04-04 12:20:50 +0200116 message(FATAL_ERROR "Volk library required to compile gr-gsm")
ptrkrysikaea7f342014-12-03 00:37:57 +0100117endif()
piotr437f5462014-02-04 17:57:25 +0100118if(NOT CPPUNIT_FOUND)
ptrkrysik3c738102015-04-04 12:20:50 +0200119 message(FATAL_ERROR "CppUnit required to compile gr-gsm")
piotr437f5462014-02-04 17:57:25 +0100120endif()
Roman Khassraf9c588462015-07-17 13:57:24 +0200121if(NOT LIBOSMOCORE_FOUND)
122 message(FATAL_ERROR "Libosmocore required to compile gr-gsm")
123endif()
Piotr Krysikb516e6d2016-09-28 11:53:26 +0200124if(NOT LIBOSMOCODING_FOUND)
125 message(FATAL_ERROR "Libosmocoding required to compile gr-gsm")
126endif()
piotr437f5462014-02-04 17:57:25 +0100127
128########################################################################
ptrkrysik35433842014-08-14 14:56:16 +0200129# Setup doxygen option
130########################################################################
131if(DOXYGEN_FOUND)
132 option(ENABLE_DOXYGEN "Build docs using Doxygen" ON)
133else(DOXYGEN_FOUND)
134 option(ENABLE_DOXYGEN "Build docs using Doxygen" OFF)
135endif(DOXYGEN_FOUND)
136
137########################################################################
piotr437f5462014-02-04 17:57:25 +0100138# Setup the include and linker paths
139########################################################################
140include_directories(
141 ${CMAKE_SOURCE_DIR}/lib
142 ${CMAKE_SOURCE_DIR}/include
143 ${CMAKE_BINARY_DIR}/lib
144 ${CMAKE_BINARY_DIR}/include
145 ${Boost_INCLUDE_DIRS}
146 ${CPPUNIT_INCLUDE_DIRS}
Piotr Krysik4a1ca982016-07-15 13:39:19 +0200147 ${GNURADIO_ALL_INCLUDE_DIRS}
Roman Khassraf9c588462015-07-17 13:57:24 +0200148 ${LIBOSMOCORE_INCLUDE_DIR}
piotr437f5462014-02-04 17:57:25 +0100149)
150
151link_directories(
152 ${Boost_LIBRARY_DIRS}
153 ${CPPUNIT_LIBRARY_DIRS}
Piotr Krysik4a1ca982016-07-15 13:39:19 +0200154 ${GNURADIO_ALL_LIBRARY_DIRS}
piotr437f5462014-02-04 17:57:25 +0100155)
156
157# Set component parameters
158set(GR_GSM_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE INTERNAL "" FORCE)
159set(GR_GSM_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/swig CACHE INTERNAL "" FORCE)
160
161########################################################################
Steve Glass3f4b9492016-01-24 10:46:24 +1000162# On Apple only, set install name and use rpath correctly, if not already set
163########################################################################
164if(APPLE)
165 if(NOT CMAKE_INSTALL_NAME_DIR)
166 set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE PATH "Library Install Name Destination Directory" FORCE)
167 endif(NOT CMAKE_INSTALL_NAME_DIR)
168 if(NOT CMAKE_INSTALL_RPATH)
169 set(cmakE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE PATH "Library Install RPath" FORCE)
170 endif(NOT CMAKE_INSTALL_RPATH)
171 if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
172 set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "Do Build Using Library Install RPath" FORCE)
173 endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
174endif(APPLE)
175
176########################################################################
piotr437f5462014-02-04 17:57:25 +0100177# Create uninstall target
178########################################################################
179configure_file(
180 ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
181 ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
182@ONLY)
183
184add_custom_target(uninstall
185 ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
186)
187
188########################################################################
189# Add subdirectories
190########################################################################
ptrkrysik3c738102015-04-04 12:20:50 +0200191add_subdirectory(include/grgsm)
piotr437f5462014-02-04 17:57:25 +0100192add_subdirectory(lib)
193add_subdirectory(swig)
194add_subdirectory(python)
195add_subdirectory(grc)
196add_subdirectory(apps)
197add_subdirectory(docs)
198
199########################################################################
200# Install cmake search helper for this library
201########################################################################
Martin Jesper Low Madsenf3105d92015-06-24 13:33:56 +0200202install(FILES cmake/Modules/gr-gsmConfig.cmake
ptrkrysikec6306b2014-12-13 11:40:35 +0100203 DESTINATION lib${LIB_SUFFIX}/cmake/grgsm
piotr437f5462014-02-04 17:57:25 +0100204)
Piotr Krysik7765bbd2016-04-14 13:20:38 +0200205
206########################################################################
207# Cpack stuff
208########################################################################
209set(CPACK_DEBIAN_PACKAGE_DEPENDS "gnuradio (>> 3.7.9), gr-osmosdr, libosmogsm5")
210set(CPACK_PACKAGE_NAME gr-gsm)
211set(CPACK_PACKAGE_VERSION 0.9.0)
212set(CPACK_PACKAGE_MAINTAINER ptrkrysik@gmail.com)
213set(CPACK_PACKAGE_DESCRIPTION "GSM functionality for Gnuradio")
214set(CPACK_PACKAGE_CONTACT ptrkrysik@gmail.com)
215include(CPack)