blob: a03ca94ecb4f71b3b3ef676889b8f2ff4afd5790 [file] [log] [blame]
Vasil Velichkov1789ae22019-08-13 20:32:05 +00001# Copyright 2011,2012,2014,2016,2018 Free Software Foundation, Inc.
piotr437f5462014-02-04 17:57:25 +01002#
Vasil Velichkov1789ae22019-08-13 20:32:05 +00003# This file was generated by gr_modtool, a tool from the GNU Radio framework
4# This file is a part of gr-gsm
piotr437f5462014-02-04 17:57:25 +01005#
6# GNU Radio is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3, or (at your option)
9# any later version.
10#
11# GNU Radio is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with GNU Radio; see the file COPYING. If not, write to
18# the Free Software Foundation, Inc., 51 Franklin Street,
19# Boston, MA 02110-1301, USA.
20
piotr437f5462014-02-04 17:57:25 +010021########################################################################
22# Project setup
23########################################################################
Vasil Velichkov1789ae22019-08-13 20:32:05 +000024cmake_minimum_required(VERSION 3.8)
Piotr Krysik0f510c02017-08-25 21:49:27 +020025project(gr-gsm CXX C)
piotr437f5462014-02-04 17:57:25 +010026enable_testing()
27
Vasil Velichkov1789ae22019-08-13 20:32:05 +000028# Install to PyBOMBS target prefix if defined
29if(DEFINED ENV{PYBOMBS_PREFIX})
30 set(CMAKE_INSTALL_PREFIX $ENV{PYBOMBS_PREFIX})
31 message(STATUS "PyBOMBS installed GNU Radio. Setting CMAKE_INSTALL_PREFIX to $ENV{PYBOMBS_PREFIX}")
32endif()
33
34# Select the release build type by default to get optimization flags
piotr437f5462014-02-04 17:57:25 +010035if(NOT CMAKE_BUILD_TYPE)
36 set(CMAKE_BUILD_TYPE "Release")
37 message(STATUS "Build type not specified: defaulting to release.")
38endif(NOT CMAKE_BUILD_TYPE)
39set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
40
Vasil Velichkov1789ae22019-08-13 20:32:05 +000041# Make sure our local CMake Modules path comes first
42list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
Piotr Krysikbb961c12017-08-24 15:35:42 +020043
44# Set the version information here
Vasil Velichkov1789ae22019-08-13 20:32:05 +000045set(VERSION_MAJOR 1)
46set(VERSION_API 0)
47set(VERSION_ABI 0)
48set(VERSION_PATCH git)
49
50cmake_policy(SET CMP0011 NEW)
51
52# Enable generation of compile_commands.json for code completion engines
53set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Piotr Krysikbb961c12017-08-24 15:35:42 +020054
55########################################################################
piotr437f5462014-02-04 17:57:25 +010056# Compiler specific setup
57########################################################################
Vasil Velichkov1789ae22019-08-13 20:32:05 +000058if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
59 CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
60 AND NOT WIN32)
piotr437f5462014-02-04 17:57:25 +010061 #http://gcc.gnu.org/wiki/Visibility
62 add_definitions(-fvisibility=hidden)
63endif()
64
Vasil Velichkov1789ae22019-08-13 20:32:05 +000065IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
66 SET(CMAKE_CXX_STANDARD 11)
67ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
68 SET(CMAKE_CXX_STANDARD 11)
69ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
70 SET(CMAKE_CXX_STANDARD 11)
71ELSE()
72 message(WARNING "C++ standard could not be set because compiler is not GNU, Clang or MSVC.")
73ENDIF()
piotr437f5462014-02-04 17:57:25 +010074
Vasil Velichkov1789ae22019-08-13 20:32:05 +000075IF(CMAKE_C_COMPILER_ID STREQUAL "GNU")
76 SET(CMAKE_C_STANDARD 11)
77ELSEIF(CMAKE_C_COMPILER_ID MATCHES "Clang")
78 SET(CMAKE_C_STANDARD 11)
79ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
80 SET(CMAKE_C_STANDARD 11)
81ELSE()
82 message(WARNING "C standard could not be set because compiler is not GNU, Clang or MSVC.")
83ENDIF()
Piotr Krysik7765bbd2016-04-14 13:20:38 +020084
piotr437f5462014-02-04 17:57:25 +010085########################################################################
86# Install directories
87########################################################################
Vasil Velichkov1789ae22019-08-13 20:32:05 +000088find_package(Gnuradio "3.8" REQUIRED COMPONENTS blocks filter fft CONFIG)
89include(GrVersion)
90
piotr437f5462014-02-04 17:57:25 +010091include(GrPlatform) #define LIB_SUFFIX
Vasil Velichkov1789ae22019-08-13 20:32:05 +000092
93if(NOT CMAKE_MODULES_DIR)
94 set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake)
95endif(NOT CMAKE_MODULES_DIR)
96
ptrkrysik3be74a72014-12-13 10:11:00 +010097set(GR_INCLUDE_DIR include/grgsm)
Vasil Velichkov1789ae22019-08-13 20:32:05 +000098set(GR_CMAKE_DIR ${CMAKE_MODULES_DIR}/gsm)
piotr437f5462014-02-04 17:57:25 +010099set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME})
piotr437f5462014-02-04 17:57:25 +0100100set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME})
piotr437f5462014-02-04 17:57:25 +0100101set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d)
piotr437f5462014-02-04 17:57:25 +0100102set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME})
piotr437f5462014-02-04 17:57:25 +0100103
104########################################################################
Steve Glass3f4b9492016-01-24 10:46:24 +1000105# On Apple only, set install name and use rpath correctly, if not already set
106########################################################################
107if(APPLE)
108 if(NOT CMAKE_INSTALL_NAME_DIR)
Vasil Velichkov1789ae22019-08-13 20:32:05 +0000109 set(CMAKE_INSTALL_NAME_DIR
110 ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE
111 PATH "Library Install Name Destination Directory" FORCE)
Steve Glass3f4b9492016-01-24 10:46:24 +1000112 endif(NOT CMAKE_INSTALL_NAME_DIR)
113 if(NOT CMAKE_INSTALL_RPATH)
Vasil Velichkov1789ae22019-08-13 20:32:05 +0000114 set(CMAKE_INSTALL_RPATH
115 ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE
116 PATH "Library Install RPath" FORCE)
Steve Glass3f4b9492016-01-24 10:46:24 +1000117 endif(NOT CMAKE_INSTALL_RPATH)
118 if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
Vasil Velichkov1789ae22019-08-13 20:32:05 +0000119 set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE
120 BOOL "Do Build Using Library Install RPath" FORCE)
Steve Glass3f4b9492016-01-24 10:46:24 +1000121 endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
122endif(APPLE)
123
124########################################################################
Vasil Velichkov1789ae22019-08-13 20:32:05 +0000125# Find gnuradio build dependencies
126########################################################################
127find_package(Doxygen)
128
129########################################################################
130# Find osmocom build dependencies
131########################################################################
Vasil Velichkov1789ae22019-08-13 20:32:05 +0000132find_package(Libosmocore)
133find_package(Libosmocodec)
134find_package(Libosmocoding)
135find_package(Libosmogsm)
Vasil Velichkov1789ae22019-08-13 20:32:05 +0000136
137########################################################################
138# Setup doxygen option
139########################################################################
140if(DOXYGEN_FOUND)
141 option(ENABLE_DOXYGEN "Build docs using Doxygen" ON)
142else(DOXYGEN_FOUND)
143 option(ENABLE_DOXYGEN "Build docs using Doxygen" OFF)
144endif(DOXYGEN_FOUND)
145
146########################################################################
piotr437f5462014-02-04 17:57:25 +0100147# Create uninstall target
148########################################################################
149configure_file(
150 ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
151 ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
152@ONLY)
153
154add_custom_target(uninstall
155 ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
Vasil Velichkov1789ae22019-08-13 20:32:05 +0000156 )
157
piotr437f5462014-02-04 17:57:25 +0100158
159########################################################################
160# Add subdirectories
161########################################################################
ptrkrysik3c738102015-04-04 12:20:50 +0200162add_subdirectory(include/grgsm)
piotr437f5462014-02-04 17:57:25 +0100163add_subdirectory(lib)
Vasil Velichkov1789ae22019-08-13 20:32:05 +0000164add_subdirectory(apps)
165add_subdirectory(docs)
piotr437f5462014-02-04 17:57:25 +0100166add_subdirectory(swig)
167add_subdirectory(python)
168add_subdirectory(grc)
piotr437f5462014-02-04 17:57:25 +0100169
170########################################################################
171# Install cmake search helper for this library
172########################################################################
Piotr Krysik7765bbd2016-04-14 13:20:38 +0200173
Piotr Krysikdf417732020-02-16 08:58:28 +0100174install(
175 FILES
176 cmake/Modules/gr-gsmConfig.cmake
Piotr Krysik21b0f7d2020-02-16 08:46:26 +0100177 DESTINATION ${CMAKE_MODULES_DIR}/grgsm
Vasil Velichkov1789ae22019-08-13 20:32:05 +0000178)