piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 1 | # 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 | ######################################################################## |
| 24 | cmake_minimum_required(VERSION 2.6) |
Piotr Krysik | 0f510c0 | 2017-08-25 21:49:27 +0200 | [diff] [blame] | 25 | project(gr-gsm CXX C) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 26 | enable_testing() |
| 27 | |
ptrkrysik | 5821379 | 2014-10-30 09:05:15 +0100 | [diff] [blame] | 28 | #set(CMAKE_BUILD_TYPE "Debug") |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 29 | #select the release build type by default to get optimization flags |
| 30 | if(NOT CMAKE_BUILD_TYPE) |
| 31 | set(CMAKE_BUILD_TYPE "Release") |
| 32 | message(STATUS "Build type not specified: defaulting to release.") |
| 33 | endif(NOT CMAKE_BUILD_TYPE) |
| 34 | set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") |
| 35 | |
| 36 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) |
| 37 | |
| 38 | ######################################################################## |
Piotr Krysik | 59e4fe6 | 2017-09-24 11:26:54 +0200 | [diff] [blame] | 39 | # 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 | |
| 44 | if(POLICY CMP0026) |
| 45 | cmake_policy(SET CMP0026 OLD) |
| 46 | endif() |
| 47 | if(POLICY CMP0043) |
| 48 | cmake_policy(SET CMP0043 OLD) |
| 49 | endif() |
| 50 | if(POLICY CMP0045) |
| 51 | cmake_policy(SET CMP0045 OLD) |
| 52 | endif() |
| 53 | if(POLICY CMP0046) |
| 54 | cmake_policy(SET CMP0046 OLD) |
| 55 | endif() |
| 56 | |
| 57 | ######################################################################## |
Piotr Krysik | bb961c1 | 2017-08-24 15:35:42 +0200 | [diff] [blame] | 58 | # Set version variables ( |
| 59 | ######################################################################## |
| 60 | |
| 61 | # Set the version information here |
Piotr Krysik | 1e8a03c | 2017-08-30 10:59:44 +0200 | [diff] [blame] | 62 | set(VERSION_INFO_MAJOR_VERSION 0) |
| 63 | set(VERSION_INFO_API_COMPAT 41) |
Piotr Krysik | 8ef9dad | 2018-03-05 12:39:06 +0100 | [diff] [blame] | 64 | set(VERSION_INFO_MINOR_VERSION 4) |
| 65 | set(VERSION_INFO_MAINT_VERSION git) |
Piotr Krysik | bb961c1 | 2017-08-24 15:35:42 +0200 | [diff] [blame] | 66 | include(GrVersion) #setup version info |
| 67 | |
| 68 | ######################################################################## |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 69 | # Compiler specific setup |
| 70 | ######################################################################## |
| 71 | if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) |
| 72 | #http://gcc.gnu.org/wiki/Visibility |
| 73 | add_definitions(-fvisibility=hidden) |
| 74 | endif() |
| 75 | |
| 76 | ######################################################################## |
| 77 | # Find boost |
| 78 | ######################################################################## |
| 79 | if(UNIX AND EXISTS "/usr/lib64") |
| 80 | list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix |
| 81 | endif(UNIX AND EXISTS "/usr/lib64") |
| 82 | set(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 Krysik | 0ed39fb | 2018-02-27 08:35:22 +0100 | [diff] [blame] | 91 | find_package(Boost "1.35" COMPONENTS filesystem system)# thread) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 92 | |
| 93 | if(NOT Boost_FOUND) |
ptrkrysik | 3c73810 | 2015-04-04 12:20:50 +0200 | [diff] [blame] | 94 | message(FATAL_ERROR "Boost required to compile gr-gsm") |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 95 | endif() |
| 96 | |
Piotr Krysik | 7765bbd | 2016-04-14 13:20:38 +0200 | [diff] [blame] | 97 | find_package(SWIG) |
| 98 | |
| 99 | if(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 Krysik | f6a76ab | 2016-04-26 16:00:48 +0200 | [diff] [blame] | 105 | else() |
| 106 | message(FATAL_ERROR "SWIG required to compile gr-gsm") |
Piotr Krysik | 7765bbd | 2016-04-14 13:20:38 +0200 | [diff] [blame] | 107 | endif(SWIG_FOUND) |
| 108 | |
| 109 | |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 110 | ######################################################################## |
| 111 | # Install directories |
| 112 | ######################################################################## |
| 113 | include(GrPlatform) #define LIB_SUFFIX |
| 114 | set(GR_RUNTIME_DIR bin) |
| 115 | set(GR_LIBRARY_DIR lib${LIB_SUFFIX}) |
ptrkrysik | 3be74a7 | 2014-12-13 10:11:00 +0100 | [diff] [blame] | 116 | set(GR_INCLUDE_DIR include/grgsm) |
ptrkrysik | 3c73810 | 2015-04-04 12:20:50 +0200 | [diff] [blame] | 117 | set(GR_INCLUDE_DIR include/grgsm/misc_utils) |
ptrkrysik | 3be74a7 | 2014-12-13 10:11:00 +0100 | [diff] [blame] | 118 | set(GR_INCLUDE_DIR include/grgsm/receiver) |
| 119 | set(GR_INCLUDE_DIR include/grgsm/demapping) |
| 120 | set(GR_INCLUDE_DIR include/grgsm/decoding) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 121 | set(GR_DATA_DIR share) |
| 122 | set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME}) |
| 123 | set(GR_DOC_DIR ${GR_DATA_DIR}/doc) |
| 124 | set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME}) |
| 125 | set(GR_CONF_DIR etc) |
| 126 | set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d) |
| 127 | set(GR_LIBEXEC_DIR libexec) |
| 128 | set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME}) |
| 129 | set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) |
| 130 | |
| 131 | ######################################################################## |
| 132 | # Find gnuradio build dependencies |
| 133 | ######################################################################## |
Piotr Krysik | 4a1ca98 | 2016-07-15 13:39:19 +0200 | [diff] [blame] | 134 | set(GR_REQUIRED_COMPONENTS RUNTIME FILTER PMT) |
David Holm | c7f2682 | 2014-12-03 22:18:12 +0100 | [diff] [blame] | 135 | find_package(Gnuradio) |
ptrkrysik | aea7f34 | 2014-12-03 00:37:57 +0100 | [diff] [blame] | 136 | find_package(Volk) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 137 | find_package(CppUnit) |
Piotr Krysik | 1a5e87e | 2018-03-04 19:36:24 +0100 | [diff] [blame] | 138 | #find_package(Doxygen) |
| 139 | find_package(Libosmocore) |
| 140 | find_package(Libosmocodec) |
| 141 | find_package(Libosmocoding) |
| 142 | |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 143 | |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 144 | if(NOT GNURADIO_RUNTIME_FOUND) |
ptrkrysik | 3c73810 | 2015-04-04 12:20:50 +0200 | [diff] [blame] | 145 | message(FATAL_ERROR "GnuRadio Runtime required to compile gr-gsm") |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 146 | endif() |
ptrkrysik | aea7f34 | 2014-12-03 00:37:57 +0100 | [diff] [blame] | 147 | if(NOT VOLK_FOUND) |
ptrkrysik | 3c73810 | 2015-04-04 12:20:50 +0200 | [diff] [blame] | 148 | message(FATAL_ERROR "Volk library required to compile gr-gsm") |
ptrkrysik | aea7f34 | 2014-12-03 00:37:57 +0100 | [diff] [blame] | 149 | endif() |
Piotr Krysik | 1a5e87e | 2018-03-04 19:36:24 +0100 | [diff] [blame] | 150 | if(NOT CPPUNIT_FOUND) |
| 151 | message(FATAL_ERROR "CppUnit required to compile gr-gsm") |
| 152 | endif() |
| 153 | if(NOT LIBOSMOCORE_FOUND OR NOT LIBOSMOCODEC_FOUND) |
Piotr Krysik | 86c9164 | 2018-03-04 22:08:52 +0100 | [diff] [blame] | 154 | message(STATUS "Compiling local version of libosmocore") |
Piotr Krysik | 1a5e87e | 2018-03-04 19:36:24 +0100 | [diff] [blame] | 155 | elseif(NOT LIBOSMOCODING_FOUND) |
| 156 | message(STATUS "Compiling local version of libosmocoding") |
| 157 | endif() |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 158 | |
| 159 | ######################################################################## |
ptrkrysik | 3543384 | 2014-08-14 14:56:16 +0200 | [diff] [blame] | 160 | # Setup doxygen option |
| 161 | ######################################################################## |
Piotr Krysik | 79e712c | 2018-02-27 11:17:38 +0100 | [diff] [blame] | 162 | #if(DOXYGEN_FOUND) |
| 163 | # option(ENABLE_DOXYGEN "Build docs using Doxygen" ON) |
| 164 | #else(DOXYGEN_FOUND) |
Piotr Krysik | 1a5e87e | 2018-03-04 19:36:24 +0100 | [diff] [blame] | 165 | option(ENABLE_DOXYGEN "Build docs using Doxygen" OFF) #TODO: write doxygen docs |
Piotr Krysik | 79e712c | 2018-02-27 11:17:38 +0100 | [diff] [blame] | 166 | #endif(DOXYGEN_FOUND) |
ptrkrysik | 3543384 | 2014-08-14 14:56:16 +0200 | [diff] [blame] | 167 | |
| 168 | ######################################################################## |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 169 | # Setup the include and linker paths |
| 170 | ######################################################################## |
Piotr Krysik | 63492bd | 2018-03-04 23:01:43 +0100 | [diff] [blame] | 171 | |
Piotr Krysik | 1a5e87e | 2018-03-04 19:36:24 +0100 | [diff] [blame] | 172 | list (APPEND grgsm_include_directories |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 173 | ${CMAKE_SOURCE_DIR}/lib |
| 174 | ${CMAKE_SOURCE_DIR}/include |
| 175 | ${CMAKE_BINARY_DIR}/lib |
| 176 | ${CMAKE_BINARY_DIR}/include |
| 177 | ${Boost_INCLUDE_DIRS} |
| 178 | ${CPPUNIT_INCLUDE_DIRS} |
Piotr Krysik | 4a1ca98 | 2016-07-15 13:39:19 +0200 | [diff] [blame] | 179 | ${GNURADIO_ALL_INCLUDE_DIRS} |
Piotr Krysik | 1e73e04 | 2018-02-27 08:37:13 +0100 | [diff] [blame] | 180 | ${CMAKE_SOURCE_DIR}/lib/decoding |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 181 | ) |
| 182 | |
Piotr Krysik | 1a5e87e | 2018-03-04 19:36:24 +0100 | [diff] [blame] | 183 | if(LIBOSMOCORE_FOUND) |
| 184 | list (APPEND grgsm_include_directories |
| 185 | ${LIBOSMOCORE_INCLUDE_DIR} |
| 186 | ) |
| 187 | endif() |
| 188 | |
| 189 | include_directories( |
| 190 | ${grgsm_include_directories} |
| 191 | ) |
| 192 | |
Piotr Krysik | 63492bd | 2018-03-04 23:01:43 +0100 | [diff] [blame] | 193 | list (APPEND grgsm_link_directories |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 194 | ${Boost_LIBRARY_DIRS} |
| 195 | ${CPPUNIT_LIBRARY_DIRS} |
Piotr Krysik | 4a1ca98 | 2016-07-15 13:39:19 +0200 | [diff] [blame] | 196 | ${GNURADIO_ALL_LIBRARY_DIRS} |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 197 | ) |
| 198 | |
Piotr Krysik | 1a5e87e | 2018-03-04 19:36:24 +0100 | [diff] [blame] | 199 | if(LIBOSMOCORE_FOUND) |
| 200 | list (APPEND grgsm_link_directories |
| 201 | ${LIBOSMOCORE_LIBRARY_DIRS} |
| 202 | ) |
| 203 | endif() |
| 204 | |
| 205 | link_directories( |
| 206 | ${grgsm_link_directories} |
| 207 | ) |
| 208 | |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 209 | # Set component parameters |
| 210 | set(GR_GSM_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE INTERNAL "" FORCE) |
| 211 | set(GR_GSM_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/swig CACHE INTERNAL "" FORCE) |
| 212 | |
| 213 | ######################################################################## |
Steve Glass | 3f4b949 | 2016-01-24 10:46:24 +1000 | [diff] [blame] | 214 | # On Apple only, set install name and use rpath correctly, if not already set |
| 215 | ######################################################################## |
| 216 | if(APPLE) |
| 217 | if(NOT CMAKE_INSTALL_NAME_DIR) |
| 218 | set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE PATH "Library Install Name Destination Directory" FORCE) |
| 219 | endif(NOT CMAKE_INSTALL_NAME_DIR) |
| 220 | if(NOT CMAKE_INSTALL_RPATH) |
| 221 | set(cmakE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE PATH "Library Install RPath" FORCE) |
| 222 | endif(NOT CMAKE_INSTALL_RPATH) |
| 223 | if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) |
| 224 | set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "Do Build Using Library Install RPath" FORCE) |
| 225 | endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) |
| 226 | endif(APPLE) |
| 227 | |
| 228 | ######################################################################## |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 229 | # Create uninstall target |
| 230 | ######################################################################## |
| 231 | configure_file( |
| 232 | ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in |
| 233 | ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake |
| 234 | @ONLY) |
| 235 | |
| 236 | add_custom_target(uninstall |
| 237 | ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake |
| 238 | ) |
| 239 | |
| 240 | ######################################################################## |
| 241 | # Add subdirectories |
| 242 | ######################################################################## |
ptrkrysik | 3c73810 | 2015-04-04 12:20:50 +0200 | [diff] [blame] | 243 | add_subdirectory(include/grgsm) |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 244 | add_subdirectory(lib) |
| 245 | add_subdirectory(swig) |
| 246 | add_subdirectory(python) |
| 247 | add_subdirectory(grc) |
| 248 | add_subdirectory(apps) |
| 249 | add_subdirectory(docs) |
| 250 | |
| 251 | ######################################################################## |
| 252 | # Install cmake search helper for this library |
| 253 | ######################################################################## |
Martin Jesper Low Madsen | f3105d9 | 2015-06-24 13:33:56 +0200 | [diff] [blame] | 254 | install(FILES cmake/Modules/gr-gsmConfig.cmake |
ptrkrysik | ec6306b | 2014-12-13 11:40:35 +0100 | [diff] [blame] | 255 | DESTINATION lib${LIB_SUFFIX}/cmake/grgsm |
piotr | 437f546 | 2014-02-04 17:57:25 +0100 | [diff] [blame] | 256 | ) |
Piotr Krysik | 7765bbd | 2016-04-14 13:20:38 +0200 | [diff] [blame] | 257 | |
| 258 | ######################################################################## |
Piotr Krysik | bb961c1 | 2017-08-24 15:35:42 +0200 | [diff] [blame] | 259 | # Print summary |
| 260 | ######################################################################## |
| 261 | message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}") |
Piotr Krysik | dea0574 | 2017-08-25 21:55:41 +0200 | [diff] [blame] | 262 | message(STATUS "Building for version: ${VERSION} / ${LIBVER}") |