cmake: Use new UHDBoost.cmake in init_usrp and tools

Modifies the CMake for the following utilities:
- init_usrp (example)
- kitchen_sink
- nirio_programmer
This commit is contained in:
Michael Dickens 2019-10-15 11:36:24 -07:00 committed by Martin Braun
parent 90f8cbc12f
commit f520573c3d
3 changed files with 43 additions and 81 deletions

View file

@ -5,7 +5,16 @@
# SPDX-License-Identifier: GPL-3.0-or-later
#
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.5.1)
project(INIT_USRP CXX)
### Configure Compiler ########################################################
set(CMAKE_CXX_STANDARD 11)
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_EXE_LINKER_FLAGS "-lthr ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
endif()
### Set up build environment ##################################################
# Choose a static or shared-library build (shared is default, and static will
@ -13,48 +22,23 @@ cmake_minimum_required(VERSION 2.8)
# Set this to ON in order to link a static build of UHD:
option(UHD_USE_STATIC_LIBS OFF)
# This example also requires Boost:
set(BOOST_REQUIRED_COMPONENTS
# To add UHD as a dependency to this project, add a line such as this:
find_package(UHD 3.15.0 REQUIRED)
# The version in ^^^^^ here is a minimum version.
# To specify an exact version:
#find_package(UHD 3.15.0 EXACT REQUIRED)
# This example also requires Boost.
# Set components here, then include UHDBoost to do the actual finding
set(UHD_BOOST_REQUIRED_COMPONENTS
program_options
system
thread
)
if(MSVC)
set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
if(BOOST_ALL_DYN_LINK)
add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
else(BOOST_ALL_DYN_LINK)
set(BOOST_REQUIRED_COMPONENTS) #empty components list for static link
endif(BOOST_ALL_DYN_LINK)
endif(MSVC)
find_package(Boost "1.46" REQUIRED ${BOOST_REQUIRED_COMPONENTS})
# To add UHD as a dependency to this project, add a line such as this:
find_package(UHD "3.8.0" REQUIRED)
# The version in ^^^^^ here is a minimum version.
# To specify an exact version:
#find_package(UHD 3.8.1 EXACT REQUIRED)
### Configure Compiler ########################################################
if(CMAKE_VERSION VERSION_LESS "3.1")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
if("${IS_APPLE}" STREQUAL "")
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
endif()
endif()
else()
set(CMAKE_CXX_STANDARD 11)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_EXE_LINKER_FLAGS "-lthr ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
endif()
set(BOOST_MIN_VERSION 1.58)
include(UHDBoost)
# need these include and link directories for the build
include_directories(
${Boost_INCLUDE_DIRS}
${UHD_INCLUDE_DIRS}

View file

@ -1,5 +1,6 @@
#
# Copyright 2010-2012 Ettus Research LLC
# Copyright 2019 Ettus Research, a National Instruments Brand
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -15,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.5.1)
project(kitchen_sink CXX)
###############################################################################
@ -28,8 +29,11 @@ endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
### Set up build environment ##################################################
#### Set up UHD:
find_package(UHD 3.15.0.0 REQUIRED)
#### Set up Boost:
set(BOOST_REQUIRED_COMPONENTS
set(UHD_BOOST_REQUIRED_COMPONENTS
date_time
filesystem
program_options
@ -38,30 +42,8 @@ set(BOOST_REQUIRED_COMPONENTS
thread
unit_test_framework
)
if(UNIX AND EXISTS "/usr/lib64")
list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
endif(UNIX AND EXISTS "/usr/lib64")
if(MSVC)
set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
if(BOOST_ALL_DYN_LINK)
add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
else(BOOST_ALL_DYN_LINK)
unset(BOOST_REQUIRED_COMPONENTS) #empty components list for static link
endif(BOOST_ALL_DYN_LINK)
endif(MSVC)
set(Boost_ADDITIONAL_VERSIONS
"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"
"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"
"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"
"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"
"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"
)
find_package(Boost 1.46 COMPONENTS ${BOOST_REQUIRED_COMPONENTS})
#### Set up UHD:
find_package(UHD "3.7.3" REQUIRED)
set(BOOST_MIN_VERSION "1.58")
include(UHDBoost)
### Configure Compiler ########################################################
include_directories(

View file

@ -1,5 +1,6 @@
#
# Copyright 2014-2015 Ettus Research LLC
# Copyright 2019 Ettus Research, a National Instruments Brand
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -15,7 +16,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.5.1)
project(NIRIO_PROGRAMMER CXX)
set(CMAKE_CXX_STANDARD 11)
### Set up build environment ##################################################
# Choose a static or shared-library build (shared is default, and static will
@ -23,28 +26,21 @@ cmake_minimum_required(VERSION 2.8)
# Set this to ON in order to link a static build of UHD:
option(UHD_USE_STATIC_LIBS OFF)
# To add UHD as a dependency to this project, add a line such as this:
find_package(UHD 3.15.0.0 REQUIRED)
# The version in ^^^^^ here is a minimum version.
# To specify an exact version:
#find_package(UHD 3.8.1 EXACT REQUIRED)
# This example also requires Boost:
set(BOOST_REQUIRED_COMPONENTS
set(UHD_BOOST_REQUIRED_COMPONENTS
program_options
system
thread
regex
)
if(MSVC)
set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking")
if(BOOST_ALL_DYN_LINK)
add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc
else(BOOST_ALL_DYN_LINK)
set(BOOST_REQUIRED_COMPONENTS) #empty components list for static link
endif(BOOST_ALL_DYN_LINK)
endif(MSVC)
find_package(Boost "1.46" REQUIRED ${BOOST_REQUIRED_COMPONENTS})
# To add UHD as a dependency to this project, add a line such as this:
find_package(UHD "3.8.0" REQUIRED)
# The version in ^^^^^ here is a minimum version.
# To specify an exact version:
#find_package(UHD 3.8.1 EXACT REQUIRED)
set(BOOST_MIN_VERSION "1.58")
include(UHDBoost)
### Configure Compiler ########################################################
include_directories(