Ticket #54709: CMakeLists.txt

File CMakeLists.txt, 7.7 KB (added by LoraLightLuke, 7 years ago)
Line 
1# Copyright 2011,2012,2014 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# gr-lora specific options
22########################################################################
23option(HAS_MONGODB "Support for storing data to MongoDB" OFF)
24option(DEBUG "Print debug output" OFF)
25
26if(DEBUG)
27    message("-- Enabling debug mode")
28    add_definitions(-DDEBUG)
29endif(DEBUG)
30
31########################################################################
32# Project setup
33########################################################################
34cmake_minimum_required(VERSION 2.6)
35project(gr-lora CXX C)
36enable_testing()
37
38#select the release build type by default to get optimization flags
39if(NOT CMAKE_BUILD_TYPE)
40   set(CMAKE_BUILD_TYPE "Release")
41   message(STATUS "Build type not specified: defaulting to release.")
42endif(NOT CMAKE_BUILD_TYPE)
43set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
44
45#make sure our local CMake Modules path comes first
46list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
47
48########################################################################
49# Compiler specific setup
50########################################################################
51if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32)
52    #http://gcc.gnu.org/wiki/Visibility
53    add_definitions(-fvisibility=hidden)
54    add_definitions(-std=c++11)
55    add_definitions(-Wall)
56    add_definitions(-Wextra)
57endif()
58
59if(APPLE)
60    add_definitions(-std=c++11)
61    add_definitions(-Wall)
62    add_definitions(-Wextra)
63endif()
64
65########################################################################
66# Find boost
67########################################################################
68if(UNIX AND EXISTS "/usr/lib64")
69    list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
70endif(UNIX AND EXISTS "/usr/lib64")
71set(Boost_ADDITIONAL_VERSIONS
72    "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"
73    "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"
74    "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"
75    "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"
76    "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"
77    "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"
78    "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"
79)
80find_package(Boost "1.35" COMPONENTS filesystem system)
81
82if(NOT Boost_FOUND)
83    message(FATAL_ERROR "Boost required to compile lora")
84endif()
85
86########################################################################
87# Install directories
88########################################################################
89include(GrPlatform) #define LIB_SUFFIX
90set(GR_RUNTIME_DIR      bin)
91set(GR_LIBRARY_DIR      lib${LIB_SUFFIX})
92set(GR_INCLUDE_DIR      include/lora)
93set(GR_DATA_DIR         share)
94set(GR_PKG_DATA_DIR     ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME})
95set(GR_DOC_DIR          ${GR_DATA_DIR}/doc)
96set(GR_PKG_DOC_DIR      ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME})
97set(GR_CONF_DIR         etc)
98set(GR_PKG_CONF_DIR     ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d)
99set(GR_LIBEXEC_DIR      libexec)
100set(GR_PKG_LIBEXEC_DIR  ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME})
101set(GRC_BLOCKS_DIR      ${GR_PKG_DATA_DIR}/grc/blocks)
102
103########################################################################
104# On Apple only, set install name and use rpath correctly, if not already set
105########################################################################
106if(APPLE)
107    if(NOT CMAKE_INSTALL_NAME_DIR)
108        set(CMAKE_INSTALL_NAME_DIR
109            ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE
110            PATH "Library Install Name Destination Directory" FORCE)
111    endif(NOT CMAKE_INSTALL_NAME_DIR)
112    if(NOT CMAKE_INSTALL_RPATH)
113        set(CMAKE_INSTALL_RPATH
114            ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE
115            PATH "Library Install RPath" FORCE)
116    endif(NOT CMAKE_INSTALL_RPATH)
117    if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
118        set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE
119            BOOL "Do Build Using Library Install RPath" FORCE)
120    endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
121endif(APPLE)
122
123########################################################################
124# Find gnuradio build dependencies
125########################################################################
126find_package(CppUnit)
127find_package(Doxygen)
128
129# Search for GNU Radio and its components and versions. Add any
130# components required to the list of GR_REQUIRED_COMPONENTS (in all
131# caps such as FILTER or FFT) and change the version to the minimum
132# API compatible version required.
133set(GR_REQUIRED_COMPONENTS RUNTIME FILTER)
134find_package(Gnuradio "3.7.2" REQUIRED)
135
136if(NOT CPPUNIT_FOUND)
137    message(FATAL_ERROR "CppUnit required to compile lora")
138endif()
139
140########################################################################
141# Setup doxygen option
142########################################################################
143if(DOXYGEN_FOUND)
144        option(ENABLE_DOXYGEN "Build docs using Doxygen" ON)
145else(DOXYGEN_FOUND)
146        option(ENABLE_DOXYGEN "Build docs using Doxygen" OFF)
147endif(DOXYGEN_FOUND)
148
149########################################################################
150# Setup the include and linker paths
151########################################################################
152include_directories(
153    ${CMAKE_SOURCE_DIR}/lib
154    ${CMAKE_SOURCE_DIR}/include
155    ${CMAKE_BINARY_DIR}/lib
156    ${CMAKE_BINARY_DIR}/include
157    ${Boost_INCLUDE_DIRS}
158    ${CPPUNIT_INCLUDE_DIRS}
159    ${GNURADIO_ALL_INCLUDE_DIRS}
160)
161
162link_directories(
163    ${Boost_LIBRARY_DIRS}
164    ${CPPUNIT_LIBRARY_DIRS}
165    ${GNURADIO_RUNTIME_LIBRARY_DIRS}
166)
167
168# Set component parameters
169set(GR_LORA_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE INTERNAL "" FORCE)
170set(GR_LORA_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/swig CACHE INTERNAL "" FORCE)
171
172########################################################################
173# Create uninstall target
174########################################################################
175configure_file(
176    ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
177    ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
178@ONLY)
179
180add_custom_target(uninstall
181    ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
182)
183
184########################################################################
185# Add subdirectories
186########################################################################
187add_subdirectory(include/lora)
188add_subdirectory(lib)
189add_subdirectory(swig)
190add_subdirectory(python)
191add_subdirectory(grc)
192add_subdirectory(apps)
193add_subdirectory(docs)
194
195########################################################################
196# Install cmake search helper for this library
197########################################################################
198if(NOT CMAKE_MODULES_DIR)
199  set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake)
200endif(NOT CMAKE_MODULES_DIR)
201
202install(FILES cmake/Modules/loraConfig.cmake
203    DESTINATION ${CMAKE_MODULES_DIR}/lora
204)