blob: dfffed74b8e066d876680ce87fd7740760dce63f [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)
Piotr Krysik0f510c02017-08-25 21:49:27 +020025project(gr-gsm 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########################################################################
Piotr Krysik59e4fe62017-09-24 11:26:54 +020039# Set cmake policies.
40########################################################################
41# This will suppress developer warnings during the cmake process that can occur
42# if a newer cmake version than the minimum is used.
43
44if(POLICY CMP0026)
45 cmake_policy(SET CMP0026 OLD)
46endif()
47if(POLICY CMP0043)
48 cmake_policy(SET CMP0043 OLD)
49endif()
50if(POLICY CMP0045)
51 cmake_policy(SET CMP0045 OLD)
52endif()
53if(POLICY CMP0046)
54 cmake_policy(SET CMP0046 OLD)
55endif()
56
57########################################################################
Piotr Krysikbb961c12017-08-24 15:35:42 +020058# Set version variables (
59########################################################################
60
61# Set the version information here
Piotr Krysik1e8a03c2017-08-30 10:59:44 +020062set(VERSION_INFO_MAJOR_VERSION 0)
63set(VERSION_INFO_API_COMPAT 41)
Piotr Krysik6ab71002017-11-05 17:44:53 +010064set(VERSION_INFO_MINOR_VERSION 3)
Piotr Krysik1e8a03c2017-08-30 10:59:44 +020065set(VERSION_INFO_MAINT_VERSION 0)
Piotr Krysikbb961c12017-08-24 15:35:42 +020066include(GrVersion) #setup version info
67
68########################################################################
piotr437f5462014-02-04 17:57:25 +010069# Compiler specific setup
70########################################################################
71if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
72 #http://gcc.gnu.org/wiki/Visibility
73 add_definitions(-fvisibility=hidden)
74endif()
75
76########################################################################
77# Find boost
78########################################################################
79if(UNIX AND EXISTS "/usr/lib64")
80 list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
81endif(UNIX AND EXISTS "/usr/lib64")
82set(Boost_ADDITIONAL_VERSIONS
83 "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"
84 "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"
85 "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"
86 "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"
87 "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"
88 "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"
89 "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"
90)
Piotr Krysik0ed39fb2018-02-27 08:35:22 +010091find_package(Boost "1.35" COMPONENTS filesystem system)# thread)
piotr437f5462014-02-04 17:57:25 +010092
93if(NOT Boost_FOUND)
ptrkrysik3c738102015-04-04 12:20:50 +020094 message(FATAL_ERROR "Boost required to compile gr-gsm")
piotr437f5462014-02-04 17:57:25 +010095endif()
96
Piotr Krysik7765bbd2016-04-14 13:20:38 +020097find_package(SWIG)
98
99if(SWIG_FOUND)
100 # Minimum SWIG version required is 1.3.31
101 set(SWIG_VERSION_CHECK FALSE)
102 if("${SWIG_VERSION}" VERSION_GREATER "1.3.30")
103 set(SWIG_VERSION_CHECK TRUE)
104 endif()
Piotr Krysikf6a76ab2016-04-26 16:00:48 +0200105else()
106 message(FATAL_ERROR "SWIG required to compile gr-gsm")
Piotr Krysik7765bbd2016-04-14 13:20:38 +0200107endif(SWIG_FOUND)
108
109
piotr437f5462014-02-04 17:57:25 +0100110########################################################################
111# Install directories
112########################################################################
113include(GrPlatform) #define LIB_SUFFIX
114set(GR_RUNTIME_DIR bin)
115set(GR_LIBRARY_DIR lib${LIB_SUFFIX})
ptrkrysik3be74a72014-12-13 10:11:00 +0100116set(GR_INCLUDE_DIR include/grgsm)
ptrkrysik3c738102015-04-04 12:20:50 +0200117set(GR_INCLUDE_DIR include/grgsm/misc_utils)
ptrkrysik3be74a72014-12-13 10:11:00 +0100118set(GR_INCLUDE_DIR include/grgsm/receiver)
119set(GR_INCLUDE_DIR include/grgsm/demapping)
120set(GR_INCLUDE_DIR include/grgsm/decoding)
piotr437f5462014-02-04 17:57:25 +0100121set(GR_DATA_DIR share)
122set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME})
123set(GR_DOC_DIR ${GR_DATA_DIR}/doc)
124set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME})
125set(GR_CONF_DIR etc)
126set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d)
127set(GR_LIBEXEC_DIR libexec)
128set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME})
129set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks)
130
131########################################################################
132# Find gnuradio build dependencies
133########################################################################
Piotr Krysik4a1ca982016-07-15 13:39:19 +0200134set(GR_REQUIRED_COMPONENTS RUNTIME FILTER PMT)
David Holmc7f26822014-12-03 22:18:12 +0100135find_package(Gnuradio)
ptrkrysikaea7f342014-12-03 00:37:57 +0100136find_package(Volk)
piotr437f5462014-02-04 17:57:25 +0100137find_package(CppUnit)
ptrkrysik35433842014-08-14 14:56:16 +0200138find_package(Doxygen)
Piotr Krysik1e73e042018-02-27 08:37:13 +0100139#find_package(Libosmocore)
Piotr Krysik70c25a12017-01-03 08:01:23 +0100140#find_package(Libosmocoding)
Piotr Krysik1e73e042018-02-27 08:37:13 +0100141#find_package(Libosmocodec)
piotr437f5462014-02-04 17:57:25 +0100142
piotr437f5462014-02-04 17:57:25 +0100143if(NOT GNURADIO_RUNTIME_FOUND)
ptrkrysik3c738102015-04-04 12:20:50 +0200144 message(FATAL_ERROR "GnuRadio Runtime required to compile gr-gsm")
piotr437f5462014-02-04 17:57:25 +0100145endif()
ptrkrysikaea7f342014-12-03 00:37:57 +0100146if(NOT VOLK_FOUND)
ptrkrysik3c738102015-04-04 12:20:50 +0200147 message(FATAL_ERROR "Volk library required to compile gr-gsm")
ptrkrysikaea7f342014-12-03 00:37:57 +0100148endif()
Piotr Krysik1e73e042018-02-27 08:37:13 +0100149#if(NOT CPPUNIT_FOUND)
150# message(FATAL_ERROR "CppUnit required to compile gr-gsm")
151#endif()
152#if(NOT LIBOSMOCORE_FOUND)
153# message(FATAL_ERROR "Libosmocore required to compile gr-gsm")
154#endif()
155#if(NOT LIBOSMOCODEC_FOUND)
156# message(FATAL_ERROR "Libosmocodec required to compile gr-gsm")
157#endif()
Piotr Krysik70c25a12017-01-03 08:01:23 +0100158#if(NOT LIBOSMOCODING_FOUND)
159# message(FATAL_ERROR "Libosmocoding required to compile gr-gsm")
160#endif()
piotr437f5462014-02-04 17:57:25 +0100161
162########################################################################
ptrkrysik35433842014-08-14 14:56:16 +0200163# Setup doxygen option
164########################################################################
165if(DOXYGEN_FOUND)
166 option(ENABLE_DOXYGEN "Build docs using Doxygen" ON)
167else(DOXYGEN_FOUND)
168 option(ENABLE_DOXYGEN "Build docs using Doxygen" OFF)
169endif(DOXYGEN_FOUND)
170
171########################################################################
piotr437f5462014-02-04 17:57:25 +0100172# Setup the include and linker paths
173########################################################################
174include_directories(
175 ${CMAKE_SOURCE_DIR}/lib
176 ${CMAKE_SOURCE_DIR}/include
177 ${CMAKE_BINARY_DIR}/lib
178 ${CMAKE_BINARY_DIR}/include
179 ${Boost_INCLUDE_DIRS}
180 ${CPPUNIT_INCLUDE_DIRS}
Piotr Krysik4a1ca982016-07-15 13:39:19 +0200181 ${GNURADIO_ALL_INCLUDE_DIRS}
Piotr Krysik1e73e042018-02-27 08:37:13 +0100182# ${LIBOSMOCORE_INCLUDE_DIR}
183 ${CMAKE_SOURCE_DIR}/lib/decoding
piotr437f5462014-02-04 17:57:25 +0100184)
185
186link_directories(
187 ${Boost_LIBRARY_DIRS}
188 ${CPPUNIT_LIBRARY_DIRS}
Piotr Krysik4a1ca982016-07-15 13:39:19 +0200189 ${GNURADIO_ALL_LIBRARY_DIRS}
piotr437f5462014-02-04 17:57:25 +0100190)
191
192# Set component parameters
193set(GR_GSM_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE INTERNAL "" FORCE)
194set(GR_GSM_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/swig CACHE INTERNAL "" FORCE)
195
196########################################################################
Steve Glass3f4b9492016-01-24 10:46:24 +1000197# On Apple only, set install name and use rpath correctly, if not already set
198########################################################################
199if(APPLE)
200 if(NOT CMAKE_INSTALL_NAME_DIR)
201 set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE PATH "Library Install Name Destination Directory" FORCE)
202 endif(NOT CMAKE_INSTALL_NAME_DIR)
203 if(NOT CMAKE_INSTALL_RPATH)
204 set(cmakE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE PATH "Library Install RPath" FORCE)
205 endif(NOT CMAKE_INSTALL_RPATH)
206 if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
207 set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "Do Build Using Library Install RPath" FORCE)
208 endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
209endif(APPLE)
210
211########################################################################
piotr437f5462014-02-04 17:57:25 +0100212# Create uninstall target
213########################################################################
214configure_file(
215 ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
216 ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
217@ONLY)
218
219add_custom_target(uninstall
220 ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
221)
222
223########################################################################
224# Add subdirectories
225########################################################################
ptrkrysik3c738102015-04-04 12:20:50 +0200226add_subdirectory(include/grgsm)
piotr437f5462014-02-04 17:57:25 +0100227add_subdirectory(lib)
228add_subdirectory(swig)
229add_subdirectory(python)
230add_subdirectory(grc)
231add_subdirectory(apps)
232add_subdirectory(docs)
233
234########################################################################
235# Install cmake search helper for this library
236########################################################################
Martin Jesper Low Madsenf3105d92015-06-24 13:33:56 +0200237install(FILES cmake/Modules/gr-gsmConfig.cmake
ptrkrysikec6306b2014-12-13 11:40:35 +0100238 DESTINATION lib${LIB_SUFFIX}/cmake/grgsm
piotr437f5462014-02-04 17:57:25 +0100239)
Piotr Krysik7765bbd2016-04-14 13:20:38 +0200240
241########################################################################
Piotr Krysikbb961c12017-08-24 15:35:42 +0200242# Print summary
243########################################################################
244message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")
Piotr Krysikdea05742017-08-25 21:55:41 +0200245message(STATUS "Building for version: ${VERSION} / ${LIBVER}")