diff options
author | Martin Braun <martin.braun@ettus.com> | 2015-01-09 18:39:29 +0100 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-01-19 09:07:16 +0100 |
commit | ad1ef1b64590b72a3286046f8baa79ac055f9923 (patch) | |
tree | 05950e99844a12c4c37a9a7a4f8b2cbbe6a59be4 /host/examples/init_usrp | |
parent | 734180c44b438cf707c4ff48bf4b11a8c5a94136 (diff) | |
download | uhd-ad1ef1b64590b72a3286046f8baa79ac055f9923.tar.gz uhd-ad1ef1b64590b72a3286046f8baa79ac055f9923.tar.bz2 uhd-ad1ef1b64590b72a3286046f8baa79ac055f9923.zip |
cmake: Added ENABLE_STATIC_LIBS option
- Allows building static libraries
- For users calling find_package(UHD), provides extra options
for building apps statically linking UHD.
- Updated the init_usrp example to link UHD statically.
Diffstat (limited to 'host/examples/init_usrp')
-rw-r--r-- | host/examples/init_usrp/CMakeLists.txt | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/host/examples/init_usrp/CMakeLists.txt b/host/examples/init_usrp/CMakeLists.txt index 420e79993..3560dbd45 100644 --- a/host/examples/init_usrp/CMakeLists.txt +++ b/host/examples/init_usrp/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2014 Ettus Research LLC +# Copyright 2014-2015 Ettus Research LLC # # 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 @@ -18,6 +18,11 @@ cmake_minimum_required(VERSION 2.8) ### Set up build environment ################################################## +# Choose a static or shared-library build (shared is default, and static will +# probably need some special care!) +# 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 program_options @@ -35,10 +40,10 @@ 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.7.1" REQUIRED) +find_package(UHD "3.8.0" REQUIRED) # The version in ^^^^^ here is a minimum version. # To specify an exact version: -#find_package(UHD 3.7.1 EXACT REQUIRED) +#find_package(UHD 3.8.1 EXACT REQUIRED) ### Configure Compiler ######################################################## include_directories( @@ -49,7 +54,26 @@ link_directories(${Boost_LIBRARY_DIRS}) ### Make the executable ####################################################### add_executable(init_usrp init_usrp.cpp) -target_link_libraries(init_usrp ${UHD_LIBRARIES} ${Boost_LIBRARIES}) +# Shared library case: All we need to do is link against the library, and +# anything else we need (in this case, some Boost libraries): +if(NOT UHD_USE_STATIC_LIBS) + message(STATUS "Linking against shared UHD library.") + target_link_libraries(init_usrp ${UHD_LIBRARIES} ${Boost_LIBRARIES}) +# Shared library case: All we need to do is link against the library, and +# anything else we need (in this case, some Boost libraries): +else(NOT UHD_USE_STATIC_LIBS) + message(STATUS "Linking against static UHD library.") + target_link_libraries(init_usrp + # We could use ${UHD_LIBRARIES}, but linking requires some extra flags, + # so we use this convenience variable provided to us + ${UHD_STATIC_LIB_LINK_FLAG} + # Also, when linking statically, we need to pull in all the deps for + # UHD as well, because the dependencies don't get resolved automatically + ${UHD_STATIC_LIB_DEPS} + ) +endif(NOT UHD_USE_STATIC_LIBS) + +### Once it's built... ######################################################## # Here, you would have commands to install your program. # We will skip these in this example. |